Continuity – Explanation of Proof for (Dis)continuity of Thomae’s Function

continuity

Can someone explain the proof for the continuity at irrationals but discontinuity at rationals for Thomae's function?
More specifically, why if x is rational with $x = \frac{p}{q}$, and we choose $0<\epsilon<\frac{1}{q}$, does the condition for continuity fail? Please be detailed but not overly technical.

Best Answer

Thomae's function is $$ f(x) = \cases{1/q & if $x = p/q$ in lowest terms with $q > 0$\cr 0 & if $x$ is irrational\cr}$$

If $x =p/q$ is rational, and you take $0 < \epsilon < 1/q$ and any $\delta > 0$, there are irrational numbers $y$ with $|x-y| < \delta$, and then $|f(x) - f(y)| = 1/q > \epsilon$. So $f$ is discontinuous at $x$.

If $x$ is irrational, for any $\epsilon > 0$, take $Q$ large enough that $1/q < \epsilon$ for $q \ge Q$. Thus the only $y$ with $|f(y) - f(x)| \ge \epsilon$ are $p/q$ for $q < Q$. There are only finitely many of these with $|y - x| < 1$, say $p_1/q_1, \ldots, p_n/q_n$. So we can take $\delta < \min \{|p_i/q_i - x| \mid i = 1 \ldots n\}$.