if $f$ is Riemann integrable, then $f^2$ is Riemann integrable This was an exercise in my real analysis text and I was a bit confused by the proof. I found it a couple places online and it seems that in general the proof uses the fact that if f is bounded we have that $$|f(x)|\le B  $$ for all x $\in$ (a,b) $\rightarrow$
$$|f^2(x)-f^2(y)|=|f(x)-f(y)||f(x)+f(y)| \le 2B|f(x)-f(y)| $$
From this they deduce
$$RS^+(f^2,p)-RS^-(f^2,p) = \sum_{k=1}^n(f^2(M_k)-f^2(m_k))(x_k-x_{k-1})\le2B(f(M_k)-f(m_k))(x_k-x_{k-1})=2B(RS^+(f,p)-RS^-(f,p))$$
From this it's easy to finish the proof, but the argument up to this point doesn't make sense to me. How do we know that the max and min of $f^2$ is the same min and max that f has on a given interval? Can someone explain this argument to me more in depth? Thanks.
 A: Note that if $f$ is not continuous, then $f$ won't necessarily have a minimum or a maximum so you should talk about supremum and infimum. The relevant part that is missing in the proof is the following:
Let $f,g \colon [a,b] \rightarrow \mathbb{R}$ be bounded functions such that $|f(x) - f(y)| \leq |g(x) - g(y)|$. Then 
$$ \sup_{x \in [a,b]} f(x) - \inf_{x \in [a,b]} f(x) \leq \sup_{x \in [a,b]} g(x) - \inf_{x \in [a,b]} g(x). $$
To prove it, note that
$$ f(x) - f(y) \leq |g(x) - g(y)| = \max \{g(x),g(y) \} - \min \{g(x),g(y) \} \leq \sup_{x \in [a,b]} g(x) - \inf_{x \in [a,b]} g(x) $$
which implies that
$$ \sup_{x \in [a,b]} f(x) - \inf_{x \in [a,b]} f(x) = \sup \{ f(x) - f(y) \, | \, x, y \in [a,b] \} \leq \sup_{x \in [a,b]} g(x) - \inf_{x \in [a,b]} g(x). $$
A: If $f$ is bounded then $f^2$ is bounded. This should be clear.
Suppose $|f|$ is bounded by $M>0$. Notice that $|f(x)^2-f(y)^2|=|f(x)+f(y)||f(x)-f(y)|$. Consequently $U(f^2,P)-L(f^2,P) \leq 2M \left ( U(f,P)-L(f,P) \right )$. From here it is straightforward to get Riemann integrability of $f^2$.
The above argument can be dinectly adapted to show that if $f$ is Riemann integrable and $g$ is Lipschitz continuous on the range of $f$, then $g \circ f$ is Riemann integrable. I think a similar argument will show that if $g$ is uniformly continuous on the range of $f$ then $g \circ f$ is Riemann integrable, but in this case the details are somewhat more complicated. Note that it is not sufficient to merely assume $g$ is continuous on the range of $f$; for one thing, in this case $g \circ f$ may fail to be bounded.
