# Simple function approximation of a function in $L^p$

I know that, in general, that any function $f \in L^p(X,\mathcal{M},\mu)$ can be approximated arbitrarily well by a simple function $\sum_{k=1}^n \lambda_k \chi_{E_k}$ where $a_k \in \mathbb{C}, E_k \in \mathcal{M}$.

My question concerns the special case $X=[a,b]\subset \mathbb{R}$ equipped with the Borel $\sigma$-algebra and the Lebesgue measure. Is it then possible to approximate a function $f\in L^p([a,b])$ arbitrarily well with simple functions of the form $\sum_{k=1}^m \alpha_k \chi_{A_k}$ where each $A_k$ is an interval?

Yes, it is possible, if $p<\infty$. It should be evident that it is enough to show that you can approximate a simple function by step functions (i.e. simple functions made only with characteristic functions of disjoint intervals). In order to do this, it is enough to show that the characteristic of a measurable set of finite measure can be approximated by step functions. Take a measurable set $A$ with $\mu(A)<+\infty$; by regularity, we can find an open set $U\supset A$ such that $\mu(U\setminus A)<\epsilon$ and by a well known result in topology, $U$ can be written as a countable union of disjoint intervals: $$U=\bigcup_{n=0}^\infty I_n$$ so, we can find $N$ such that $$\mu\left(\bigcup_{n> N} I_n\right)<\epsilon\;.$$ Hence, we define $$h(x)=\sum_{n=0}^N\chi_{I_n}(x)$$ and we have $$\|h(x)-\chi_A(x)\|_p\leq(2\epsilon)^{1/p}\;.$$ So, the step functions are dense among the simple functions, which in turn are dense in $L^p$.
If $p=\infty$, the result no longer holds: take a measurable set $A$ such that $0<\mu(A\cap I)<\mu(I)$ for every interval $I$, then $\chi_A$ is at a positive distance from every step function.