Problem: Consider the function $f$ defined on $\mathbb{R} $ by
\[
f(x) =
\begin{cases}
x^2 \sin \frac{1}{x}, &\text{ if } x \neq 0 ;\\
0, &\text{ otherwise} .
\end{cases}
\]
Prove that the function is differentiable at $x=0$ but $f^\prime $ is not continuous at zero.
Solution: Note that for $x\neq 0$,
\[
\vert f(x) \vert = \left\vert x^2 \sin \frac{1}{x} \right\vert \leq \vert x^2 \vert.
\]
So the function $f$ satisfies the property that $\vert f(x) \vert \leq x^2$ in some neighborhood of zero and $f(0) = 0$. Then we claim that the function is differentiable at $x=0$. The difference quotient at $x_0 = 0$ will be
\[
\frac{f(x) - f(0)}{x - 0} = \frac{f(x)}{x},
\]
from which we have
\begin{align*}
\left\vert \frac{f(x)}{x} \right\vert \leq \left\vert \frac{x^2}{x} \right\vert = \vert x \vert .
\end{align*}
So,
\[
0 \leq \lim_{x \to 0} \left\vert \frac{f(x)}{x} \right\vert \leq \lim_{x \to 0} \vert x \vert = 0.
\]
Therefore, $f^\prime (0) = 0$. So this proves that the function is differentiable at $x = 0$.
Now we will prove that the derivative of $f$ is not continuous at $x = 0$. Just a simple computation gives us
\[
f^\prime (x) =
\begin{cases}
\cos \frac{1}{x} + 2x \sin \frac{1}{x}, &\text{ if } x \neq 0 ;\\
0 , &\text{ otherwise} .
\end{cases}
\]
To prove that the $f^\prime (x)$ is not continuous at $x= 0$, we consider the following sequence:
\[
x_n = \frac{1}{\pi n}.
\]
Clearly, $x_n \rightarrow 0$. Note that
\[
f^\prime \left( x_n \right) =
\begin{cases}
\cos \pi n, &\text{ if } x \neq 0 ;\\
0 , &\text{ otherwise} .
\end{cases}
\]
Since $\cos (\pi n)$ takes the number $\pm 1$ and hence the sequence is an alternating sequence with values $1$ and $-1$. This implies $f^\prime \left( x_n \right) $ is not a convergent sequence and hence $f^\prime (x)$ is not continuous at $x = 0$.