Continuity and derivative of a piecewise function $$f(x) =
\begin{cases}
x^2\sin(1/x),  & \text{if $x$ $\neq$ 0} \\
0, & \text{if $x$ = 0}
\end{cases}$$
Ok, as far as I know, to test if a function is continuous at $0$, the $\lim_{x \to 0} \ f(x) = f(0) $ has to exist if $x→0$ , this means that x is different than $0$ , so in this case $f(x)$ = $x^2\sin(1/x)$ , and the limit above exists and equals to $0$. (I think)
How do I derive a piecewise function? I though that i could derive $x^2\sin(1/x) $ after that, $0$. For example, the derivative of 
$$f(x) =
\begin{cases}
x,  & \text{if $x$ $≥$ 0} \\
-x, & \text{if $x$ < 0}
\end{cases}$$
would be 
$$f'(x) =
\begin{cases}
1,  & \text{if $x$ $≥$ 0} \\
-1, & \text{if $x$ < 0}
\end{cases}$$
and $f'(0)$ $= 1$, but this can't be right because the derivative of |x| at $0$ doesn't exist. (i hope I made myself clear with this example)
The exercise asks if the derivative at $0$ exists. Sorry if it caused confusion, i wanna know the derivative at $0$ to the first function and not the $|x|$.

In general when you want to find the derivative of a piece-wise  function, you evaluate the two pieces separately, and where they come together, if the function is continuous and the derivative of the left hand side equals the derivative of the right hand side, then you can say that the function is differentiable at that point.
i.e. if $f(x)$ is continous at $a$ and
$\lim_\limits{x\to a^+} \frac {f(x) - f(a)}{x-a} = \lim_\limits{x\to a^-} \frac {f(x) - f(a)}{x-a}$ then f(x) is differentiable at $a.$
To the problem at hand:
$f'(0) = \lim_\limits{x\to 0} \frac {f(x)-f(0)}{x-0}$
$-x^2\le f(x)\le x^2$
$-|x| <\frac {f(x)-f(0)}{x-0} < |x| $
and as $x$ goes to $0, f'(x)$ gets squeezed.
