# Why is this function only differentiable at zero?

In my analysis class, we had the following function: $$f: \mathbb{R} \to \mathbb{R}: x \mapsto \begin{cases} x^2 & \text{ if } x \in \mathbb{Q}\\ -x^2 & \text{elsewhere}.\end{cases}$$

At zero, I can see that this function is differentiable: indeed, we have that $$\lim_{h \to 0}\Big|{\frac{f(h) -f (0)}{h}}\Big| = \lim_{h \to 0}|h| = 0$$ by continuity of the absolute-value function and therefore, the limit of $h \to 0$ of the quotients also equals zero.

My course notes then state that this function is nowhere differentiable except at zero. At this point, I only know about continuity and the definition of differentiability. Another example of my course notes used a sequence converging to zero, such that the quotient in the definition of derivative does not converge or has no limit. Therefore, I tried doing the same, but without result... Any hints on how to solve this?

Note that I do know that this function is not continuous (except at zero), but I have not seen the result (differentiable implies continuous) yet, so I'm sure the lecture notes do not intend to use this result...

• What happens if you take a rational sequence converging to $0 \neq x \in \mathbb{Q}$? What if you take a non-rational sequence? How does this change when $x \not\in \mathbb{Q}$? – Hetebrij Aug 28 '18 at 9:40
• "I have not seen the result (differentiable implies continuous) yet, so I'm sure the lecture notes do not intend to use this result..." Sorry but this sentence is just absurd. You should know that differentiability is stronger than continuity and how to prove that it is. – Did Aug 28 '18 at 10:01
• @Did: this result is only proven in the section after this example. I tried to indicate that I suspected the intended proof of this example does not use this result, nothing more, nothing less... – Student Aug 28 '18 at 10:04
• By the way it is much easier to prove that the function is discontinuous at all points except $0$ and thus the method at the end of your question is the most natural one to handle this. – Paramanand Singh Aug 29 '18 at 1:55

If you compute the limit

$$\lim_{x\to x_0}\frac{f(x)-f(x_0)}{x-x_0}$$ using a subsequence of rationals and a subsequence of irrationals, you will converge to $2x_0$ and $-2x_0$ respectively, which are different numbers. This shows that the limit does not exist when $x_0\ne0.$

Erratum:

As commented by José, the above reasoning is not right. If $x_0$ is rational, then the limit via the irrationals does not exist, and similarly if $x_0$ is rational the limit via the irrationals does not exist.

So in both cases, the limit does not exist.

• This is not correct. If $x_0$ is irrational and if $(x_n)_{n\in\mathbb{N}}$ is a sequence of rational numbers such that $\lim_{n\to\infty}x_n=x_0$, then the limit $\lim_{n\to\infty}\frac{f(x_n)-f(x_0)}{x_n-x_0}$ is not $\pm2x_0$. It simply doesn't exist (in $\mathbb R$). – José Carlos Santos Aug 28 '18 at 10:11
• @JoséCarlosSantos: you are right, fixing. – Yves Daoust Aug 28 '18 at 10:15
• Would it be possible to rewrite the answer with the right reasoning? The erroneous argument can be confusing to some, so I would prefer to see it removed rather than commented. – Joonas Ilmavirta Aug 28 '18 at 13:29
• Why do the limits not exist? At a glance it looks like reasonable logic to me... – Chris Aug 28 '18 at 13:32
• @chris: so did it to me at first glance. But if $x_0$ is "of the other kind", $f(x_0)$ is "of the other sign". – Yves Daoust Aug 28 '18 at 13:59

Consider the point $1$, for instance. In order to prove that $f$ is not differentiable there, you have to prove that the limit $\lim_{x\to1}\frac{f(x)-1}{x-1}$ doesn't exist. Note that there are numbers arbitrarily close to $1$ whose square is irrational. For such a point $x$, $f(x)$ is close to $-1$, and therefore $\left\lvert\frac{f(x)-1}{x-1}\right\rvert$ must be a very large number. It is not hard to formalize this in order to prove that the limit $\lim_{x\to1}\frac{f(x)-1}{x-1}$ doesn't exist indeed.

The argument is similar at the other points of $\mathbb{R}\setminus\{0\}$.