# $f$ integrable iff set of discontinuities have measure $0$. But why is $\chi_\mathbb{Q}$ not integrable?

I have a theorem stating that if $$f:[a,b] \rightarrow \mathbb{R}$$ is bounded, then $$f$$ is Riemann integrable if and only if the set of discontinuities of $$f$$ has measure 0. Using this you can prove that the Thomae function is Riemann integrable. However I'm confused about this function:

$$f(x)=\begin{cases}1 & \text{ if x is rational } \\ 0 & \text{ if x is irrational} \end{cases}$$

I know that this function is in theory not integrable on $$[0,1]$$; however, isn't its set of discontinuities $$\mathbb{Q} \cap [0,1]$$, which have measure $$0$$? I'm very confused because the theorem seems to tell me that this function is integrable, while the argument with lower and upper sums of partitions clearly states that it is not. I hope someone can resolve my confusion.

• It’s discontinuous everywhere. Dec 22, 2022 at 20:20

The function is discontinuous everywhere, because of the density of the rationals and irrationals within $$\mathbb{R}$$.

Take $$q \in \mathbb{Q}$$ and $$\varepsilon > 0$$. If $$f$$ were continuous at $$q$$, then we could find $$\delta > 0$$ such that $$0 < |x-q| < \delta \implies |f(x)-f(q)|=|f(x)-1|<\varepsilon$$ However, for $$\varepsilon = 1/2$$ and any $$\delta > 0$$, we have infinitely many irrationals in $$(q-\delta,q+\delta)$$, at which $$f$$ is $$0$$, and so $$|f(x)-f(q)|=1 \not < 1/2$$.

Hence, $$f$$ is discontinuous on the rationals.

A parallel argument follows for the irrationals. Take $$r \in \mathbb{R} \setminus \mathbb{Q}$$. Then $$\forall \delta > 0$$, we can find $$x$$ such that $$0 < |x-r| < \delta \text{ but } | f(x) - f(r) | = |f(x)| < \frac 1 2$$ Namely, this occurs when $$x \in \mathbb{Q}$$; the density of $$\mathbb{Q}$$ ensures that $$(r-\delta,r+\delta)$$ has infinitely many rationals for any $$\delta > 0$$.

Hence, $$f$$ is discontinuous on the irrationals too.

It's easy to think of "well, this function is zero everywhere, except where it jumps up at the irrationals" and go "well, it's discontinuous on a set of measure zero."

However, I think the key realization is that it "jumps up and down" far too often. In any interval, you can think of the function as oscillating up and down infinitely many times (though in a discontinuous way, unlike $$\sin(1/x)$$ as an example).

Alternatively, the realization is simply that just because $$f=g$$ a.e., doesn't mean that the points of (dis)continuity of $$f$$ or $$g$$ have no effect. The nature of those points matters too. After all,

• $$f := \chi_{\mathbb{Z}}$$ has (countably) infinitely-many discontinuities, but integrating it is totally fine, because the integers are sufficiently spread apart
• $$f := \chi_{\mathbb{Q}}$$ has (countably) infinitely-many discontinuities, but integrating it (in the Riemann sense) is not fine, since it is discontinuous everywhere

...and so on.

• Thanks for your comment this makes a lot of sense! So now thinking about the thomae function. The proof that its integrable is to show that there are finitely many $x\in [0,1]$ such that $|x-x_0|<\delta$ but $f(x)-f(x_0)>\epsilon$? So basically the set of discontinuities is finite?
– Goob
Dec 22, 2022 at 20:26
• The set of discontinuities for Thomae's function is $\mathbb{Q}$ (or its intersection with $[0,1]$ if you're viewing it in that sense). Hence the discontinuities are infinite in number, but still of measure zero. Wikipedia has a proof. Dec 22, 2022 at 20:34