Prove continuity/discontinuity of the Popcorn Function (Thomae's Function). I have to prove that a 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 discontinuous in every point $x \in \ ]0,1] \cap\Bbb Q$.
And then to consider $x \in \ ]0,1] \backslash \Bbb Q$ and prove that it is continuous.
For now I learned different ways to prove continuity (epsilon-delta, sequences), but I'm never sure what would be better to use in each different case.
I wanted to prove the discontinuity by using sequences:
$$\forall x_n \quad x_n\rightarrow a \quad \Rightarrow \quad f(x_n) \rightarrow f(a)$$
I tried creating a sequence $ x_n=\frac1n + a$, we know it converges to $a$ but $f(x_n)\ $ doesn't  converges to $\ f(a)$ because there would still be some points not in our set (irrational numbers that creates gaps).
But I don't think it works, so I'm asking you if you could help me solving the two questions.
 A: This sometimes called the Popcorn Function, since if you look at a picture of the graph, it looks like kernels of popcorn popping. (Also called the Thomae's Function.)
To prove it is discontinuous at any rational point, you could argue in the following way: Since the irrationals that are in $(0,1)$ are dense in $(0,1)$, given any rational number $p/q$ in $(0,1)$, we know $f(p/q) = 1/q$.  But let $a_{n}$ be a sequence of irrationals converging to $p/q$ (by the definition of density).  Then $\lim \limits_{a_{n} \to (p/q)} f(x) = 0 \neq f(p/q)$.  Thus, $f$ fails to be continuous at $x = p/q$.
Now, to prove it is continuous at every irrational point, I recommend you do it in the following way:

*

*Prove that for each irrational number $x \in (0,1)$, given $N \in \Bbb N$, we can find $\delta_{N} > 0$ so that the rational numbers in $(x - \delta_{N}, x + \delta_{N})$ all have denominator larger than $N$.


*Once you have the result from above, we can use the $\epsilon-\delta$ definition of continuity to prove $f$ is continuous at each irrational point.
So, first prove 1. (It's not too hard.) Once you've done that, you can accomplish 2. in the following way:

Let $\epsilon > 0$.  Let $x \in (0,1)$ be irrational.  Choose $N$ so that $\frac{1}{n} \leq \epsilon$ for every $n \geq N$ (by the archimedian property).
By what you proved in 1., find $\delta_{N} > 0$ so that $(x - \delta_{N}, x + \delta_{N})$ contains rational numbers only with denominators larger than $N$.
Then if $y \in (x-\delta_{N}, x + \delta_{N})$, $y$ could either be rational or irrational.  If $y$ is irrational, we have $|f(x) - f(y)| = |0 - 0| = 0 < \epsilon$ (since $f(z) = 0$ if $z$ is irrational).
On the other hand, if $y$ is rational, we have $y = p/q$ with $q \geq N$.  So $|f(x) - f(y)| = |0 - f(y)| = |f(y)| = |1/q| \leq |1/N| < \epsilon$, and this is true for every $y \in (x-\delta_{N}, x + \delta_{N})$.
Thus, given any $\epsilon > 0$, if $x \in (0,1)$ is irrational, we found $\delta > 0$ (which was actually $\delta_{N}$ in the proof) so that $|x - y| < \delta$ implies $|f(x) - f(y)| < \epsilon$.

A: Your approach of proving it by choosing an appropriate sequence is viable, but it becomes easier if you define a sequence (still converging to a) where the individual members are irrational.
For the second part sequences are clumsy because, in order to prove continuity, you would have to consider every possible sequence. You need to show that any fraction that is sufficiently close to a given irrational number a has a large simplest denominator.
