How to approximate simple function using step function? I'm learning Lebesgue integral, where I came to such problem.
Suppose $\varphi$ is a simple function defined on $E$. For each $\varepsilon$, is there a step function $\psi$ approximate to $\varphi$ in the sense that
$|\psi-\varphi|<\varepsilon$ on $E$
or
$\int_E |\psi-\varphi|<\varepsilon$.
Can anyone help me?
 A: Theorem: Let $(X,\mathcal{A},\mu)$ be a measure space and $f:X \to [0,\infty]$ be a $\mu$-measurable function. Then there exists a sequence of measurable simple functions $\varphi_n:X\to [0,\infty)$ such that $$0\leq \varphi_n(x) \leq \varphi_{n+1} (x) \leq f(x) $$
for all $n\in\mathbb{N}, x\in X,$ and $\varphi_n(x)\to f(x)$ for all $x\in X.$
Proof: For every $n\in\mathbb{N}$ divide $(0,\infty]$ into $(0,n] $ and $[n,\infty].$ Now partition $(0,n]$ into dyadic intervals $$\displaystyle I_{n,k} = \left(\frac{k}{2^n},\frac{k+1}{2^n}\right],  \ \ \  k=0,1,2,\cdots, n2^n-1. $$
Consider the preimages: $$A_{n,k} = f^{-1}(I_{n,k})= \{x\in X \ \ \big| \ \frac{k}{2^n} < f(x)\leq \frac{k+1}{2^n} \},\ \ \ \ k=0,1,2,\cdots, n2^n-1 $$
and $$A_{n,n2^n} = f^{-1}( (n,\infty]) = \{ x\in X \ \ \big| \ \ f(x)>n \} .$$
Since $f$ is measurable $A_{n,k} \in \mathcal{A}.$ Set $$ \varphi_n = \sum_{k=0}^{n2^n} \frac{k}{2^n} \mathcal{X}_{A_{n,k}}$$
which defines a $\mu$-measurable function on $X.$
The values of $f$ can be split into three cases to consider:


*

*$f(x)=0.$ Then $x\notin A_{n,k}$ for any $n\in \mathbb{N}$ and $k=0,1,2,\cdots, n2^n.$ Hence $0= \varphi_n(x) = f(x)$ for all $n\in \mathbb{N}.$ 

*$0<f(x)<\infty.$ Then for sufficiently large $n$ we have $0 < f(x) \leq n.$ Hence for each such $n$ there exists $k=0,1,2,\cdots,n2^n$ with $$\varphi_n(x)= \frac{k}{2^n} < f(x) \leq \frac{k+1}{2^n}.$$
In particular $0\leq \varphi_n(x)\leq f(x)$ and $0<f(x)-\varphi_n(x)\leq \frac{1}{2^n}.$ Hence $\varphi_n(x)\to f(x)$ as $n\to\infty.$

*$f(x)=\infty.$ Then $x\in A_{n,n2^n}$ for all $n\in \mathbb{N}$ so $$\varphi_n(x)=n<f(x)=\infty$$ for all $n\in \mathbb{N}.$ Hence $\varphi_n(x)\to \infty=f(x).$


Thus we have shown that $0\leq \varphi_n(x)\leq f(x)$ for all $n\in\mathbb{N}, x\in X,$ and $\varphi_n \to f$ pointwise. 
Now note $$ \frac{k}{2^n} = \frac{2k}{2^{n+1}} < \frac{2k+1}{2^{n+1}} < \frac{2k+2}{2^{n+1}} = \frac{k+1}{2^n}. $$
Hence $A_{n,k} = A_{n+1,2k} \bigcup A_{n+1,2k+1}$ is a disjoint union and therefore $\varphi_n(x) \leq \varphi_{n+1}(x)$ for all $x\in X. \\ \\ \square $ 
Remarks: 


*

*If $f$ is bounded then the above proof shows $\varphi_n \to f$ uniformly on $X$, not just pointwise. 

*If $f:X\to \mathbb{R}$ we can apply the theorem to the positive and negative parts of $f$ and get a sequence of simple functions $\phi_n:X\to \mathbb{R}$ with $\phi_n\to f$ pointwise and $$0\leq | \phi_n(x)| \leq | \phi_{n+1} (x) | \leq |f(x)| $$ for all $n\in \mathbb{N}, x\in X.$

