Thomae Function is Continuous at Irrational Numbers

Theorem
Let $D_M: \R \to \R$ denote the Thomae function:


 * $\forall x \in \R: \map {D_M} x = \begin {cases} 0 & : x = 0 \text { or } x \notin \Q \\ \dfrac 1 q & : x = \dfrac p q : p, q \in \Z, p \perp q, q > 0 \end {cases}$

where:
 * $\Q$ denotes the set of rational numbers
 * $\Z$ denotes the integers
 * $p \perp q$ denotes that $p$ and $q$ are coprime (that is, $x$ is a rational number expressed in canonical form)

Then $\map {D_M} x$ is:
 * continuous at all irrational $x$ and at $x = 0$
 * discontinuous at all rational $x$ such that $x \ne 0$.

Rational $x$
Let $x = \dfrac p q \in \Q \setminus \set 0$ such that $\dfrac p q$ is the canonical form of $x$.

Then we have:
 * $\map {D_M} x = \dfrac 1 q$

Let $\epsilon = \dfrac 1 {2 q}$.

Let $\delta \in \R$.

Then from Between two Real Numbers exists Rational Number:
 * $\exists y \in \Q: x < y < \delta$

and from Between two Real Numbers exists Rational Number:
 * $\exists z \in \R \setminus \Q: x < z < y$

Hence there exists $z \in \R$ such that:
 * $z: \size {x - z} < \delta: \map {D_M} z = 0$

that is, such that:
 * $\size {\map {D_M} x - \map {D_M} z} = \dfrac 1 q > \epsilon$

That is, there exists an $\epsilon \in \R_{>0}$ such that it is always possible to find $\delta \in \R_{>0}$ such that there exists $z$ such that:
 * $\size {x - z} < \delta$

but such that:
 * $\size {\map {D_M} x - \map {D_M} z} > \epsilon$

Hence when $x$ is rational $\map {D_M} x$ is discontinuous.

Irrational $x$
In the following it is to be understood that all rational numbers expressed in the form $\dfrac p q$ are in canonical form.

Let $x \in \R \setminus \Q$ or $x = 0$.

Let $\Q$ be ordered in the following way:


 * $\dfrac {p_1} {q_1} \prec \dfrac {p_2} {q_2} \iff \begin {cases} q_1 < q_2 & : q_1 \ne q_2 \\ p_1 < p_2 & : q_1 = q_2 \end {cases}$

and so we can denote $\Q$ with this ordering as $\struct {\Q, \prec}$

Let $\epsilon$ be arbitrary.

Let $q$ be the smallest positive integer such that $\dfrac 1 q < \epsilon$.

Let $S \subseteq \struct {\Q, \prec}$ defined as:
 * $S = \set {z \in \Q: z \prec \dfrac 1 q}$

That is, $S$ is the set of all rational numbers whose denominators are all less than or equal to $q$

Let $a$ be the supremum of the set:
 * $\set {z \in S: z < x}$

Let $b$ be the infimum of the set:
 * $\set {z \in S: x < z}$

Then we have that the open interval:
 * $C = \openint a b$

contains $x$ and no rational numbers whose denominators are less than $q$.

Thus:
 * $\forall y \in C: \map {D_M} y \le \dfrac 1 q$

and so:


 * $\forall y \in C: \size {\map {D_M} y - \map {D_M} x} \le \epsilon$

because $\map {D_M} x = 0$ by definition.

Letting $\delta = \max \set {\size {x - a}, \size {b - x} }$ gives us our $\delta$.

Thus we have shown that:
 * $\forall \epsilon \in \R_{>0}: \exists \delta \in \R_{>0}: \forall y \in \R: \size {y - x} < \delta \implies \size {\map {D_M} y - \map {D_M} x} < \epsilon$

That is, $D_M$ is continuous at $x$.

Hence, when $x$ is irrational or $0$, $\map {D_M} x$ is continuous.