Given $$ f(x) = \begin{cases} x, & \text{when x is rational} \\ -x, & \text{when x is not rational} \end{cases} $$ Show that $f$ is not Riemann-integrable over $[a,b]$, but $|f|$ is.
How to go about this problem? I started by taking a partition $P$ with each interval of equal length say $k$. Now clearly $U(P,f)$ is not equal to $L(P,f)$ and hence the limits. Is this approach fair?
HINT. $\mathbb{Q}$ is dense in $\mathbb{R}$. So given an interval in the partition, what is its sup and inf over that interval? So what happens when you shrink down the intervals, taking the sum over all the intervals in your partition? Do the largest and smallest possible Riemann sums converge to each other?
For the second part, rewrite $f(x)$ using the definition of $f$ and the definition of $|\cdot|$. It should be clear what function you get and why it is integrable.