Here is Prob. 5, Chap. 6, in the book Principles of Mathematical Analysis by Walter Rudin, 3rd edition:
Suppose $f$ is a bounded real function on $[a, b]$, and $f^2 \in \mathscr{R}$ on $[a, b]$. Does it follow that $f \in \mathscr{R}$? Does the answer change if we assume that $f^3 \in \mathscr{R}$?
My Attempt:
The Riemann-integrability of $f^2$ need not imply the integrability of $f$. For example, let $f$ be defined on $\mathbb{R}$ by $$ f(x) \colon= \begin{cases} 1 \qquad & \mbox{ if } x \in \mathbb{Q}, \\ -1 \qquad & \mbox{ if } x \not\in \mathbb{Q}. \end{cases} $$ Then $f^2(x) = 1$ for all $x \in \mathbb{R}$, and so $$ \int_{-r}^{+r} f(x) \ \mathrm{d} x = 2r $$ for any real number $r > 0$.
However, this function $f$ is not integrable on $[a, b]$, where $a$ and $b$ are real numbers such that $a < b$. The details are as follows:
If $P$ be any partition of $[a, b]$, then we have $$ L(P, f) = -(b-a), \ \mbox{ and } \ U(P, f) = b-a, $$ and so $$ U(P, f) - L(P, f) = 2(b-a) > \varepsilon $$ for any real number $\varepsilon$ such that $0 < \varepsilon < 2(b-a)$, and thus the condition of Theorem 6.6 in Baby Rudin is violated.
Is what I've stated above correct? If so, then is my counter-example the right one? And, have I managed to present this argument correctly as well?
On the other hand, if $f^3$ is integrable on $[a, b]$, then so is $f$.
Am I right?
The proof is as follows:
As $f$ is a bounded real function on $[a, b]$, so the supremum and infimum of the range of $f$ exist in $\mathbb{R}$. Let us put $$ M \colon= \sup \left\{ \ f(x) \ \colon \ a \leq x \leq b \ \right\}, \ \mbox{ and } \ m \colon= \inf \left\{ \ f(x) \ \colon \ a \leq x \leq b \ \right\}. $$
Since the function $t \mapsto t^3$ is a continuous one-to-one mapping of $\mathbb{R}$ onto $\mathbb{R}$, therefore it is also a continuous one-to-one mapping of any finite interval $[c, d ]$ onto the interval $\left[c^3, d^3 \right]$. Moreover, the interval $[ c, d ]$ is compact. So by Theorem 4.17 in Baby Rudin, the function $t \mapsto t^{1/3}$ is a continuous (one-to-one) mapping of $[c^3, d^3 ]$ onto $[c , d ]$.
Now as $f^3 \in \mathscr{R}$ on $[a, b]$, $m^3 \leq f^3 \leq M^3$ on $[a, b]$, and the map $\phi$ defined on $\left[m^3, M^3 \right]$ by $\phi(t) = t^{1/3}$ is continuous, so by Theorem 6.11 in Baby Rudin the function $h = \phi \circ f^3 $ is also integrable on $[a, b]$.
Is my reasoning in this proof correct? If so, then have I presented this proof correctly and lucidly enough too?