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?
Best Answer
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$.