$f(x)=1/q$ for $x=p/q$ is integrable
Let $f:\mathbb{R}\rightarrow\mathbb{R}$ be defined by setting $f(x)=1/q$ if $x=p/q$, where $p$ and $q$ are positive integers with no common factor, and $f(x)=0$ otherwise. Show that $f$ is integrable over $[0,1]$.
I'm using the Darboux definition of integration, so I want to prove that for any $\epsilon>0$ there exists a partition $P$ of $[0,1]$ such that $U(f,P)-L(f,P)<\epsilon$. Equivalently, there exists a partition $P$ of $[0,1]$ such that $$\sum_Rv(R)(M_R(f)-m_R(f)) < \epsilon$$ where $M_R(f)$ is the supremum of $f$ inside interval $R$, $m_R(f)$ is the infimum of $f$ inside interval $R$, and $R$ ranges over all intervals in the partition.
So I tried taking $P=[0,\dfrac1n,\dfrac2n,\ldots,1]$. The sum in question becomes $$\dfrac1n\sum_{i=0}^{n-1}(M_{[\frac{i}{n},\frac{i+1}{n}]}(f)-m_{[\frac{i}{n},\frac{i+1}{n}]}(f))$$
I know that $m_{[\frac{i}{n},\frac{i+1}{n}]}(f)=0$, because in the interval $[\dfrac{i}{n},\dfrac{i+1}{n}]$ there is an irrational number, so the sum reduces to $$\dfrac1n\sum_{i=0}^{n-1}M_{[\frac{i}{n},\frac{i+1}{n}]}(f)$$
I don't really know anything about the fraction with lowest denominator inside $[\dfrac{i}{n},\dfrac{i+1}{n}]$. How can I prove that this sum goes to $0$ as $n\rightarrow\infty$?
Solution 1:
In the Darboux version, you don't have to use partitions of the special type where every subinterval has the same length $1/n$. My suggestion: Let $A_n$ be the set of all the fractions whose denominator is at most $n$, then surround each element $a$ of $A_n$ by a small interval $I_a$, in such a way that the total length of these intervals is less than $\epsilon/2$. (or some other sub-part of given $\epsilon$). Now you know that on the complement of these intervals so far chosen, all the denominators exceed $n$. From here it should work out.
Note: the order of choices here is important. We are given $\epsilon$. Next we choose $n$ such that $1/n<\epsilon/2,$ and using that $n$ we look at $A_n$ and make the intervals $I_a$ around each $a \in A_n$ of total length less than $\epsilon/2$. Then on the rest of the interval $[0,1]$ the function is at most $1/n<\epsilon/2$, so we finally get the upper sum for the partition less than $\epsilon.$
Solution 2:
This function is called the Thomae's function and you can show that it is continuous at irrationals and discontinuous at rationals. In Lebesgue theory, we have a theorem which states that a bounded function on $[0, 1]$ is Riemann integrable if and only if it is continuous almost everywhere. Here the set of discontinuities has cardinality that of rationals so it has measure zero. Hence this function is integrable.
I understand that your question was to find partitions in order to prove the Riemann integrability (it's pretty similar to Darboux here). I will update this if I find a better way.