# Show that $f(x)=x$ if $x\in\mathbf{Q}$ and $f(x)=1-x$ if $x \in\mathbf{R}/\mathbf{Q}$ is Riemann integrable on $[0,1]$

Let $$f(x)=x$$ if $$x\in\mathbf{Q}$$ and $$f(x)=1-x$$ if $$x \in\mathbf{R}/\mathbf{Q}$$. Show that $$f$$ is Riemann integrable on $$[0,1]$$.

I know that there are a few posts on this function, but I didn't see the same approach as mine. So, I would like to know if my prove holds, please and have a feedback.

My attempt is to pass by Darboux upper and lower sums.

To show that $$f$$ is Riemann integrable, we have to show the following:$$\forall \epsilon>0$$ $$\exists$$ a partition $$\sigma$$: $$\overline{S}_{\sigma}(f)<\underline{S}_{\sigma}(f)+\epsilon$$.

First, consider the interval $$[0,\frac{1}{2}]$$. We know that $$\int_{0}^{1}f(x)=\int_{0}^{1/2}f(x)+\int_{1/2}^{1}f(x)$$. So, if one of the integrals is undefined, we could conclude that it is not integrable on the whole interval (*I'm not sure that is true. Should I show that the integral doesn't exist for both intervals, or one is sufficient?)

Let $$M_i=\sup\{f(x):x\in[x_i,x_{i+1}]\}$$ and $$m_i=\inf\{f(x):x\in[x_i,x_{i+1}]\}$$ (We work on $$[0,\frac{1}{2}]$$ now). We remark by density of $$\mathbf{Q}$$ and $$\mathbf{R}/\mathbf{Q}$$, that $$M_i=(1-x_i)$$ and $$m_i=x_i$$. Thus,

$$\overline{S}_{\sigma}(f)-\underline{S}_{\sigma}(f)=\sum_{i=0}^{n}(1-x_i)(x_{i+1}-x_i)-\sum_{i=0}^{n}x_i(x_{i+1}-x_i)$$.

But, $$\overline{S}_{\sigma}(f)\ge\int_{0}^{1/2}(1-x)\ dx$$ and $$\underline{S}_{\sigma}(f)\le \int_{0}^{1/2}x\ dx$$ whatever the partition. So, $$\overline{S}_{\sigma}(f)-\underline{S}_{\sigma}(f)\ge \int_{0}^{1/2}(1-x)\ dx - \int_{0}^{1/2}x\ dx=\frac{1}{4}$$.

Thus, there is no partition on the interval $$[0,\frac{1}{2}]$$ such that $$\overline{S}_{\sigma}(f)-\underline{S}_{\sigma}(f)<\epsilon$$ for $$0<\epsilon<\frac{1}{4}$$ and we conclude that $$f$$ is not integrable on $$[0,1/2]$$ and so on $$[0,1]$$ as well.

• The proof is good.
– RRL
Feb 26, 2021 at 21:31
• You seem to have learnt the technique from the answer by @RRL to one of your previous questions. +1 and I feel great about it. Feb 27, 2021 at 2:17
• Another note: why are your questions worded "show that something is integrable". They should have been "check whether something is integrable or not". Feb 27, 2021 at 2:19
• @Paramanand Singh Thank you for advice, I will do it next time! Feb 27, 2021 at 7:45

If $$f$$ is Riemann integrable on $$[a,b]$$, then for any $$\epsilon> 0$$ there is a partition $$P$$ of $$[a,b]$$ such that $$U(P,f) - L(P,f) < \epsilon$$.
Let $$P'$$ be the refinement of $$P$$ obtained by adding the point $$c \in (a,b)$$ if not already there. Otherwise let $$P' = P$$. Let $$P''$$ be the partition of $$[a,c]$$ induced by $$P'$$. It follows that
$$U(P'',f) - L(P'',f) \leqslant U(P',f) - L(P',f) \leqslant U(P,f) - L(P,f) < \epsilon,$$
and by the Riemann criterion $$f$$ must be Riemann integrable on $$[a,c]$$.