Approximating Riemann integrable functions Here's a problem I encountered: Suppose $f$ is Riemann integrable (and so must be bounded) on the interval $[a,b]$. Show that given $\epsilon > 0$, there exist continuous functions $g,h$ such that $g(x) \leq f(x) \leq h(x)$ for all $x$, and $\int_a^b |g(x) - h(x)|\  dx < \epsilon$
Now my thought was to attempt was to prove something slightly stronger. Of course the following holds: $$\int_a^b |g(x) - h(x)| dx \leq \int_a^b |f(x) - g(x) | + |g(x) - h(x)|\  dx$$by triangle inequality. Then since $\epsilon$ is arbitrary, I've reduced the problem to just dealing with approximation from above or below.
Now I wanted to use a particular trick I'd seen before, since I know that Riemann integrable functions can be approximated by Lipschitz functions, which are of course continuous, the problem is that this approximation is not necessarily strictly from above or below. The proof is basically to take a sufficiently fine partition so that the Riemann sums $U(P,f) - L(P,f) < \epsilon$, and then interpolate linearly between the points of the partition. Taking the maximum of the slopes and using the triangle inequality allows you to conclude this piecewise linear guy is actually Lipschitz.
Of course this strategy won't work here though, because there's nothing that says the function can't cross over these lines frequently. In fact, that kind of wild behavior can even happen for $C^1$ functions. So I've run into trouble.
I still think that the original idea is right - if I can approximate from above, whatever scheme I use should work from below too. I'm just having a hard time figuring out how.
 A: Your idea is correct and you need to make use of step functions. Prove the following theorem:

Theorem: If $g$ is step function on $[a, b]$ (which is continuous from at least one side at each point) and $\epsilon >0$ then there is a continuous function $f$ on $[a, b] $ such that $g-f$ is non-negative and $\int_{a} ^{b} (g(x) - f(x)) \, dx<\epsilon$.

This is easily handled by assuming that $g$ has only one discontinuity in interval $[a, b]$ (this does not lead to any loss of generality). We can just use a slanted line segment to join two disconnected parts in the graph of $g$ keeping the line segment below the graph. The slope of the slanting line segment can be made as steep as necessary so that the area of the triangle involved is less than $\epsilon $ and we are done.
And using this we easily prove your result in question. Let $f$ be Riemann integrable on $[a, b] $ with integral $I$. Then for any $\epsilon>0$ we have a partition $P$ of $[a, b] $ with lower sum $L(f, P) $ such that $$0\leq I-L(f,P) <\frac{\epsilon} {2} $$ Since $L(f, P) =\sum_{k=1}^{n}m_{k}(x_{k}-x_{k-1})$ where $P=\{x_{0}=a,x_{1},\dots, x_{n} =b\} $ and $m_{k} =\inf\, \{f(x) \mid x\in[x_{k-1},x_{k}]\}$ we can define a step function $g$ on $[a, b] $ such that $g(x) =m_{k} $ for $x\in (x_{k-1},x_{k})$. For the values of $g$ at points of partition we choose $g(a) =m_{0},g(b)=m_n$ and $g(x_{k}) =\min(m_{k}, m_{k+1})$ for $k=1,2,\dots,n-1$. Then $\int_{a}^{b} g(x) \, dx=L(f, P) $ and we have $f-g$ being non-negative and $$0\leq \int_{a} ^{b} (f(x) - g(x)) \, dx<\frac{\epsilon} {2}$$ Next by the theorem mentioned above we can choose a continuous function $h$ on $[a, b] $ such that $g-h$ is non-negative and $$0\leq \int_{a} ^{b} (g(x) - h(x)) \, dx<\frac{\epsilon} {2}$$ Thus we get a continuous function $h$ such that $f-h$ is non-negative and $$0\leq \int_{a}^{b}(f(x)-h(x))\,dx<\epsilon $$ You can observe that the idea of lower sums works for any bounded function and the lower sums converge to  lower Darboux integral of the function. Thus the above procedure gives an approximation for any arbitrary bounded function via continuous functions from below. 
