Elegant proof that $L^2([a,b])$ is separable

Is anybody aware of, or can provide at least an outline, of a proof that the Hilbert space of Lebesgue functions square-integrable on the closed real interval [a,b], equipped with the $L^2$ norm, is separable?

I've seen an ugly proof involving truncated functions so I'm not desperate, but would really like to use something nice. By the way, if you refer to a particular dense countable subset, could you please explain why it is dense and countable even if you consider it to be a fairly 'high-profile' set?

Thanks

-
polynomials with rational coefficients – yoyo Apr 26 '11 at 20:47

The set of functions $\{e_n\colon n\in\mathbb{Z}\}$ given by $$e_n(x) = \exp\left(2\pi in\frac{x-a}{b-a}\right)$$ is dense in $C[a,b]$ by the Stone-Weierstrass Theorem.* Since $C[a,b]$ is dense in $L^2[a,b]$, it follows that $\{e_n\colon n \in \mathbb{Z}\}$ is dense in $L^2[a,b]$.

*Technically speaking, they're dense in the space of continuous functions normalized so that $f(a) = f(b) = 1$. However, this doesn't really matter as we can always look at $[a-\epsilon, b+\epsilon]$ instead.

-
Can someone verify (or argue against) my comment after the asterisk? It's late where I am, and I can never be 100% sure of myself at this hour... – Jesse Madnick Apr 26 '11 at 8:48
It's not the set of functions but the vector space generated by these functions, and after the asterisk the condition is just $f(a)=f(b)$. – Plop Apr 26 '11 at 9:48
Thanks Jesse. Where did you find these functions? – Josef K. Apr 26 '11 at 14:36
One needs to be slightly careful. Stone-Weierstrass Theorem gives that the trig polynomials are dense in $C[a,b]$ in the topology given by uniform convergence of functions, while $C[a,b]$ is dense in $L^2$ in the Hilbert space topology of $L^2$. So just this is not enough to guarantee that the trignometric polynomials are dense in $L^2$. This is the distinction I wrote about in my answer to another question. – Willie Wong Apr 26 '11 at 15:01
To complete the argument you need to use the fact that the uniform norm (or the $L^\infty$ norm) is stronger than the $L^2$ norm. More precisely, if a sequence of function on $[a,b]$ converges uniformly it will also converge in $L^2$ to the same limit. – Willie Wong Apr 26 '11 at 15:06

The sub-$\mathbb Q$-vector space generated by the characteristic functions of intervals with rational end-points is countable and dense.

-
Very good answer: simple, elegant and almost trivial after observing this fact in the first place. :-) (the upvote wasn't enough.) – Asaf Karagila Apr 26 '11 at 9:10
Thank you. Could you please explain a bit about the endpoints? In particular, if $a$ is irrational then any simple function $\phi$ will vanish at $a+\delta$, leaving a set of positive measure on which $|f-\phi|=|f|$. Now $\delta$ tends to zero, but why doesn't $f$ escape fast enough for convergence in $L^2$ to be avoided? – Josef K. Apr 26 '11 at 14:27
@Josef: I'm not sure I understand your question. The subspace Mariano describes approximates the space of all step functions since $\mathbb{Q}$ is dense in $\mathbb{R}$, and the step functions are dense in $L^2$ by the standard argument. – Qiaochu Yuan Apr 26 '11 at 14:42
@Qiaochu: I could rephrase my question as follows: given that $\mathbb Q$ is dense in $\mathbb R$, how do you conclude that the step (simple) functions with endpoints in $\mathbb Q$ are dense in the step functions with endpoints in $\mathbb R$. But I can see now that it may be so because - unlike my arbitrary function $f$ above, a step function in $\mathbb R$ cannot escape because it has finitely many values. (I hope this makes sense to someone other than me, but it makes me happy anyway ;) ) – Josef K. Apr 26 '11 at 15:12
The $L^2$ distance between the characteristic function of $[a,b]$ and $[p,q]$, where $p$ and $q$ are rational approximations for $a$ and $b$, is $\sqrt{|a-p|+|b-q|}$. Clearly you can make this arbitrarily small. – R.. Apr 26 '11 at 15:53