A function continuous on all irrational points Let $h:[0,1]\to\mathbb R$
$h(x)=\begin{cases}0&\text{if }x=1\\\frac{1}{n}& \text{otherwise if }x\in\mathbb Q,x=\frac{m}{n},\;m,n\in\mathbb N,\gcd(m,n)=1\\0&\text{otherwise if }x\in\mathbb R\setminus\mathbb Q\end{cases}$
How do you prove that $h$ is continuous on all irrational points within $[0,1]$?
 A: That is discontinuous at all rational points is the easy part.
Let $x\not\in \mathbb Q, \ \epsilon>0$ and consider the sets $$U_1=\left\{y\in[0,1]:f(y)<\epsilon\right\}\text{ and }U_2=\{y\in[0,1]:f(y)\geq\epsilon\}.$$ To show that $f$ is continuous at $x$ we have to show that $U_1$ contains an interval $(x-\delta,x+\delta)$ for sufficiently small $\delta$. 
Note that $U_2\subset \mathbb Q$  and that $\dfrac mn\in U_2\iff n\leq \dfrac1\epsilon$. Also for a fixed $n\in\mathbb N, \dfrac mn\in[0,1]\iff m\in\{0, 1, 2, \ldots, n\}$. Therefore $U_2$ is finite. 
Since $U_1\cup U_2=[0,1], \ U_1\cap U_2=\emptyset, \ x\in U_1$and $U_2$ is finite it follows that for some $\delta>0$, $U_2$ and $(x-\delta,x+\delta)$ are disjoint and therefore $ (x-\delta,x+\delta)\subseteq U_1$
This means that $f$ is continuous at $x$.
A: So you need to know that for any irrational $x$, any sufficiently good rational approximation has sufficiently large denominator. That is, fix an $N >0$, then we can find an $\epsilon_N >0$ so that whenever $|q-x|<\epsilon_N$, $q=\frac{a}{b}$ with $b>N$. I haven't done much but slightly rewrite the definition of continuity. Why is it that good rational approximations of irrational numbers have large denominators? It basically comes down to the division algorithm. Look at all the multiples of $\frac{1}{2}$. Our $x$ misses them, so we can put some small ball $\epsilon_1$ around $x$ so it misses all of the multiples of $\frac{1}{2}$. Here I'm implicitly using the division algorithm. Now look at multiples of $\frac{1}{3}$, $x$ misses all of them, so there is an $\epsilon_2$ such that....
Use this idea to write a formal proof.  
A: Note that when you have rationals $\frac ab,\frac cd$ with $ad-bc=-1$, then all rationals between them have denominator $\ge b+d$: If $\frac ab<\frac uv<\frac cd$, then the differences $\frac{ub-av}{bv}$ and $\frac{cv-ud}{vd}$ are positive, hence $ub-av\ge 1$, $cv-ud\ge 1$ and finally
$$ v = (bc-ad)v = b(cv-ud)+d(ub-av)=b+d. $$
Also note that one fraction inbetween is given by $\frac{a+c}{b+d}$.
Given any irrational $\alpha$, you can find such an fractions $\frac ab<\alpha<\frac cd$ with $ad-bc=-1$ and $b+d$ arbitrarily large as follows:
You can start with $\frac n1<\alpha<\frac{n+1}1$ where $n=\lfloor\alpha\rfloor$, then repeatedly from $\frac ab<\alpha<\frac cd$ switch to $\frac ab<\alpha<\frac {a+c}{b+d}$ or $\frac {a+c}{b+d}<\alpha<\frac cd$, depending on how $\frac{a+c}{b+d}$ compares to $\alpha$.
A: In fact, you can show that the lim$f(x)$ as $x\rightarrow x_{0}$ is $0$ for all $x_{0}\in [0,1]$:
Since $Q$ is countable, we can list its elements, reduced to lowest terms, in some prescribed way, say $0, \frac{1}{2},\frac{1}{3},\frac{2}{3},\frac{1}{4},\frac{3}{4},\frac{1}{5},...$. Now note that any infinite sequence of these must contain an infinite number of values of $q$ in $p/q$ unless it is eventually constant. 
Now pick $x_{0}\in [0,1]$ and suppose that the limit as stated above is not $0$. Then there is an $\epsilon >0$ and a sequence of points $\left \{   x_{n} \right \}$ s.t $x_{n}\in B((x_{0},1/n)$ and $f(x_{n})>\epsilon$ for all $n\in N$. This sequence cannot contain any irrational points, since at these points $f=0$.
Thus, we have constructed a sequence of rational numbers, not eventually constant, for which $f$ maps each term to a number greater than $\epsilon$. But this is impossible because as we have noted, any infinite sequence of rationals in $[0,1]$ must contain an infinite number of values of $q$ in $p/q$, so as soon as $q>1/\epsilon$, we select a term in the sequence of the form $p/q'$ with $q'>q$. Then $f(p/q')=1/q'<1/q<\epsilon$ and we get a contradiction.
