Proving $f(x)=\begin{cases}0&, x\in\mathbb Q\\x^2&,x\in\mathbb R\setminus\mathbb Q\end{cases}$ is differentiable only at $x=0$ 
Consider the function $$f(x)=\begin{cases}0&,x\in\mathbb Q\\x^2&,
x\in\mathbb R\setminus\mathbb Q\end{cases}$$ Prove that $f$ is differentiable only at $x=0$. 

My approach: 
Let us take any point $a$ and assume that $f$ is continuous at $a$. 
We know that there exists a sequence $\{q_n\}_{n\ge 1}$ of rational numbers such that $$\lim_{n\to\infty}q_n=a.$$ 
Also we know that there exists a sequence $\{r_n\}_{n\ge 1}$ of irrational numbers such that $$\lim_{n\to\infty}r_n=a.$$ 
Now since we have assumed that $f$ is continuous at $a$, this implies that $$\lim_{n\to\infty}f(q_n)=\lim_{n\to\infty}f(r_n)=f(a)...(1)$$ 
Now $$\lim_{n\to\infty}f(q_n)=\lim_{n\to\infty}0=0$$ and $$\lim_{n\to\infty}f(r_n)=\lim_{n\to\infty}r_n^2=a^2.$$ 
Therefore by $(1)$ we have $0=a^2\implies a=0.$ Now $f(0)=0$. 
This implies that $f$ is continuous only at $x=0$. 
Now let us take any sequence $\{x_n\}_{n\ge 1}$ such that $$\lim_{n\to\infty}x_n=0.$$
Now if the limit $$\lim_{n\to\infty}\frac{f(x_n)-f(0)}{x_n-0}=\lim_{n\to\infty}\frac{f(x_n)}{x_n}$$ exists, then we can conclude that $f$ is differentiable at $x=0$. 
But, how to systematically show the same?
 A: you have $\dfrac{f(x)}{x}=0$ or $x$, depending on the rationality of $x$. Hence for all $x\neq 0$, we have $\vert \dfrac{f(x)}{x}\vert\leq \vert x\vert$. So the letf hand side goes to zero as $x$ goes to zero and you may conclude that $f$ is differentiable at $0$ and $f'(0)=0$.
A: There is no need to first study continuity.
You form two sequences converging to some $x_\infty$ by the irrationals and by the rationals.
We first assume $x_\infty$ irrational, and 
$$\frac{f(x_n)-f(x_\infty)}{x_n-x_\infty}=\begin{cases}\dfrac{x_n^2-x_\infty^2}{x_n-x_\infty}\to2\,x_\infty&\text{ for }x_n\notin\mathbb Q\\\dfrac{-x_\infty^2}{x_n-x_\infty}\text{ d.n.e.}&\text{ for }x_n\in\mathbb Q.\end{cases}$$
Next, with $x_\infty$ nonzero rational, 
$$\frac{f(x_n)-f(x_\infty)}{x_n-x_\infty}=\begin{cases}\dfrac{x_n^2}{x_n-x_\infty}\text{ d.n.e.}&\text{ for }x_n\notin\mathbb Q\\\dfrac{0}{x_n-x_\infty}\to0&\text{ for }x_n\in\mathbb Q.\end{cases}$$
Finally, with $x_\infty=0$,
$$\frac{f(x_n)-f(x_\infty)}{x_n-x_\infty}=\begin{cases}\dfrac{x_n^2}{x_n}\to0&\text{ for }x_n\notin\mathbb Q\\\dfrac{0}{x_n}\to0&\text{ for }x_n\in\mathbb Q.\end{cases}$$
and the derivative is $0$.
A: We have 
$$ \frac{f(x_n)}{x_n} = \frac{1}{x_n} \begin{cases} 0, & x_n \in \mathbb{Q} \\ x_n^2, & x_n \notin \mathbb{Q}  \end{cases} = \begin{cases} 0, & x_n \in \mathbb{Q} \\ x_n, & x_n \notin \mathbb{Q}  \end{cases} \overset{n \to \infty}{\longrightarrow} 0$$
as both terms converge to $0$.
