# Prove that $f$ defined by $f(x)=1$ if $x \in \mathbb{Q}$, $f(x)=0$ if $x \in \mathbb{R}\setminus \mathbb{Q}$, is not integrable

Prove that

$$f\left ( x \right )= \begin{cases} 1 & x \in \mathbb{Q}, \\ 0 & x\in \mathbb{R}\setminus \mathbb{Q}. \end{cases}$$

is not integrable.

I came across this. I think that the function itself is not continuous? But I do not think that is a legitimate answer to this question.

• I guess you mean Riemann integrability, for otherwise it is Lebesgue integrable. For the proof, notice that on every interval $I$ of positive length the supremum of $f$ over $I$ is 1 and the infimum of $f$ over $I$ is 0. From this you can check that the upper Riemann integral does not equal the lower Riemann integral – Sangchul Lee Jan 15 '17 at 11:49
• Is is possible to clarify "supremum" and "infimum"? – Huzo Jan 15 '17 at 11:53
• I mean $\sup_I f = \sup\{f(x) : x \in I \}$ and $\inf_I f = \inf\{f(x) : x \in I \}$. – Sangchul Lee Jan 15 '17 at 11:54
• Possible duplicate of Is Dirichlet function Riemann integrable? – Alex M. Jan 15 '17 at 13:40

Let $$S(f,P)$$ and $$s(f,P)$$ be the upper and low sums of $$f$$ with respect to partition $$P$$ of interval $$[0,1]$$. Let $$M_i=\sup\{f(x)| x \in I_i\}$$ and $$m_i=\inf\{f(x)| x \in I_i\}$$, where $$I_i$$ is the $$i$$th interval of the partition $$P$$. Note that $$M_i=1$$ for all $$i$$, because every interval $$I_i$$ of the partition $$P$$ contains rational numbers. On the other hand, $$m_i=0$$ for all $$i$$ because every interval $$I_i$$ of the partition $$P$$ contains irrational numbers. By definition, $$S(f,P)=\sum_{i=1}^nM_i\mu(I_i)=\sum_{i=1}^n1\mu(I_i)=\sum_{i=1}^n\mu(I_i)=1-0=1$$ $$s(f,P)=\sum_{i=1}^nm_i\mu(I_i)=\sum_{i=1}^n0\mu(I_i)=0$$ Thus, $$f$$ is not Riemann integrable because the upper and lower integrals are not equal. (The upper integral is the limit of the upper sums and the lower integral is the limit of the lower sums).

• Your proof is for $[0,1]$, but the OP's function is defined on $\Bbb R$, which complicates things. – Alex M. Jan 15 '17 at 13:21
• No, $f:\mathbb{R} \to \mathbb{R}$ if the function is not integrable in $[0,1]$ then she in not integrable in $\mathbb{R}$, because if $f$ were integrable in $\mathbb{R}$ so $f$ it would be integrable in any interval $I$ of $\mathbb{R}$. – Cgomes Jan 15 '17 at 14:29
• This is not true: there is absolutely no concept of Riemann integrability on unbounded intervals. There is, though, the concept of improper Riemann integral (of the first type, in this case), but this complicates the proof. – Alex M. Jan 15 '17 at 14:49

The peculiarity of this function is that it has an infinite number of discontinuities in any finite interval over which it is Riemann-integrated.

Here, the upper and lower Riemann sums do not coincide. Hence it is not Riemann integrable. But it is Lebesgue integrable.

For further reading, you may check this.

• No, this answer is mistaken: a function may very well have infinitely many discontinuities in any subinterval of its domain of definition, and still be Riemann-integrable; the only condition is that the set of discontinuitites should have Lebesgue measure $0$. – Alex M. Jan 15 '17 at 13:06
• @AlexM. Well I didn't know about this. Thanks for telling me. But in the link you provided, I found this line : " thus a bounded function (on a compact interval) with only finitely or countably many discontinuities is Riemann integrable." This clearly states what I have written. Please check the link. And tell me what you think of it. – SchrodingersCat Jan 15 '17 at 13:10
• @SchrodingersCat: "This clearly states what I have written." How? You have written that $f$ is not integrable, while your quote gives sufficient condition for a function to be integrable. – Alex M. Jan 15 '17 at 13:14
• @SchrodingersCat: You should prove first that the discontinuities of $f$ are uncountable; only then will you be able to use Lebesgue's theorem. – Alex M. Jan 15 '17 at 13:24
• This answer argues that the (true) fact that "a bounded function (on a compact interval) with only finitely or countably many discontinuities is Riemann integrable" implies that any bounded function (on a compact interval) with uncountably many discontinuities is not Riemann integrable... and six users agree? Every cat is mortal. I am mortal (I think). Hence I am a cat? Cool... – Did Jan 15 '17 at 14:23

An important remark: since the function $$f(x) = \begin{cases} 1 & x \in \mathbb{Q} \\ 0 & x \in \mathbb{R} \setminus \mathbb{Q} \end{cases}$$ is clearly Lebesgue-integrable (being equal to $$0$$ almost everywhere), you are probably asking about Riemann integrability. In this case, though, you have a problem: the concept of Riemann integrability is defined only for functions defined on bounded intervals, and $$f$$ is defined on $$\Bbb R$$. I believe that what you meant to ask about is the following slightly modified function: $$g(x) = \begin{cases} 1 & x \in [a,b] \cap \mathbb{Q} \\ 0 & x \in [a,b] \setminus \mathbb{Q} \end{cases}$$. In this case, an answer can be given using Lebesgue's criterion of Riemann integrability: a bounded $$f$$ is Riemann-integrable on $$[a,b]$$ if and only if the set of discontinuities of $$f$$ has Lebesgue measure $$0$$.

Let $$x \in [a,b] \cap \Bbb Q$$. Then $$f(x)=1$$. Pick a sequence of irrational numbers $$(x_n)_{n\in\Bbb N}$$ with $$x_n \to x$$. Then $$f(x_n)=0 \not\to 1=f(x)$$, so $$f$$ is not continuous in $$x$$.

Let $$x \in [a,b] \setminus \Bbb Q$$. Then $$f(x)=0$$. Pick a sequence of rational numbers $$(x_n)_{n\in\Bbb N}$$ with $$x_n \to x$$. Then $$f(x_n)=1 \not\to 0=f(x)$$, so $$f$$ is not continuous in $$x$$.

The above argument shows that $$f$$ is discontinuous in all the points of $$[a,b]$$, which is a set of Lebesgue measure $$b-a \ne 0$$, therefore Lebesgue's criterion tells us that $$f$$ is not Riemann-integrable on $$[a,b]$$.