Partial derivatives of a piecewise function with trigonometric functions 
Let $f:\mathbb{R}^n \to \mathbb{R}$ and $$f(x) = \left\{
\begin{array}{ll}
      ||x||^2\sin(\frac{1}{||x||}), & x\ne0 \\
      0, & x =0 \\
\end{array} 
\right.$$ Determine the partial derivatives of $f$ and show that each one of them is discontinuous at the origin.

This seemed a bit weird since we have it from $\mathbb{R^n} \to \mathbb{R}$. My initial assumption was that I could just do it by components of the vector $x$ like this $$\frac{\partial}{\partial x_j} = 2||x_j||\sin(\frac{1}{||x_j||})-\cos(\frac{1}{||x_j||})$$ and then since the $\sin$ and $\cos$ both diverge the limits at $0$ are not equal. Is this the way or am I missing something?
 A: The partial derivatives wrt $x_i$ is computed by the chain rule, first we have
$$
\frac{\partial}{\partial x_i}\| x \| = \frac{x_i}{\| x \|}
$$
that means for $\|x\| \ne 0$ the partial derivatives are
$$
\frac{\partial}{\partial x_i} f = \left(\frac{\partial}{\partial \| x \|} f\right) \frac{\partial}{\partial x_i}\| x \|= \left(2\| x \|\sin(\frac{1}{\|x\|})-\cos(\frac{1}{\|x\|})\right)\frac{x_i}{\| x \|} \\
= 2 x_i \sin(\frac{1}{\|x\|})-\frac{x_i}{\| x \|}\cos(\frac{1}{\|x\|}) \\
$$
the first term has $0$ as limit at zero along the $x_i$. But the second term along the $x_i$ axis has no limit at all at zero, because it vibrates infinitely rapidly with nonzero amplitude. From the last observation only it is clear that the partial derivative is not continuous.
At $x=0$ the partial derivatives should be computed as follows
$$
\frac{\partial}{\partial x_i} f = \lim_{h\to 0} \frac{f(0+he_i) - f(0)}{h-0}\\
\lim_{h\to 0} \frac{\|0+he_i\|^2\sin\frac{1}{\|0+he_i\|} - 0}{h-0} \\
\lim_{h\to 0} \frac{h^2\sin\frac{1}{h}}{h} = \lim_{h\to 0} (h\sin\frac{1}{h}) = 0
$$
where $e_i$ is the relevant standard basis vector. So that means that the $\frac{\partial}{\partial x_i} f = 0$ at $x=0$ but its limit as $\|x\| \to 0$ does not exist, so it is not continuous.
A: In fact you computed $\frac{\partial f }{\partial ||x||}$, so you must complete it by chain rule as @Physor explained.
