In Thomae's Function:

$$ \begin{align} t(x) = \begin{cases} 0 & \text{if $x$ is irrational}\\ \frac{1}{n} & \text{if $x = \frac{m}{n}$ where $\gcd(m,n) = 1$} \end{cases} \end{align} $$

I can prove the discontinuity at rational $b$ by taking a sequence of irrationals $x_n$ which converge to $b$.

But while going through an argument for continuity at irrationals. I found this in a book.

On the other hand if $b$ is an irrational number and $\epsilon > 0$ then there is a natural number $n_0$ such that $1/n_0 < \epsilon$. There are only finite number of rationals with denominator less than $n_0$ in the interval $(b-1,b+1)$. Hence we can find a $\delta > 0$ such that $\delta$ neighbourhood of $b$ contains no rational with denominator less than $n_0$.

I understand the rest of the proof. But I am unable to prove the emphasized text. Although I find it intuitive.

  • $\begingroup$ @Arctic Char Can you please tell me the name of this book? $\endgroup$
    – Learning
    Commented Feb 15, 2022 at 4:43
  • 2
    $\begingroup$ @Learning I guess that book is Introduction to Real Analysis by Robert G. Bartle and Donald R. Sherbert. $\endgroup$ Commented Apr 1, 2022 at 21:11
  • 2
    $\begingroup$ Yes, page 128 of the fourth edition, which is free online. $\endgroup$
    – Joe
    Commented Apr 1, 2022 at 21:17

4 Answers 4


Let $m=n_0-1$, so we want to consider rationals with denominators $1,\cdots,m$ in the interval $(b-1,b+1)$. Since consecutive rationals with denominator k differ by $1/k$ and the interval $(b-1,b+1)$ has length 2, there are at most 2k rationals with denominator k in $(b-1,b+1)$.

Therefore there are at most $2\cdot1+2\cdot2+\cdots+2m$ rationals in $(b-1,b+1)$ with denominator less than $n_0$, so we can choose a $\delta$ with $0<\delta<|b-r|$, where r is the rational with denominator less than $n_0$ in $(b-1,b+1)$ which is closest to b.

  • $\begingroup$ what if we take $b = 1$ and $k = 4$? You see the "consecutive" rationals with denominator $k$ are $1/4$, $3/4$, $5/4$, and $7/4$, which are at a distance of $2/4 = 1/2$. So don't you think your argument breaks down? $\endgroup$ Commented Mar 30, 2017 at 17:36
  • $\begingroup$ @SaaqibMahmuud In your example, I am arguing that there are at most 8 rationals of the form $\frac{m}{4}$ in the interval $(0,2)$, since the distance between $\frac{m}{4}$ and $\frac{m+1}{4}$ is $\frac{1}{4}$ for each $m$. $\endgroup$
    – user84413
    Commented Apr 1, 2017 at 19:13
  • $\begingroup$ why do we choose $ \delta < |b-r| $? Would it be wrong to choose $\delta < 1/n_{0} $ ? $\endgroup$
    – ali
    Commented Aug 29, 2020 at 5:39
  • 1
    $\begingroup$ @ali yes it would be wrong. Setting $\delta<\frac{1}{n_0}$ does not guarantee that you exclude all rationals with a denominator $<n_0$. Take for example an irrational number $b:=3+\frac{1}{1000 \pi}$ and you start with an $\epsilon=\frac{1}{3}$. Then $\frac{1}{n_0}=\frac{1}{2}>\epsilon=\frac{1}{3}$. However, if I set $\delta:=\frac{1}{10}<\frac{1}{n_0}=\frac{1}{2}$ then we still can plug in the rational $3$ because $|b-3|<\delta $ but this implies $|f(b)-f(\frac{3}{1})|=|0-1|>\epsilon=\frac{1}{2}$. So the condition regarding continuity would not be satisfied. You always must use $|b-r|$. $\endgroup$
    – Philipp
    Commented Sep 3, 2020 at 14:01
  • 1
    $\begingroup$ @pie, the greatest commen divisor of $0$ and $1$ is $1$. So in terms of the definition of Thomae function we have $0=\frac{0}{1}$. Hence, $t(0)=\frac{1}{1}=1$. $\endgroup$
    – Philipp
    Commented Oct 3, 2023 at 10:49

Let $b \in \mathbb{R} \setminus \mathbb{Q}$. Given $\epsilon > 0$ let $K = \left \lceil \frac{1}{\epsilon} \right \rceil$. Thus, $\frac{1}{K} < \epsilon$.

Note that $K$ is a finite number and the number of integers less than $K$ is also finite. This means the number of rationals of the form $\frac{1}{q} > \frac{1}{K}$ is also finite.

Shrink the interval $(b-1, b+1)$ down to $(b-\delta, b+ \delta )$ such that all these $\frac{1}{q}$ are tossed out, leaving only rationals $\frac{1}{q} < \frac{1}{K} < \epsilon$.

It follows that if $|x -b| < \delta$ then $|f(x) - f(b) | = |f(x)| \leq \frac{1}{K} < \epsilon$.

  • $\begingroup$ Will this be a good approach to shrink the interval ? $Let E_{n}:=\{x \in Q | f(x) \geq 1/n\}$ now $n\{E_{n}\} \leq \frac{n(n+1)}{2} = m \; (say)$ clearly m $\in$ $N$ $E_{n}=\{b_{1},b_{2} \ldots b_{m}\}$ let $ q=inf\{|b-b_{i}|i=1,2 \ldots m\}$ then if $|x-b|<q$ $ \Rightarrow$ $|f(x)-f(b)|=|f(x)|=f(x) <1/n< \epsilon$ $\endgroup$
    – vishu
    Commented Nov 2, 2017 at 14:36
  • $\begingroup$ Your answer helped me a lot! Thank you!! $\endgroup$
    – Natasha J
    Commented Aug 29, 2021 at 13:09
  • $\begingroup$ @MartyB. I've made a change to your answer. Do you agree to my edit? $\endgroup$ Commented Apr 1, 2022 at 21:09

Let $\frac{m}{n}$ be a rational number such that $$b-1 \leq \frac{m}{n} \leq b+1,$$ where $m$ and $n$ are integers such that $n> 0$ and $\gcd (m, n) = 1$.

Then we see that $$ n ( b-1) \leq m \leq n(b+1).$$ Thus, $$ m \in \mathbb{Z} \cap \left[ \ n(b-1), \ n(b+1) \ \right].$$ Therefore, $$m \in \left\{ \ \lceil n(b-1) \rceil, \ldots, \lfloor n(b+1) \rfloor \ \right\},$$ where $\lfloor 2.5 \rfloor = 2$ and $\lceil 2.5 \rceil = 3$, and $\lfloor 2 \rfloor = 2 = \lceil 2 \rceil$.

Hence, for each natural number $n$, there are at most $$N \colon= \lfloor n(b+1) \rfloor - \lceil n(b-1) \rceil$$ rational numbers with denominator $n$ in the closed interval $[b-1, b+1]$ and hence in the open interval $(b-1, b+1)$.

  • $\begingroup$ I can see that it is clearly true, but how do you prove that m is in between the ceiling of n(b-1) and the floor of n(b+1)? $\endgroup$
    – jsmith
    Commented May 31, 2022 at 8:42
  • $\begingroup$ @jsmith you see, $m$ is an integer $\geq n(b-1)$, but $\lfloor n(b-1) \rfloor \leq n(b-1)$; moreover there is a difference between $\lfloor n(b-1) \rfloor$ and $\lceil n(b-1) \rceil$ only if $n(b-1)$ is not an integer,. So we must have $m \geq \lceil n(b-1) \rceil$, and the latter quantity of course equals $\lfloor n(b-1) \rfloor$ when $n(b-1)$ is an integer. A similar argument works for $n(b+1)$. $\endgroup$ Commented Jun 1, 2022 at 19:48

The natural extension of Thomae's function to the hyperreals is defined by the same formula: $$ \begin{align} t(x) = \begin{cases} \frac{1}{n} & \text{if $x = \frac{m}{n}$ where $m,n\in{}^\ast\mathbb N$ and $\gcd(m,n) = 1$} \\ 0 & \text{otherwise.}\\ \end{cases} \end{align} $$ To show that $t(x)$ is continuous at $c\in\mathbb R\setminus \mathbb Q$, suppose $q$ is a hyperrational infinitely close to $c$. Clearly $q\not\in\mathbb R$. Since $q$ is appreciable (i.e., finite but not infinitesimal), its denominator $n$ is necessarily an infinite hyperinteger. Hence $t(q)=\frac{1}{n}\approx 0$ where $\approx$ is the relation of infinite proximity. Thus $t(x)$ is infinitesimal at all points infinitely close to $c$, proving the continuity of $t(x)$ at $c$.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .