# 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.

-
I have explained this as part of another answer over here. math.stackexchange.com/questions/21767/meaning-of-mathbfc0/… – user17762 Mar 10 '11 at 20:20
For future reference, $\neq$ is obtained by using \neq. – Arturo Magidin Mar 10 '11 at 20:39

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|$.