Continuity of Popcorn Function (Thomae's Function)

Working with sequences you would have to prove that for all sequences $x_n\to a$ one has $\lim_{n\to\infty}f(x_n)=f(a)=0$.

A direct $\epsilon$-$\delta$-proof is much simpler.

Let an $\epsilon>0$ be given. There is an $N\in{\mathbb N}$ with ${1\over N}<\epsilon$. The set $$Q:=\left\{{k\over n}\>\biggm|\>1\leq n\leq N, \ k\in{\mathbb Z}\right\}$$ of all rationals with a denominator $\leq N$ is discrete, and does not contain the irrational $a$. It follows that $Q$ contains a point nearest to $a$, and $$\delta:=\min_{x\in Q}|x-a|>0\ .$$ I claim that $|f(x)|<\epsilon$ for all $x$ with $|x-a|<\delta$.

Proof. If $x\in\ ]a-\delta, a+\delta[\ $ is irrational then $f(x)=0$ by definition of $f$. If this $x$ is rational then certainly $x\notin Q$, hence $x={p\over q}$ with $q>N$. It follows that $|f(x)|={1\over q}<{1\over N}<\epsilon$.


It suffices to show that $\lim_{t\to x}f(t)=0$ for any $x\in\Bbb R$.

$\underline{\forall x\in\Bbb R,f(x-)=0}$.

Let $\epsilon>0$ and choose $N\in\Bbb N_+$ such that $1/N<\epsilon$. For each $n\in\Bbb N_+$, let $$\begin{align} m_n & =\max\left\{m\in\Bbb Z:\frac mn<x\right\}\\ q_n & =\frac{m_n}n\quad\text{and,}\\ M_n & = \left\{\frac mn:\frac mn<x\right\}. \end{align}$$

For any $1\le n\le N$, we have that $M_n\cap [q_n,x)=\emptyset$ or $M_n\cap [q_n,x)=\{q_n\}$, since $\frac{m_n+1}n\ge x$. Therefore the set $$M=\bigcup_{k=1}^N M_k\cap[q_N,x)$$ is finite and we can define $$\delta=\min\{x-q:q\in M\}.$$

Now suppose $0<x-t<\delta$ for some $t\in\Bbb R$. If $t\in\Bbb Q$, then $t=m/n$ with $n>N$, and $f(t)=1/n<\epsilon$. If $t\notin\Bbb Q$, then $f(t)=0<\epsilon$.

$\underline{\forall x\in\Bbb R, f(x+)=0}$.

Let $\epsilon$ and $N$ be as above and define $$\begin{align} m_n & =\min\left\{m\in\Bbb Z:\frac mn>x\right\}\\ q_n & =\frac{m_n}n\\ M_n & =\left\{\frac mn:\frac mn>x\right\}. \end{align}$$

The proof now follows along the sames lines as the previous claim.