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

Solution 1:

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

Solution 2:

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.

Solution 3:

The set of continuous functions $C^0$ forms a dense subset of $L^2$ (Principles of Mathematical Analysis. W.Rudin. Theorem 10.38), the set of all polynomials with rational coefficients is clearly a countable set contained in $C^0$ and so it is a dense subset of $L^2$.