Continuous functions on $[0,1]$ is dense in $L^p[0,1]$ for $1\leq p< \infty$

Let $f\in\mathbb L^p$ and $\varepsilon\gt 0$. Choose $N$ such that $\left\lVert f-f\mathbf 1_{-N\leqslant f\leqslant N}\right\rVert_p\leqslant \varepsilon/2$. Let $f_N:=f\mathbf 1_{-N\leqslant f\leqslant N}$.

  • Lusin's theorem gives a closed set $F$ such that $[0,1]\setminus F$ has measure smaller than $2^{-p} \varepsilon^p/\left(2N\right)^p$, and $f_N$ restricted to $F$ is continuous.

  • Tietze extension theorem applied to $f_N$ and $F$ gives that the extension $g$ is still bounded by $N$.

    Consequently, $$\left\lVert f_N-g\right\rVert_p^p=\int_{[0,1]\setminus F} \left\lvert f_N-g\right\rvert_p^p\leqslant (2N)^p\lambda\left([0,1]\setminus F\right)\leqslant 2^{-p}\varepsilon^{-p}. $$ We thus got a continuous function $g$ such that $$\left\lVert f-g\right\rVert_p\leqslant \varepsilon,$$ which show that the set of continuous functions is dense in $\mathbb L^p$.


Since $L_p([0,1])=\mathrm{cl}(\mathrm{span}\{\chi_E:E\in\mathfrak{M}([0,1])\})$, it is enough to prove that $$ \forall\varepsilon>0\quad\forall E\in\mathfrak{M}([0,1])\quad\exists f\in C([0,1])\quad \Vert f-\chi_E\Vert<\varepsilon $$ Indeed, by regularity of the Lebesgue measure there exists a closed set $F$ and an open set $U$ such that, $F\subset E\subset U$ with $\mu(U\setminus F)<\varepsilon$. The desired $f\in C([0,1])$ is $$ f(t)=\frac{d(t, [0,1]\setminus U)}{d(t, [0,1]\setminus U)+d(t,F)} $$ where $d(t, S)=\inf\{|t-s|:s\in S\}$ is the distance function.


Fix $p\text{ , and }1\leq p\lt \infty.$

By using Lusin's theorem, for any $f \in L^p[0,1]$, for any given $ \epsilon $ $ > $ 0, there exists a closed set $ F_\epsilon $ such that $ m([0,1]- F_\epsilon) < \epsilon$ and $f$ restricted to $F_\epsilon$ is continuous.

Using Tietze's extension theorem, extend $f$ to a continuous function $g$ on $[0,1]$.

Note that $f\equiv g$ on $F_\epsilon$, so we only need to take care of the integral on $[0,1]- F_\epsilon$.

Continuous function is always integrable on $[0,1]$, so $g^p$ is integrable on $[0,1]$.

Since $|f(x)-g(x)|^p \leq 2^p (|f(x)|^p + |g(x)|^p)$ and $f \in L^p[0,1],$

we know $\int_{[0,1]}|f(x)-g(x)|^p \lt \infty, i.e. |f(x)-g(x)|^p$ is integrable on $[0,1].$

By the proposition I post, $ \int_{[0,1]-F_\epsilon}|f(x)-g(x)|^p \to 0 $ when $m([0,1]- F_\epsilon)\to 0.$

Note that $\epsilon \to 0 \Rightarrow m([0,1]- F_\epsilon)\to 0$ (Since $m([0,1]- F_\epsilon \lt \epsilon$)

For each $\epsilon \gt 0$, we can find a corresponding continuous function $g_\epsilon, $ and $\Vert f-g_\epsilon \Vert \to 0$ when $\epsilon \to 0$.

So, $C([0,1])$ is dense in $L^p[0,1]$.

Reference: The proposition is from the Real Analysis,4th Ed, written by Royden and Fitzpatrick.

enter image description here