Find $f'(x)$ when $f(x) = x^2 \cos(\frac{1}{x})$ Find $f'(x)$ when
$$
f(x) = \begin{cases}
x^2\cos(\frac{1}{x}),& x \neq 0\\
0, &x = 0\end{cases}$$
Ok, I know the derivative of $f$ and it is $2x\cos(\frac{1}{x})+\sin(\frac{1}{x})$. My question is, am I only supposed to find the derivative here or evaluate this at $0$? I mean what exactly is the reason behind this piecewise function if I don't evaluate this at $0$? Does it make sense? Also, when a question says to find out whether or not $f$ is differentiable for a piecewise function like this, what are we supposed to do, find $f'(x)$ or evaluate at $f'(0)$? I am sorry if these are very elementary level questions. But, I always get confused on terms like these. Any explanation would be much appreciated. Thanks. 

Notice, Using first principle $$f'(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$ $$\implies f'(x)=\lim_{h\to 0}\frac{(x+h)^2\cos\left(\frac{1}{x+h}\right)-x^2\cos\left(\frac{1}{x}\right)}{h}$$ It is clear from given data that function, $f(x)$ changes its definition at $x=0$, hence to check the differentiability of function $f(x)$ at $x=0$, let's calculate the left hand derivative (LHD) & the right hand derivative (RHD) at $x=0$ as follows $$\implies LHD=\lim_{h\to 0^{-}}\frac{(0+h)^2\cos\left(\frac{1}{0+h}\right)-(0)^2\cos\left(\frac{1}{0}\right)}{h}$$ $$=\lim_{h\to 0^{-}}\frac{h^2\cos\left(\frac{1}{h}\right)}{h}=\lim_{h\to 0^{-}}h\cos\left(\frac{1}{h}\right)$$$$=\lim_{h\to 0}(-h)\cos\left(\frac{1}{-h}\right)=-\lim_{h\to 0}h\cos\left(\frac{1}{h}\right)=0$$  $$\implies RHD=\lim_{h\to 0^{+}}\frac{(0+h)^2\cos\left(\frac{1}{0+h}\right)-(0)^2\cos\left(\frac{1}{0}\right)}{h}$$ $$=\lim_{h\to 0^{+}}\frac{h^2\cos\left(\frac{1}{h}\right)}{h}=\lim_{h\to 0^{+}}h\cos\left(\frac{1}{h}\right)$$$$=\lim_{h\to 0}(h)\cos\left(\frac{1}{h}\right)=0$$   Thus, we find that $LHD=RHD=0$, hence function $f(x)$ is differentiable at $x=0$, we have $$f'(0)=0$$
While, $f'(x)$ for $x\neq 0$ can be simply determined using product rule as follows $$f'(x)=\frac{d}{dx}\left(x^2\cos\left(\frac{1}{x}\right)\right)$$ $$=2x\cos\left(\frac{1}{x}\right)-x^2\sin\left(\frac{1}{x}\right)\left(\frac{-1}{x^2}\right)$$ $$=2x\cos\left(\frac{1}{x}\right)+\sin\left(\frac{1}{x}\right)$$
