# Integrability of Thomae's Function on $[0,1]$.

Consider the function $f: [0,1] \to \mathbb{R}$ where f(x)= \begin{cases} \frac 1q & \text{if } x\in \mathbb{Q} \text{ and } x=\frac pq \text{ in lowest terms}\\ 0 & \text{otherwise} \end{cases}

Determine whether or not $g$ is in $\mathscr{R}$ on $[0,1]$ and prove your assertion. For this problem you may consider $0= 0/1$ to be in lowest terms.

Here's an attempt. I may have abused a bit of notation here, but the ideas are there.

Proof:
Let $M_i = \sup \limits_{x \in [x_{i-1},x_i]} f(x)$.

Notice first that the lower Riemann sums are always $0$, since every interval contains an irrational number. Thus, to prove $f \in \mathscr{R}$, it suffices to prove that, given any $\epsilon >0$, $\sum \limits_{i \in P} M_i \Delta x_i < \epsilon$ for some partition.

Let $\epsilon > 0$ and $M > \frac{2}{\epsilon}$. We first show that there exists $\eta(x,\frac{1}{M})$ so that $|f(x) - f(y)| < \frac{1}{M}$ if $|x-y| < \eta$. Fix $x \in (\mathbb{R} \setminus \mathbb{Q}) \cap [0,1]$. Now, consider the set $$R_{M} := \{ r \in \mathbb{Q} : r = \frac{p}{n}, n \leq M, p \leq n, p \in \mathbb{N} \}.$$ Clearly this set is finite, enumerate it as $\{q_1,\ldots, q_m\}$. So, let $$\eta(x,\frac{1}{M}) = \min_{i=1,\ldots, m} |x- q_i|.$$ We see then, $|f(x) - f(y)| < \frac{1}{M}$ on this $\eta$-neighborhood.

After we choose that $\eta$ so that $x \in (\mathbb{R} \setminus \mathbb{Q}) \cap [0,1]$, is continuous in a $\eta$-neighborhood, we see $$A:= [0,1] \setminus R_M \subset \left( \bigcup_{ x \in ( \mathbb{R} \setminus \mathbb{Q}) \cap [0,1]} B_{\eta(x)} (x) \right) \cap [0,1].$$ Since $A$ is compact, we may take finite sub-covering, and let $\delta = \min \limits_{i=1,\ldots,n} \{\eta(x_i)\}$. Take a partition $P_1$ of $A$ so that $\Delta x_i < \delta$. Since $R_M$ is non-empty, we can take a partition $P_2$ of $R_M$ so that $\Delta x_i < \frac{\epsilon}{2m}.$ Moreover, we see that, on $[0,1]$, $f$ is at most $1$. Let $P = P_1 \cup P_2$. Thus,

\begin{eqnarray*} \sum_{i \in P} M_i \Delta x_i &=& \sum_{i \in P_1} M_i \Delta x_i + \sum_{i \in P_2} M_i \Delta x_i \\ &\leq& \frac{1}{M} \sum_{i \in P_1} \Delta x_i + \sum_{i \in P_2} \Delta x_i \\ &<& \frac{\epsilon}{2} + \frac{\epsilon}{2} = \epsilon \end{eqnarray*}

EDITED I think I resolved the issue.

• What's $\mathscr{R}$? Commented Sep 9, 2015 at 4:36
• Sorry, it's the class of riemann integrable functions. We're supposed to prove this without using riemann lebesgue Commented Sep 9, 2015 at 4:38
• I think there may be an issue with the statement that these neighborhoods form an open cover Commented Sep 9, 2015 at 5:23
• See Petrovic, Advanced Calculus, Theory and Practice, (2014), p. 146. Commented Sep 9, 2015 at 5:38
• @TonyPiccolo Unfortunately the link seems to be unavailable Commented Sep 9, 2015 at 6:27

For an alternative approach, choose $$N \in \mathbb{N}$$ such that $$1/(N+1) < \epsilon/2$$ and let

$$B_N = \left\{1,\frac{1}{2},\frac{1}{3},\frac{2}{3}, \ldots, \frac{1}{N}, \ldots, \frac{N-1}{N} \right\}.$$

If $$x \notin B_N$$, then $$f(x) \leqslant 1/(N+1) < \epsilon/2$$. With $$m = \#(B_N)$$, choose a partition $$P = (x_0,x_1, \ldots, x_n)$$ where $$n > m$$ and $$\|P\| < \frac{\epsilon}{4m}.$$ There are at most $$2m$$ subintervals such that $$[x_{j-1},x_j] \cap B_n \neq \varnothing.$$

Let $$M_j = \sup_{x \in [x_{j-1},x_j]} f(x).$$

Then, the upper sum satisfies

$$U(P,f) = \sum_{j=1}^n M_j(x_j-x_{j-1}) = \\ \sum_{[x_{j-1},x_j] \cap B_N \neq \varnothing} M_j(x_j-x_{j-1}) + \sum_{[x_{j-1},x_j] \cap B_N = \varnothing} M_j(x_j-x_{j-1}) \\ \leqslant 2m \cdot 1 \cdot \frac{\epsilon}{4m} + \frac{1}{N+1}(1-0) \\ \leqslant \epsilon.$$

• @RFZ: The partition norm is $\|P\| = \min_{1 \leqslant i \leqslant n}(x_i-x_{i-1})$ and $\#(A)$ means the number of elements in the set $A$.
– RRL
Commented Nov 13, 2015 at 15:18
• @Fianra: Yes -- $\max$ instead of $\min$ in the comment which I can no longer edit. Thank you.
– RRL
Commented Jan 31, 2018 at 20:18
• Hi, @RRL! Can you explain why there are fewer than $2m$ subintervals such that $[x_{j-1},x_j] \cap B_n \neq \phi.$ ? Thanks!
– idk
Commented Jul 15, 2018 at 21:57
• @idk. The set $B_N$ contains $m$ points. The partition is assumed to have more than $m$ subintervals. The $m$ points can belong to at most $2m$ subintervals and this happens if each point is at the intersection of a pair of intervals (for m distinct pairs). I could have worded this better - it should say "at most $2m$" rather than "fewer than $2m$ in the answer.
– RRL
Commented Jul 15, 2018 at 22:27
• @Philipp: All that matters is that the contribution from summing over the intervals containing the $m$ points in $B_N$ is bounded by the maximum possible number of intervals times $\frac{\epsilon}{4m}$ and this is less than $\frac{\epsilon}{2}$ regardless of whether this number of intervals is $2m-1$ or $2m$. You are probably correct. I just threw out the estimate $2m$ to be conservative.
– RRL
Commented Mar 8, 2021 at 19:07

I just wanted to note that using Lebesgue's criterion for Riemann integrability, the proof is easy:

The criterion says that a bounded function on a compact interval $[a,b]$ is Riemann integrable if and only if it is continuous almost everywhere (the set of its points of discontinuity has measure zero).

Since the rationals have measure zero, it is enough to show $f$ is continuous in at all irrational points.

Let $x \in \mathbb{R} \setminus \mathbb{Q}$. Then $f(x)=0$. Suppose $x_n \to x$. We need to show $f(x_n) \to 0$. We can assume W.L.O.G that all the $x_n$ are rational. Since a sequence of rationals with an irrational limit have denominators going to infinity, we get the desired result.

Admittedly, Lebesgue's criterion is a rather "heavy gun" to use here, but for those who already know it, it is very nice:)

Yall, I think you're making this harder than it has to be.

First, $$\overline\int_a^b f = \overline\int_a^b f\cdot \mathbf 1_{\{x\}^c}$$. That is to say, you can "delete" any single point that you want, and the upper integral is unchanged.

Now obviously by the ML bound, $$\overline\int_0^1 f\le 1$$.

Delete the point at $$x=1$$ and call $$f_1 = f\cdot \mathbf 1_{\{1\}^c}$$. Then $$\overline \int_0^1 f = \overline\int_0^1 f_1 \le \frac 1 2$$.

Delete the point at $$x=1/2$$ and the integral is shown to be at most $$\frac 1 3$$.

Continue likewise, or more formally, let $$\varepsilon\in\Bbb R^+$$ and show that $$\overline\int_0^1 f < \varepsilon$$.

The lowest sums are easily seen to be zero. We are going to prove that with a suitable selection of the partitions the upper sums tend to zero. For this, take $$p$$ a prime number and let $$k=\max \{n \mid 1+\frac{n(n+1)}{2}\leq p\}$$. So $$p=1+\frac{k(k+1)}{2}+q$$, where $$0\leq q< k+1$$. We consider now the partition $$P=\{0<1/p<2/p<...<(p-1)/p<1\}$$ and let $$m_i=\sup\{f(x)\mid x\in [(i-1)/p,i/p]$$; $$i=0,1,...p-1\}$$. Now we reorder the sequence $$M=\{m_1,m_2,...,m_p\}$$ in decreasing order (not strictly) to obtain the finite sequence of $$p$$ terms $$R=\{1,....1/p\}$$. $$1$$ appear as the supreme in the subinterval $$[(p-1)/p,1]$$ and $$1/p$$ as the supreme in the subinterval $$[0,1/p]$$. Then we have

A-) If $$a and $$a/b\in [(l-1)/p,l/p]$$ then $$a/b\in ((l-1)/p,l/p)$$. In other words, with the above conditions $$a/b$$ can not be of the form $$n/p, n because if so, $$p\mid bn \Rightarrow p\mid b$$ or $$p\mid n$$ which is absurd since $$b,n. This prevent $$1/b$$ from being the supreme of two consecutive subintervals. For example if $$p=4$$ then $$1/2$$ is the supreme in the subintervals $$[1/4,1/2]$$ and $$[1/2,3/4]$$ and we don't want this to happen. That's the reason for which we choose p to be a prime number.

B-) As a consequence of A-) we have then that $$1/b$$ could appear at most $$b-1$$ times in the sequence $$M$$ (or $$R$$). Therefore, the first $$1+k(k+1)/2$$ terms of $$R$$ can be upper bounded (not strictly) term-to-term by the sequence $$\{1,1/2,1/3,1/3,1/4,1/4,1/4,...,1/(k+1),...,1/(k+1)\}$$ (note that in fact there are $$1+1+2+...+k=1+k(k+1)/2$$) terms). For the remaining $$q$$ terms we can take $$1/(k+2)$$ as an upper bound. Then we have

C-) $$U(f;P)\leq \frac{1}{p}[1+1/2+2/3+...+k/(k+1)+q/(k+2)]=\frac{1}{p}[1+1-1/2+1-1/3+...+1-1/(k+1)+q/(k+2)]=\frac{1}{p}[k+1-S+q/(k+2)]$$ where $$S=1/2+...+1/(k+1)$$. Since $$S>0$$, $$p>\frac{k(k+1)}{2}$$ and $$q,then $$U(f;P)<\frac{1}{p}[k+1+q/(k+2)]<\frac{2}{k(k+1)}[k+1+q/(k+2)]=\frac{2}{k}+\frac{q}{k(k+1)(k+2)}<\frac{2}{k}+\frac{1}{k(k+2)}$$

If $$p\rightarrow \infty \Rightarrow k\rightarrow \infty \Rightarrow \frac{2}{k}+\frac{1}{k(k+2)}\rightarrow 0$$. So we have proved that if $$p\rightarrow \infty \Rightarrow U(f;P)\rightarrow 0$$

Here is an approach which is not that lengthy. We first introduce the sandwich principle: $$f:[a,b]\to \mathbb R$$ is integrable if for any $$\epsilon>0$$, there exist integrable $$g,h$$ such that $$g\leq f\leq h$$ and $$\int_a^b h-g<\epsilon$$.

Then for Thomae's function $$T$$ and a given $$\epsilon>0$$, $$0\leq T\leq \epsilon \chi_{[0,1]}+t(x)$$, where $$t(x)=\begin{cases}\frac{1}{q},& x=\frac{p}{q}\in \mathbb Q\cap[0,1] \text{ and }\frac{1}{q}\geq \epsilon;\\0,&\text{otherwise.}\end{cases}$$ Note that $$t(x)$$ has only finite discontinuity (which makes $$t(x)$$ integrable), and $$\int \epsilon\chi_{[0.1]}+t(x)dx=\epsilon$$. Thus, by sandwich principle, $$T$$ is integrable with $$\int T=0$$.