Is Dirichlet function Riemann integrable?

The Dirichlet function $f$ isn't continuous anywhere. For every irrational number $x$, there is a sequence of rational numbers $\{r_n\}$ that converges to it. We have: $$ \lim_{n\to\infty} f(r_n) = 1 \ne 0 = f(x) $$

Thus, $f$ isn't continuous at irrational numbers. Rational numbers can be handled similarly.


The Dirichlet function is nowhere continuous, since the irrational numbers and the rational numbers are both dense in every interval $[a,b]$. On every interval the supremum of $f$ is $1$ and the infimum is $0$ therefore it is not Riemann integrable.


There are two different definitions of the Dirichlet function:

$$ D(x) = \begin{cases}1:& x\in\mathbb Q \\ 0:&x\in\mathbb R\setminus\mathbb Q\end{cases}$$

which is obviously nowhere continuous. And then there is the "reduced" version, also known as Thomae's function

$$ D(x) = \begin{cases} \frac{1}{b}:& x=\frac{a}{b}\in\mathbb Q \quad\text{is a reduced fraction} \\ 0:&x\in\mathbb R\setminus\mathbb Q\end{cases}$$

enter image description here

which turns out to be continuous at the irrationals, since any approximation of an irrational number by rationals forces the denominator to become large. It can be shown that the former is not Riemann integrable whereas the latter is and its integral vanishes.