# Continuity of Popcorn Function (Thomae's Function)

I have to prove that the function $f:]0,1] \rightarrow \Bbb R$ : $$f(x) = \begin{cases} \frac1q, & \text{if x \in \Bbb Q with  x=\frac{p}q for p,q \in \Bbb N coprime} \\ 0, & \text{if x \notin \Bbb Q } \end{cases}$$

is continuous in $x \in \ ]0,1] \backslash \Bbb Q$ (irrational numbers).

I already tried to solve this exercise and I understood how to prove that this function is discontinuous for rational numbers. I was trying, now, to understand how to prove that for the irrational numbers it is continuous.

I already have the solutions but they are a bit complicated, and I come up using sequences to prove it's continuous: $$\forall x_n \quad x_n\rightarrow a \quad \Rightarrow \quad f(x_n) \rightarrow f(a)$$

I created a sequence $x_n=\frac1n + a$, and we consider $a$ an irrational number. In order to be continuous $f(x_n)$ has to converge to $f(a)$. In fact:

$$\lim_{n\to\infty} f(x_n)= f(a) = 0$$

So my proof ends here, but I know that I'm missing something really big because in the solution there is another complicated step using a set and the Epsilon-Delta theorem after what I've showed.

Can someone explain what's wrong and help me with this proof?

• For $f$ to be continuous at $a$ you need to show that $\lim_{n\to\infty} f(x_n)=f(a)$ for all sequences $(x_n)_n$ with $x_n\to a$, not just your favorite one.
– J.R.
Jan 23, 2016 at 16:42
• I find it easier to show it is discontinuous using the $\epsilon, \delta$ definition of continuity. Here you merely have to use the fact that for any $\epsilon > 0$ you have an $N \in \mathbb{N}$ so that $\frac{1}{N}< \epsilon$. Jan 23, 2016 at 16:47

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$.

• Why do I have to choose the inf of the distance between my irrational number and the rational one?
– Ergo
Jan 24, 2016 at 13:35
• @Ergo I think it is to use inf to construct contradiction. Mar 15, 2016 at 20:47
• @Ergo: See my edit. Hope it's clearer now. Mar 15, 2016 at 21:03
• Christian Blatter Can you help Connection of complex $e^z$ and real Dirichlet please?
– BCLC
Aug 19, 2018 at 6:24
• @ChristianBlatter Hi! Please consider a simple sequence proof here. Thanks. May 16, 2020 at 17:06

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.

• Tim, why did you write it is possible that $M_n\cap [q_n,x)=\emptyset$ ? Actually I think it does always result in any case that $M_n\cap [q_n,x)=\{q_n\}$ May 16, 2020 at 16:38