Differentiability question ends up in contradiction. Let $f(x)=x^3cos\frac{1}{x}$ when $x\neq0$ and $f(0)=0$.
Is $f(x)$ differentiable at $x=0$?

My first attempt
Definition: A function is differentiable at $a$ if $f'(a)$ exists.
$$f'(x)=\lim_{h \to 0}\frac{f(x+h)-f(x)}{x+h-x}$$
$$f'(0)=\lim_{h \to 0}\frac{f(h)-f(0)}{h}$$
since $f(0)=0$
$$f'(0)=\lim_{h \to 0}\frac{f(h)-0}{h}$$
$$f'(0)=\lim_{h \to 0}\frac{h^3cos\frac{1}{h}}{h}$$
$$f'(0)=\lim_{h \to 0}h^2cos\frac{1}{h}$$
We know that $-1\leq cos(a) \leq 1$ for any real number $a$, so this implies:
$$-h^2 \leq h^2cos\frac{1}{h} \leq h^2$$
were both the lower and upper bounds approach $0$ when $h$ approaches $0$, therefore this seems to imply that a limit exists for $f'(0)$ and it is precisely $0$. So therefore $f(x)$ is differentiable at $0$.

But my second attempt results in a different answer.
$$f'(x)=3x^2cos\frac{1}{x}-xsin\frac{1}{x}$$
$cos\frac{1}{0}$ is undefined but since $f(0)=0$ if we could get the terms to be expressed in terms of $x^3cos\frac{1}{x}$ then maybe that is defined:
$$f'(x)=3\frac{x^3cos\frac{1}{x}}{x}-\frac{x\sqrt{x^6-x^6cos^2\frac{1}{x}}}{x^3}$$
since $f(0)=0^3cos\frac{1}{0}=0$
$$f'(0)=\frac{0}{0}-0$$
which is undefined.

So there lies my contradiction.
I think my questionable step is assuming that $f(0)=0 \implies 0^3cos\frac{1}{0}=0$
How do I solve this contradiction and determine whether $f'(0)$ is differentiable?
 A: You should trust the first method more; it is, after all, the definition of the derivative. The issue with the second method is that, though its algebra looks correct, you have division of $0$ by $0$, which you correctly note to be undefined. However, a better interpretation of "undefined" is "this method doesn't yield an answer" rather than "the answer doesn't exist" - so your results don't contradict each other; it's just that your standard method failed.
Also, be careful with trying to look at the derivative at other points $x\neq 0$ in order to find it at $0$. In general, the derivative of a function is not necessarily continuous; for instance, if we take the function $f(x)=x^2\sin(x^{-1})$ for non-zero $x$ and $f(0)=0$, we can see the derivative to be $f'(x)=x\sin(x^{-1})-\cos(x^{-1})$ at non-zero $x$ and $f'(0)=0$. However, $\lim_{x\rightarrow 0}f'(x)$ does not exist, because the function $f'$ oscillates infinitely often near $0$. In general, the second method, therefore, can't always be expected to work.
A: $$f'(x)=3x^2\cos\frac{1}{x}-x\sin\frac{1}{x}$$
For real $x,-1\le\cos\dfrac1x,\sin\dfrac1x\le1\implies f'(0)=0$
A: As your first calculation shows, $f$ is differentiable at $x=0$ and $f'(0)=0$. What you do in your second computation is to calculate $\lim_{x\to0}f'(x)$. In this particular case $f'(0)=\lim_{x\to0}f'(x)=0$. But for $g(x)=x^2\cos(1/x)$ you will find that $g'(0)=0$ and $\lim_{x\to0}g'(x)$ does not exist (this is the typical example of a differentiable function whose derivative is not continuous.)
A: $1$) You showed correctly, from the definition of the derivative, that $f'(0)=0$. 
$2$) You used the ordinary differentiation formula to find the derivative of $f(x)$ when $x\ne 0$. That is perfectly fine.
Then you decided to use the limit as $x\to 0$ of the $f'(x)$ calculated in $2$) to calculate $f'(0)$. That is in principle not OK. This limit exists and is equal to $f'(0)$ precisely if $f'(x)$ is continuous at $x=0$. In our case, $f'(x)$ happens to be continuous at $x=0$. However, let $g(x)=x^2\sin(1/x)$ when $x\ne 0$, and let $g(0)=0$. Then it turns out that $g(x)$ is differentiable everywhere, but $g'(x)$ is not continuous at $x=0$. 
Remark: It turns out that $\lim_{x\to 0}f'(x)=0$. However, your particular manipulation did not show this. We give a simillar but more extreme example. Let $h(x)=e^x$. Of course $\lim_{x\to 0} h(x)=1$. But note that if $x\ne 0$, then $h(x)=\frac{x^3e^x}{x^3}$. If we set $x=0$, we get an undefined result. That's not a problem: setting $x=0$ is just not the right way to calculate the limit.   
