If a function $h(x)$ satisfies:
exists partition $ P=\left\{ a_{0},a_{1},...,a_{n}\right\} $
of the interval [a,b], such that $ h $ is constant in the segment $(a_{k-1},a_{k}) $ for any $1\leq k\leq n $ then we call $h(x) $ a step function.
Let $ f(x) $ be integrable function in the interval [a,b] and let $ \varepsilon>0 $. prove that exists step function $ h $ that satisfies
$ \intop_{a}^{b}|f\left(x\right)-h\left(x\right)|dx<\varepsilon $
This is actually a part from a bigger proof. Im trying to prove that for any integrable function $ f $ in an interval $[a,b]$, for any $\varepsilon>0 $ exists continious function $g(x) $ such
$ \intop_{a}^{b}|f\left(x\right)-g\left(x\right)|dx<\varepsilon $
So, part 1 of the proof is to prove the thing I mentioned. and part 2 is to prove that for any step function $h(x)$ in the interval $[a,b]$, and for any $ \varepsilon>0 $ exists continious function $g(x)$ in the interval $[a,b]$ that satisfies
$ \intop_{a}^{b}|h\left(x\right)-g\left(x\right)|dx<\varepsilon $
I already proved that any step function in any interval $[a,b] $ is integrable. Im not sure how to prove the parts I mentioned. Thanks in advance.
If $f$ is Riemann integrable, then for any $\epsilon > 0$ there exists $P: a = x_0 < x_1< \ldots x_n = b$, a partition of $[a,b]$, such that
$$\tag{*}0 \leqslant \int_a^b f(x) \, dx - L(P,f) = \int_a^b f(x) \, dx - \sum_{j=1}^n m_j(x_j - x_{j-1}) < \epsilon,$$
where $m_j = \inf \{f(x): x_{j-1} \leqslant x \leqslant x_j\}$. Here, of course, $L(P,f)$ denotes the lower Darboux sum.
Define the function
$$h(x) = \begin{cases}m_j ,& x_{j-1} \leqslant x < x_j \,\, (j = 1, \ldots, n)\\ m_n, & x= x_n \end{cases}$$
Clearly, $h$ is a step function since it assumes constant values on disjoint intervals. Furthermore, we have
$$\int_{x_{j-1}}^{x_j} h(x) \, dx = m_j(x_j - x_{j-1})$$
since the value of $h(x)$ at $x = x_j$ is irrelevant in computing the integral.
Thus,
$$\int_a^b f(x) \, dx - \sum_{j=1}^n m_j(x_j - x_{j-1}) = \int_a^b f(x) \, dx -\int_a^b h(x) \, dx = \int_a^b (f(x) - h(x)) \, dx $$
We also have $f(x) \geqslant h(x)$ for all $x \in [a,b]$ and it follows that $f(x) - h(x) = |f(x) - h(x)|$. Substituting into (*), we get
$$\int_a^b|f(x) - h(x)| \, dx < \epsilon$$