Continuity of a rational ruler like function 
Consider $f:\Bbb{R} \rightarrow \Bbb{R}$ by$$f(x)=\begin{cases} \frac{p+\sqrt{2}}{q+\sqrt{2}}-\frac{p}{q} &\text{if}\;x=\frac{p}{q}\in\Bbb{Q}\;\text{with}\;\text{gcd}(p,q)=1\\ \\0 & \text{otherwise} \; \end{cases}$$
Prove: $f$ is continuous at $(\Bbb{R} \setminus \Bbb{Q}) \cup \{1\}$

Here's my try:
Let $x_n \in (\Bbb{R} \setminus \Bbb{Q}) $ so that $x_n \rightarrow x=p/q \in \Bbb{Q}$ , so $f(x_n)=0$.
Therefore we make $f$ continuous at this $x$,we have  $f(x)=0$. But $f(x)=0$ only when $p=q$ and so $p/q=1$. So $f$ is continuous at $1$
Let $b$ be an arbitrary irrational number. Now check the continuity at $b$:
Whatever we make $\vert x-b \vert < \delta$, $\vert f(x)-f(b) \vert = \vert f(x) \vert < \epsilon$
Since $x \in (b-\delta,b+\delta)$ is irrational, then $f(x)=0<\epsilon$
and $x \in (b-\delta,b+\delta)$ is rational except $1$, so $x=p/q$ and note that $f(x)=\frac{p+\sqrt{2}}{q+\sqrt{2}}-\frac{p}{q}$ is irrational,since $p \neq q$, we conclude $f(x)=0< \epsilon$

Summary: For every $x \in N_\delta(b)$, $\vert f(x)-f(b) \vert < \epsilon$

Am I right? Any Thoughts?
 A: First, let's rewrite the formula for $f(x)$ when $x=p/q\in \mathbb Q$:
$$
f(x)=\sqrt{2}\frac{1-x}{q^2(q+\sqrt{2})}.
$$
Continuity at the irrationals.
Fix any irrational $y\in \mathbb R\setminus \mathbb Q$ and fix $\varepsilon>0$. To establish continuity at $y$, we must find $\delta>0$ such that $|f(x)|<\varepsilon$ for all $x\in (y-\delta,y+\delta)$. Here is how to find such a $\delta$. Fix an integer $N>2|1-y|/\varepsilon$ and let $\delta_1$ be the distance from $y$ to the closest rational number with denominator at most $N$. Let $\delta_2>0$ be sufficiently small such that
$$
\max(|1-y-\delta_2|,|1-y+\delta_2|)<\sqrt{2}|1-y|.
$$
(Such a $\delta_2$ exists since $y\not=1$.)
Finally, set $\delta=\min(\delta_1,\delta_2)$.
Then for all $x\in (y-\delta,y+\delta)$ either $x$ is irrational (in which case $f(x)=0$) or, by the above formula,
$$
|f(x)|=\sqrt{2}\frac{|1-x|}{q^2(q+\sqrt{2})}\leq \sqrt{2}\frac{|1-x|}{N^3}\leq \sqrt{2}\frac{|1-x|}{N}<\epsilon\frac{|1-x|}{\sqrt{2}|1-y|}<\varepsilon.
$$
This establishes continuity at the irrationals.
Continuity at $x=1$.
Note that $f(1)=0$ and $|f(x)|\leq \sqrt{2}|1-x|$. Continuity follows by the squeeze theorem.
Discontinuity at all remaining points of $\mathbb R$. It remains to show that $f(x)$ is discontinuous at every $x\in\mathbb Q\setminus \{1\}$. Indeed, note that at any such $x$ we have that $f(x)\not=0$. On the other hand, let $x_1,x_2,\ldots$ be a sequence of irrational numbers converging to $x$. Then $f(x_n)=0$ for all $n$, and in particular $\lim_{n\to\infty}f(x_n)=0$ which does not equal $f(x)$. Hence $f$ is discontinuous at $x$.
A: First we try to simplify the function $$f(x)=\begin{cases} \frac{p+\sqrt{2}}{q+\sqrt{2}}-\frac{p}{q} &\text{if}\;x=\frac{p}{q}\in\Bbb{Q}\;\text{with}\;\text{gcd}(p,q)=1\\ \\0 & \text{otherwise} \; \end{cases}=\begin{cases} \dfrac{\sqrt{2}(q-p)}{q(q+\sqrt{2})}=\dfrac{\sqrt 2(1-x)}{q+\sqrt 2} &\text{if}\;x\in\Bbb{Q}\\ \\0 & \text{otherwise} \; \end{cases}$$for some $x_0\in \Bbb Q^c$ it is quite obvious that for $x\in \Bbb Q^c$ and $x\to x_0$ we have $f(x)=0$. If $x\in\Bbb Q$ notice that $x\to x_0$ and $q$ grows unbounded (why?), so the numerator of $\dfrac{\sqrt 2(1-x)}{q+\sqrt 2}$ remains bounded around $\sqrt 2(1-x_0)$ and the denominator goes to $\infty$. This means that $\dfrac{\sqrt 2(1-x)}{q+\sqrt 2}\to 0$ as $x\to x_0$ and therefore the function is continuous over $\Bbb R-\Bbb Q$ so in $x_0=1$ because $x=1$ is a root of $\dfrac{\sqrt 2(1-x)}{q+\sqrt 2}$ so that even if $q\not\to\infty$ we have $1-x\to 0$ and $f(x)\to 0$ which completes our proof.
