How do I show that if $f$ is Riemann int., then for each $\epsilon$ there exists a step function, $g(x)$, s.t. $\int |f(x)-g(x)| \ dx < \epsilon$? 
How do I show that if $f$ is Riemann integrable, then for each $\epsilon>0$ there exists a step function such that $\int |f(x)-g(x)| \ dx < \epsilon$?

I know that if $f$ is Riemann integrable, then the infimum of the upper Riemann sums minus the supremum of the lower Riemann sums is less than $\epsilon$ which implies that they are equal and this value is the integral $\int_a^b f(x) \ dx$.
 A: Given $\epsilon>0$, choose a partition $P=\{a=x_{0}<\cdots<x_{n}=b\}$ such that $U(f,P)-L(f,P)<\epsilon$.
Let $c_{i}=\inf_{x\in[x_{i},x_{i+1}]}f(x)$, $i=0,...,n-1$. Set $g=\displaystyle\sum_{i=0}^{n-1}c_{i}\chi_{[x_{i},x_{i+1})}$, then 
\begin{align*}
\int_{a}^{b}|f(x)-g(x)|dx&=\sum_{i=0}^{n-1}\int_{x_{i}}^{x_{i+1}}|f(x)-c_{i}|dx\\
&=\sum_{i=0}^{n-1}\int_{x_{i}}^{x_{i+1}}(f(x)-c_{i})dx\\
&\leq\sum_{i=0}^{n-1}\int_{x_{i}}^{x_{i+1}}\left(\sup_{x\in[x_{i},x_{i+1}]}f(x)-c_{i}\right)\\
&=\sum_{i=0}^{n-1}\left(\sup_{x\in[x_{i},x_{i+1}]}f(x)-\inf_{x\in[x_{i},x_{i+1}]}f(x)\right)(x_{i+1}-x_{i})\\
&=U(f,P)-L(f,P)\\
&<\epsilon.
\end{align*}
A: The following argument is for the existence of a continuous function which can approximate $f$ in the $L^{1}$ sense.
I will continue the notations used in the first argument.
Let $d_{i}=\sup_{x\in[x_{i},x_{i+1}]}f(x)$, $i=0,...,n-1$. Choose $\delta>0$ small enough such that $\delta<\dfrac{1}{3}(x_{i+1}-x_{i})$ and define $L_{i}$ the spline joining the points $(x_{i+1}-\delta,c_{i})$ and $(x_{i+1}+\delta,c_{i})$, so
\begin{align*}
L_{i}(x)=\dfrac{c_{i+1}-c_{i}}{2\delta}(x-(x_{i+1}+\delta))+c_{i+1},
\end{align*}
for $i=0,...,n-1$.
We let 
\begin{align*}
h&=c_{0}\chi_{[x_{0},x_{1}-\delta)}+L_{0}\chi_{[x_{1}-\delta,x_{1}+\delta)}+c_{1}\chi_{[x_{1}+\delta,x_{2}-\delta)}+L_{1}\chi_{[x_{2}-\delta,x_{2}+\delta)}\\
&~~~~+\cdots+L_{n-1}\chi_{[x_{n-1}-\delta,x_{n-1}+\delta)}+c_{n-1}\chi_{[x_{n-1}+\delta,x_{n}]}.
\end{align*}
Then $h$ is continuous and 
\begin{align*}
\int_{a}^{b}|h(x)-g(x)|dx&=\sum_{i=0}^{n-1}\left(\int_{x_{i+1}-\delta}^{x_{i}}|L_{i-1}(x)-c_{i-1}|dx+\int_{x_{i+1}}^{x_{i+1}+\delta}|L_{i}(x)-c_{i+1}|dx\right)\\
&=\sum_{i=0}^{n-1}\left(\dfrac{\delta}{2}|L_{i}(x_{i+1})-c_{i}|+\dfrac{\delta}{2}|L_{i}(x_{i+1})-c_{i+1}|\right)\\
&\leq\dfrac{\delta}{2}\sum_{i=0}^{n-1}[(d_{i}-c_{i})+(d_{i+1}-c_{i+1})]\\
&\leq\delta\sum_{i=0}^{n-1}(d_{i}-c_{i})\\
&<\dfrac{1}{3}\sum_{i=0}^{n-1}(d_{i}-c_{i})(x_{i+1}-x_{i})\\
&=\dfrac{1}{3}(U(f,P)-L(f,P))\\
&<\dfrac{\epsilon}{3},
\end{align*}
so
\begin{align*}
\int_{a}^{b}|f(x)-h(x)|dx&\leq\int_{a}^{b}|f(x)-g(x)|dx+\int_{a}^{b}|g(x)-h(x)|dx\\
&<\epsilon+\dfrac{\epsilon}{3}\\
&=\dfrac{4}{3}\epsilon.
\end{align*}
