# Distinguishing differentiable and continuously differentiable functions

I came across this question as stated below:

let $$g(x) = xf(x)$$ where $$f(x)= \begin{cases} x \hspace{0.1cm}\sin(\frac{1} {x} ) &\text{if}\ x\neq 0\\ 0 &\text{if}\, x= 0 \end{cases}$$
Show that $$g(x)$$ is differentiable at $$x = 0 \hspace{0.2cm}$$but $$g'(x)$$ is not continuous at $$x=0$$

What I want to know is whether functions can exist which are differentiable but their derivative isn't continuous at that point. And, if they do exist, why would the derivative be discontinuous but the function be differentiable?

Until now, whenever they asked to check differentiability, instead of going for the limit definition, I directly differentiate the function and then check the continuity of the new function which clearly goes wrong as in this example.

Why are there functions that behave like that?

*To know exactly what I mean to ask, re-read the lines below the bold sentence.

• Yes, such functions exist; $g(x)$ is an example. Derivatives have no jump discontinuities, but they can have oscillatory discontinuities, as in this case. If you simply do the problem, I think all your questions will answer themselves. Jun 8 at 14:30
• "What I did until now, was whenever they asked to check differentiability instead of going for the limit stuff, I directly differentiate the function and then check the continuity of the new function which clearly goes wrong as in this example.": You've been wrong. Indeed this is a common mistake. Jun 8 at 14:38
• It is more confusing because it works in one direction: if the limit of $f'$ at that point exists, then $f$ is differentiable at that point and the derivative is the limit. But the fact that $f'$ has no limit says nothing about differentiability at that point. Jun 8 at 14:43
• "why would the derivative be discontinuous but the function be differentiable ?" Counter question: Why shouldn't it be discontinuous? Do you have any intuitive reason to believe so, other than the fact that you don't know any examples? Jun 8 at 15:02
• How I think about it: The derivative of a function is a (usually different) function. Since functions don't have to be continuous, there is no a priori reason to expect that the derivative (which is a function) is continuous. Jun 8 at 16:35

In this particular case it is not hard to confirm that the derivative exists at all non-zero values of $$x$$, that the usual convenient rules of differentiation give the same formula for the derivative at all non-zero $$x,$$ and that there is no possible value of the derivative at $$x$$ that would make the derivative continuous there.
On the other hand, if we compute the derivative from first principles (delta-epsilon), we find that it exists at $$x = 0$$ and we can find the value of the derivative there.
For an intuitive notion of how to construct a function with such bizarre properties as this, note that the factor $$\sin(1/x)$$ puts an infinite number of oscillations into the function near $$x = 0.$$ The factor $$x^2$$ (in $$g(x) = x f(x) = x^2 \sin(1/x)$$ when $$x\neq 0$$) "suppresses" the effect of those oscillations on the slope of the secant lines through $$(0,g(0)),$$ but it still allows the derivative oscillate between values that don't converge as we approach $$x = 0$$ from either side.
If we consider $$f(x)$$ then the oscillations of $$\sin(1/x)$$ near $$x = 0$$ would prevent convergence of the slopes of the secant lines at $$(0,f(0))$$. On the other hand, the derivative of $$x^2 f(x)$$ is continuous. That is, if we only multiply $$\sin(1/x)$$ by $$x$$ when $$x \neq 0,$$ it does not "suppress" the oscillations enough to allow defining the derivative at $$x=0$$; but if we multiply by $$x^3$$ it "suppresses" the oscillations so thoroughly that it suppresses the discontinuity of the derivative too.