prove that derivative exists or doesn't exist I am solving couple of problems to an upcoming test and I have a question regarding the understanding of the derivative.
consider the following function:
$$f\colon x\mapsto\begin{cases}x^2\sin\left(\dfrac{1}{x}\right) & x \neq 0\\0 & x = 0\end{cases}$$
We have to prove if the derivative exists at $0$.
It's clear that the function is continuous because:
$$\lim_{x \rightarrow 0}x^2\sin\left(\frac{1}{x}\right)  = 0\times\lim_{x \rightarrow 0}\sin\left(\frac{1}{x}\right)$$
and $$x\mapsto\sin\left(\frac{1}{x}\right)$$ is bounded 
so:
$$\lim_{x \rightarrow 0} x^2\sin\left(\frac{1}{x}\right)=0$$
but what about the derivative?
its clear that:
$$\lim_{x\to 0}\ f'(x)=\lim_{x \rightarrow 0}\Big(2x\sin\left(\frac{1}{x}\right)-\cos\left(\frac{1}{x}\right)\Big)$$
and in this case the limit doesn't exist which makes perfect sense.
But what if I try to find the derivative by definition?
We get:
$$\lim_{h \rightarrow 0}\frac{(0+h)^2\sin\left(\dfrac{1}{0+h}\right)-0}{h} = \lim_{h \rightarrow 0}\frac{h^2\sin\left(\dfrac{1}{h}\right)}{h}=\lim_{h \rightarrow 0}h\sin\left(\dfrac{1}{h}\right)=0$$
How can it be? I am totally confused. 
 A: There is no contradiction, it is possible for the derivative to exists but it need not continuous. 
That is $f'(0)$ exists but $\lim_{x \to 0}f'(x) \neq f'(0)$
Edit:

A: This function is the example of a function which is differentiable everywhere, but where the derivative isn't continuous. What is happening here is that $f$ is squeezed between $x^2$ and $-x^2$, so at $0$ the derivative must exist and it must be $0$ (this is true of any function, no matter how ugly and discontinuous: If it is squeezed between $x^2$ and $-x^2$, or something similar, then it is differentiable at $0$ with derivative $0$). If you think of the derivative as the slope of a line that approximates the function, rather than some algebraic limit of a fraction, this is easier to grasp.
However, close to $0$, the function $f$ oscillates up and down ever faster. In fact, it's happening so fast that even though it's squeezed between two parabolas, it gets to be about $1$ steep each time. That means that the derivative goes up and down between (roughly) $\pm 1$ more and more as you get closer and closer to $0$. And that is why $\lim_{x\to 0}f'(x)$ doesn't exist.
