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.
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). $$