I am working on the following exercise for practice:
Show that the Riemann integral $\int_0^1 f(x) dx = 0$, where $$f(x) = \begin{cases} 1 & \exists n \in \mathbb{N}, x=\frac{1}{n} \\ 0 & \text{otherwise} \end{cases}$$ (Wilcox & Meyers, "An Introduction to Lebesgue Measure and Fourier Series", Problem 5.6)
Basic Approach
Using the definition of the Riemann integral, I need to show that $\lim_{||P|| \rightarrow 0} R(f,P) = 0$, i.e.
$$ \forall\, \varepsilon > 0, \exists\, \delta > 0, \forall \text{ partitions } P, \quad || P || < \delta \implies |R(f,P)| < \varepsilon $$
where $R(f,P)$ is a Riemann sum of the function $f$ with partition $P$, and $||P||$ denotes the mesh of $P$.
Progress
We can view $f$ as the indicator function $\mathcal{X}_U$ for unit fractions $U\equiv \{ \frac{1}{n} : n\in\mathbb{N} \}$. I am aware that the indicator function $\mathcal{X}_\mathbb{Q}$ of the rationals is not Riemann integrable, and my intuition tells me that the difference is that $U$ is not dense on the interval $[0,1]$, and so as $||P||$ becomes smaller, fewer of the intervals in our partition contain members of $U$.
In fact, for any $\delta > 0$, the set $U \cap [0,1]$ contains only finitely many elements. Let $U_\delta \equiv U \cap [\delta,1] = \{ \frac{1}{n} : n \leq \frac{1}{\delta}\}$. So, $|U_\delta| \leq \frac{1}{\delta}$.
Suppose $P=\{0=x_0,x_1,\dots,x_n=1 \}$ is a partition of $[0,1]$ with $||P||<\delta$. Let $I_k=[x_{k=1},x_k]$ be the $k$th interval. Then,
$$ R(f,P) = \sum_{k=1}^m \left|I_k\right| \, f(x_k^*) = \left| I_1 \right| f(x_1^*) + \sum_{k=2}^m \left|I_k\right| \, f(x_k^*) $$
The first term in the sum above is bounded above by $\delta$. However, I can't seem to bound the second term in any meaningful way. I can bound by one by noting that $|U_\delta| \leq \frac{1}{\delta}$ and $|I_k| \leq \delta$, but this is not helpful.
Can I extend this line of reasoning further to obtain the desired result? How should I approach this problem?
Consider those unit fractions with denominator less than or equal to $N$. There are exactly $N$ of these fractions in the interval $[0,1]$. Choose a partition width less than $\delta$, which I will specify later, and note in particular that around each of these $N$ fractions there is a little $\delta$-interval.
Then our interval $[0,1]$ breaks into two pieces: the interval from $[0,1/N]$, which we haven't considered; and the interval from $[1/N, 1]$, which further breaks down into $\delta$-partitions containing the $N$ unit fractions and those partitions that do not. We will bound each of these three regions from above.
Any partition of the interval from $[0, 1/N]$ will be no wider than $\dfrac{1}{N} + \delta$, and the function is no larger than $1$. So we can bound the contribution here by $1 \cdot \left( \dfrac{1}{N} + \delta \right)$.
The $N$ partitions around the $N$ unit fractions will each be no wider than $\delta$, and the function is no larger than $1$ on each of these subintervals. Thus we can bound the contribution here by $N\cdot 1 \cdot \delta$. Notice that we may be overcounting a bit between here and the first region --- but that's okay.
In the rest of the interval $[0,1]$, the function is exactly $0$, and so there is no contribution.
Thus the overall contribution is bounded by $$ \left(\frac{1}{N} + \delta\right) + N\delta.$$ If, for each $N$, we choose $\delta < \frac{1}{N^2}$, then the overall contribution is bounded by $$ \left(\frac{1}{N} + \frac{1}{N^2} + \frac{1}{N} \right)\leq \frac{3}{N}.$$
In particular, given an $\epsilon > 0$, if we choose $N > 3\epsilon^{-1}$ and $\delta = \frac{1}{N^2}$, then the overall integral is bounded above by $$ \epsilon,$$ completing the proof that the Riemann integral is $0$. $\diamondsuit$