Problem with an Hessian matrix having a vectorial function 
Let be $$f(x)= |x-x_0| \mbox{ } \forall x \in \mathbb{R}^n \setminus \{x_0 \} $$ Calculate the Hessian Matrix $\forall x \in \mathbb{R}^n \setminus \{x_0 \}$

My work:
$$Df(x)= \frac{x-x_0}{|x-x_0|}$$ This is a vector with $n$ elements. 
Now $$\frac{\partial^2 f}{\partial x_i^2}=\frac{|x_i-x_{0_i}|^2-(x_i-x_{0_i})}{|x_i-x_{0_i}|^3}$$ and i think but i'm not sure that $$\frac{\partial^2 f}{\partial x_i \partial x_j}=0$$ so $$D^2f(x)=\frac{|x-x_0|^2-(x-x_0)}{|x-x_0|^3}I$$ 
The solution of this exercize is:
$$D^2f(x)=\frac{1}{|x-x_0|^3}(|x-x_0|^2I+(x-x_0) \otimes (x-x_0))$$ Can someone help me where is the mistake? I'm not good with tensorial notation. Can someone help me considering member by member?
 A: For clarity, I call $a=x_0\in\mathbb{R}^n$.
Let us choose the euclidian norm
$$\|x-a\|=\sqrt{\sum_{k=0}^{n}\left(x_k-a_k\right)^2}.$$
We have
$$\frac{\partial f}{\partial x_k}(x)=\frac{x_k-a_k}{\|x-a\|}\quad\quad\quad\forall 1\leq k\leq n.$$
Now we compute the second order partial derivatives :
$$\frac{\partial^2 f}{\partial x_k^2}(x)
=\frac{1}{\|x-a\|}-\frac{x_k-a_k}{\|x-a\|^2}\cdot\frac{\partial f}{\partial x_k}(x)=\frac{1}{\|x-a\|}-\frac{\left(x_k-a_k\right)^2}{\|x-a\|^3}
\quad\quad\quad\forall 1\leq k\leq n,$$
$$\frac{\partial^2 f}{\partial x_kx_\ell}(x)
=-\frac{x_k-a_k}{\|x-a\|^2}\cdot\frac{\partial f}{\partial x_\ell}(x)=-\frac{\left(x_k-a_k\right)\left(x_\ell-a_\ell\right)}{\|x-a\|^3}\quad\quad\quad\forall 1\leq k,\ell\leq n,k\neq\ell.$$
Hence, the Hessian matrix at $x\in\mathbb{R}^n\setminus\{a\}$ is
$$\mathrm{H}\left(f\right)(x)=\frac{1}{\left\Vert x-a\right\Vert }\begin{pmatrix}1-\frac{\left(x_{1}-a_{1}\right)^{2}}{\left\Vert x-a\right\Vert ^{2}} & -\frac{\left(x_{1}-a_{1}\right)\left(x_{2}-a_{2}\right)}{\left\Vert x-a\right\Vert ^{2}} & \cdots & -\frac{\left(x_{1}-a_{1}\right)\left(x_{n}-a_{n}\right)}{\left\Vert x-a\right\Vert ^{2}}\\
-\frac{\left(x_{1}-a_{1}\right)\left(x_{2}-a_{2}\right)}{\left\Vert x-a\right\Vert ^{2}} & 1-\frac{\left(x_{2}-a_{2}\right)^{2}}{\left\Vert x-a\right\Vert ^{2}} & \cdots & -\frac{\left(x_{2}-a_{2}\right)\left(x_{n}-a_{n}\right)}{\left\Vert x-a\right\Vert ^{2}}\\
\vdots & \vdots & \ddots & \vdots\\
-\frac{\left(x_{1}-a_{1}\right)\left(x_{n}-a_{n}\right)}{\left\Vert x-a\right\Vert ^{2}} & -\frac{\left(x_{2}-a_{2}\right)\left(x_{n}-a_{n}\right)}{\left\Vert x-a\right\Vert ^{2}} & \cdots & 1-\frac{\left(x_{n}-a_{n}\right)^{2}}{\left\Vert x-a\right\Vert ^{2}}
\end{pmatrix}.$$
A: You can very quickly determine that $$\frac{\partial^2 f}{\partial x_i\partial x_j}$$
is not equal to $0$. Since you know that $$\frac{\partial f}{\partial x_i} = \frac{x_i - x_i^{(0)}}{||x-x_0||}$$
(where $x_i^{(0)}$ is the $i$-th element of $x_0$), you know that 
$$\frac{\partial^2 f}{\partial x_i\partial x_j} = \frac{\partial}{\partial x_j}\left(\frac{x_i - x_i^{(0)}}{||x-x_0||}\right)$$
Now, since the function $$F_j(x) = \frac{x_i - x_i^{(0)}}{||x-x_0||}$$
is not independent from $x_j$ (this should be obvious), its derivative is most certainly not equal to $0$.
You can calculate the derivative since it is not that complicated. The function is actually equal to 
$$\frac{x_i - x_i^{(0)}}{\sqrt{A + (x_j-x_j^{(0)})^2}}$$ where $A$ is independent of $x_j$.
