# Showing a Function is Both Continuous and Differentiable

So, I'm given: $$f(x) = \left\{\begin{array}{ll} x^2\sin\left(\frac{1}{x}\right) & \mbox{if x\neq 0,}\\ 0 &\mbox{if x=0.} \end{array}\right.$$

I'm asked to show that this piecewise function is both continuous and differentiable on the real number line.

I'm not sure how to state what I know, i.e. that since $x^2$ and $\sin(1/x)$ are both continuous and differentiable on their domains, the product is also continuous and differentiable (on their domains where obviously $\sin(1/x)$ can't have $x = 0$.) But that case is covered since $f(x) = 0$ when $x = 0$.

I guess I just to know how I would state all that in a mathematically accurate fashion.

Any assistance is greatly appreciated.

Differentiability at a point implies continuity at that point. Since $\sin$ is differentiable, $1/x$ is differentiable, $x$ is differentiable, compositions of differentiable functions are differentiable, and products of differentiable functions are differentiable, it follows that $f$ is differentiable at each nonzero point. To show that $f$ is differentiable at $0$, compute $f'(0)$ using the definition of the derivative. Once you know this exists, you'll know that $f$ is differentiable, and hence continuous, on all of the real number line.
use the definition of differentiability, say at 0: $$\lim_{x\to0}\frac{f(x)-f(0)}{x-0}=\lim_{x\to0}\frac{x^2\sin(1/x)}{x}=\lim_{x\to0}\ x\sin(1/x)=0$$ where the last step can be justified various ways. for instance $|x\sin(1/x)|\leq|x|$.