If a function $f(x)$ is Riemann integrable on $[a,b]$ and $|f(x)| \le M$ for $x \in [a, b]$, show $|\int_a^b f(x)dx| \le M(b - a).$ I have that every Riemann sum $$S := |\sum_{i=1}^n f(t_i)(x_i - x_{i-1})| \le \sum_{i = 1}^n M(x_i - x_{i-1}) = M(b-a),$$ where $t_i$ is an arbitrary $x \in (x_{i-1}, x_i)$, and $x_1 \le ... \le x_n$ is a partitioning of $[a, b].$
I'm not sure how to extend that to $|\int_a^b f(x)| \le M(b-a).$
Does anyone have any pointers?
Thanks!
 A: For any partition $\mathcal{P} = \{a = t_0 < t_1 < \cdots < t_n = b\}$ of $[a,b]$ we know that 
$$
\int_a^b f \le U(f, \mathcal{P})
$$
where 
$$
U(f, \mathcal{P}) = \sum_{i=0}^n \sup_{[t_{i-1}, t_i]} f(x) (t_i - t_{i-1})
$$
is the upper Riemann sum of $f$ with the partition $\mathcal{P}$. Furthermore, as you state in your question, you know that 
$$
\left|U(f, \mathcal{P})\right| \le M(b-a).
$$
Can you see how to combine these facts to obtain the result?
A: Hint: If you think about it, this comes down to prove that $$\left|\int_a^b f(x) \mathrm{d}x\right|\leq \int_a^b |f(x)|\mathrm{d}x.$$

To help you, let us prove that $|f|:x\mapsto |f(x)|$ is integrable. Given a function $g:[a,b]\rightarrow \mathbb{R}$, we have that $g$ is integrable iff  $\forall \varepsilon > 0$, there exists a partition $\mathcal{P}_n=\{x_0,...,x_n\}\in[a,b], x_0 = a, x_n=b,$ such that
$$\sum_{i=1}^n \omega_i(g)(x_i-x_{i-1})<\varepsilon,$$
where $\omega_i(g) = \sup g([x_{i-1},x_i]) - \inf g([x_{i-1},x_i])= \sup\{|g(x)-g(y)|,x,y\in[x_{i-1},x_i]\}$.
Since $$||f(x)|-|f(y)||\leq |f(x)-f(y)|,$$
we can conclude that for every partition $\mathcal{P}_n$, $\omega_i(|f|)\leq\omega_i(f)$. Thus, $|f|$ is integrable.
Furthermore, $-|f(x)|\leq f(x)\leq |f(x)|$, and therefore
\begin{align}&&-\int_a^b |f(x)|\mathrm{d}x\leq \int_a^b f(x)\mathrm{d}x\leq \int_a^b |f(x)|\mathrm{d}x&\\
\Leftrightarrow &&\left|\int_a^b f(x)\mathrm{d}x\right|\leq \int_a^b |f(x)|\mathrm{d}x.&\end{align}
