Let $f\in L^1(\mathbb{R})$. Prove that there is a sequence $g_n$ of step functions so that $$\lim_{n\to \infty}\int_{-\infty}^{\infty}|f(x)-g_n(x)|dx = 0$$
I was thinking of standard partition of the interval $[-n,n)$ into intervals of length $\frac{1}{n}$.
Let $$g_n(x) = \sum_{i=-n^2}^{n^2} f(i/n).1_{\{[\frac{i}{n},\frac{i+1}{n})\}}$$
Then:
$$\int_{-\infty}^{\infty}|f(x)-g_n(x)|dx = \int_{-\infty}^{-n}|f(x)|dx + \int_{-n}^{n}|f(x)-g_n(x)|dx + \int_{n}^{\infty}|f(x)|dx$$
Now $$\int_{-\infty}^{-n}|f(x)|dx < \epsilon, \int_{n}^{\infty}|f(x)|dx< \epsilon \text{ for large $n$ because f $\in L^1$}$$
How can I show that $$\int_{-n}^{n}|f(x)-g_n(x)|dx$$ can be controlled? Intuitively it is clear but formally I'm having trouble with this. Thanks.
HINT
We know that simple functions with compact support are dense in $L^1$
But you can approximate every simple function by step functions.
Use the following theorem:
Here $''\triangle''$ is $A \triangle B=(A \setminus B) \cup (B \setminus A)$
Use this theorem to approximate every function $1_A$(of the simple functions,which of course is a linear combination of these functions) where $A$ is measurable with finite measure,with step functions.
Then add all the step functions for every set to approximate the simple function.