TITLE: What does it exactly mean for a subspace to be dense?
QUESTION [9 upvotes]: My understanding of rationals being dense in real numbers:
I know when we say the rationals are dense in real is because between any two rationals we can find a irrational number. In other words we can approximate irrational numbers using rationals. I think a more precise definition would be is that any open ball around a irrational number will contain a rational number. 
If what I said is correct, I am trying to think about what it means for $C[a,b]$ (which are the continuous complex valued functions on [a.b]) to be dense subspace of $L^2[a,b]$. From what I said above, I want to say that all functions in $L^2[a,b]$ can be approximated by functions from $C[a,b]$. Is the intuition correct here, what would the precise definition in this case?

REPLY [3 votes]: In general topological spaces, a dense set is one whose intersection with any nonempty open set is nonempty. For metric spaces, since we have a topological base of open balls, this is equivalent to every point in space space being arbitrarily close, with regards to the metric, to point in the dense set.
Note that $L^2$ is a metric space, where $d(f,g) = ||f-g||_2$, with $||\cdot||_2$ being the $L^2$ norm.

REPLY [2 votes]: Your generalization is (more or less) correct. In a metric space $M$, we say a subset $D\subseteq M$ is dense if for every open ball $B$, there is at least one member $d\in D$ that is also in $B$. In a topological space, we say a subset is dense if it meets every non-empty open neighborhood. 
Now, towards answering your question. We know that $L^2([a,b])$ is a metric space, with it's metric given by $d(f,g)=\int_a^b |f-g|^2\ dx$. So for the continuous functions to be dense, we need them to meet every open ball. More precisely the continuous functions are dense if, for a given $f$ and $\epsilon>0$, there exists a continuous function $g$ so that $\int_a^b |f-g|^2\ dx<\epsilon$. 
There are plenty of ways to show this, depending on where you are in your measure theory studies. If you've just begun, look at Littlewood's three principles (Luzin's theorem will help you here). For readers a bit more familiar with the theory, one may take an approximation to the identity $\phi_n$, and put $f_n=\phi_n*f$.  Then $f_n$ is continuous, being the convolution of two $L^1$ functions ($L^2$ functions are $L^1$ on finite measure sets by Cauchy-Schwarz) and $f_n$ converges in $L^2$ norm to $f$.