# Continuity of function

Suppose $f(x) = \begin{cases} 0 \ \ \text{if} \ x \in \mathbb{R}- \mathbb{Q} \newline \frac{1}{q} \ \ \text{if} \ x \in \mathbb{Q} \ \text{and} \ x = \frac{p}{q} \ \text{in lowest terms} \end{cases}$

(i) Is $f$ continuous on the irrationals? (ii) Is $f$ continuous on the rationals?

For (i) you could use the sequence definition of continuity? Maybe try $a_n = \frac{\sqrt{2}}{n}$ and show that $a_n \to 0$ but $f(a_n) \not \to 0$? So its discontinuous on the irrationals?

For (ii) I don't see why there are $1+2+ \cdots + (q-1)$ rational numbers? I know that we need to use this fact to choose an appropriate $\delta$ (e.g $0< |x-a| < \delta \Rightarrow |f(x)-L| < \epsilon$).

-
Hints: Imagine the markings on a ruler. The $\epsilon$-$\delta$ definition of continuity is more useful for this problem than the sequence one. Remember the Archimedian property of real numbers. – Jyotirmoy Bhattacharya Oct 17 '10 at 5:09
But to prove discontinuity, I think the sequence definition is easier to use. – PEV Oct 17 '10 at 5:10
More hints: the function is continuous at all irrational points and discontinuous at all rational ones. – Jyotirmoy Bhattacharya Oct 17 '10 at 5:10
@Jyotirmoy: Sorry, I wrote my answer without noticing your hints. "Markings on a ruler" is a nice way of putting it. – Jonas Meyer Oct 17 '10 at 5:15
@Jonas: "also known as the popcorn function, the raindrop function, ..., the Riemann function or the Stars over Babylon" en.wikipedia.org/wiki/Thomae%27s_function – Jyotirmoy Bhattacharya Oct 17 '10 at 5:22
show 1 more comment

It's an well known function, continuous at all irrationals and discontinuous at all rationals. I will give sketch of the proof below.

First let's see why it's continuous at irrationals. To be continuous at an irrational point $x_0$, we need to show that $\forall\delta>0\exists\epsilon>0:|x-x_0|<\epsilon\Rightarrow |f(x)-f(x_0)|<\delta$.

Notice that within any range of length 1, in particular within $[x_0-1/2,x_0+1/2)$, $f(x)$ takes the value 1/2 exactly once, 1/3 twice, 1/4 thrice, and so on, taking 1/k exactly k+1 times. So if we remove these points upto say $\lceil1/\delta\rceil$, we will be removing only finitely many points, and we will be left with points on which $f(x)<1/\lceil1/\delta\rceil\le\delta$. Notice that $x_0$ being irrational was not one of the points that was removed. So find the closest point $a$ to $x_0$ that was removed, and call the distance $|x_0-a|$ as $\epsilon$.

In the same way, one can argue that the function is discontinuous for rationals. If $x_1$ is a rational point, notice that if we remove all the points of the form $p/q$ upto $0\lt q\le N$, any interval around $x_1$ will contain all points with $f(x)\lt 1/N$. So we can form intervals around $x_1$ with arbitrarily small $f$. Hence $f$ is discontinuous at $x_1$ since $f(x_1)>0$.

-

Your $a_n$'s are irrational, so $f(a_n)=0$. The function is continuous on the irrationals. You can show this using the $\epsilon$-$\delta$ definition of continuity. Once you're given an irrational $x$ and an $\epsilon>0$, there is an integer $n>1/\epsilon$, and there are only finitely many rational numbers in, say, $(x-1,x+1)$ having denominator smaller than $n$ is lowest terms. Thus there is a closest one to $x$, and you can use this to find your $\delta$.

Using similar reasoning, you can show that the limit at each rational is 0, but, as AD. points out, without knowing this there is a quick way to see that the function is discontinuous at each rational number.

-
 That $f$ is discontinuous at rationals are is much easier I would say: every neighborhood of $p/q$ contain irrational numbers. – AD. Oct 17 '10 at 5:27 @AD.: Good point. That was silly of me. – Jonas Meyer Oct 17 '10 at 5:30

Here's a picture that might help you see things more clearly: http://en.wikipedia.org/wiki/Thomae%27s_function

-