Why does $ \frac{\partial r_i}{\partial r_j} \neq \frac{\partial r_i}{\partial r}\frac{\partial r}{\partial r_j} $ for $ i, j \in \{x,y,z\} $? I have a function f(r) that depends only on the distance from the origin. I need to find $ \frac{\partial^2 f}{\partial r_i \partial r_j} $ where $ i, j \in \{x,y,z\} $; in other words, I need to find 
$ \begin{bmatrix}
\frac{\partial^2}{{\partial x}^2} & \frac{\partial^2}{\partial y \partial x} & \frac{\partial^2}{\partial z \partial x} \\ \frac{\partial^2}{\partial x \partial y}
 & \frac{\partial^2}{{\partial y}^2} & \frac{\partial^2}{\partial z \partial y}\\ 
 \frac{\partial^2}{\partial x \partial z} & \frac{\partial^2}{\partial y \partial z} & \frac{\partial^2}{{\partial z}^2}
\end{bmatrix} f $.
I apply the chain rule 
$ \frac{\partial f}{\partial r_i} = \frac{\partial f}{\partial r}\frac{\partial r}{\partial r_i} $ 
and again
$ \frac{\partial^2 f}{\partial r_i \partial r_j} = \frac{\partial}{\partial r}(\frac{\partial f}{\partial r_i})\frac{\partial r}{\partial r_j} $. 
These leave me with a cross term $ \frac{\partial r_i}{\partial r}\frac{\partial r}{\partial r_j} $. Now I have a choice:


*

*Evaluate $ \frac{\partial r}{\partial r_i} = \frac{r_i}{r} $ and $ \frac{\partial r_j}{\partial r} = (\frac{\partial r_j}{\partial r})^{-1}  = \frac{r}{r_j} $ right away, leaving me with $ \frac{\partial r_i}{\partial r}\frac{\partial r}{\partial r_j} = \frac{r_j}{r_i} $ .

*Cancel the $ \partial r $'s, leaving me with $ \frac{\partial r_i}{\partial r}\frac{\partial r}{\partial r_j} = \frac{\partial r_i}{\partial r_j} = \delta_{ij} $ . 
As far as I can tell, these two results are not equivalent. This comes from one of those "show this is true" homework problems, so I know the correct method is method 2. So what did I do wrong in method 1?
 A: $ \frac{\partial f}{\partial x_i} = \frac{\partial f}{\partial r} \cdot \frac{\partial r}{\partial x_i} \implies $ 
$ \frac{\partial^2 f}{\partial x_j \partial x_i} = \frac{\partial^2 f}{\partial r^2} \cdot \frac{\partial r}{\partial x_j} \cdot \frac{\partial r}{\partial x_i} + \frac{\partial f}{\partial r} \cdot \frac{\partial^2 r}{\partial x_j \partial  x_i} $ 
The cross term you refer to : $ \frac{\partial r}{\partial x_j} \cdot \frac{\partial r}{\partial x_i} $ is actually just the product of two partial derivatives:
$r=\sqrt {x_1^2 + x_2^2 + x_3^2 } \implies \text{ for instance } \implies \frac{\partial r}{\partial x_1} \cdot \frac{\partial r}{\partial x_2} = \frac{x_1}{r}\cdot\frac{x_2}{r}  =\frac{x_1x_2}{r^2} $ so no ambiguity there.
The other term: 
$ \frac{\partial^2 r}{\partial x_j \partial x_i}  \implies \text{ for instance } \implies  \frac{\partial^2 r}{\partial x_1 \partial  x_2}=\frac{\partial (\frac{x_2}{r}) }{\partial x_1  } =-\frac{x_1x_2}{r^3}$ or : $  \frac{\partial^2 r}{\partial x_1^2}=\frac{\partial (\frac{x_1}{r}) }{\partial x_1  } =\frac{1}{r} -\frac{x_1^2}{r^3} $.

$ \frac{\partial^2 f}{\partial x_j \partial x_i} =  \frac{x_ix_j}{ r^2}\frac{\partial^2 f}{\partial r^2} + (\frac{\delta_{ij}}{ r}  - \frac{ x_ix_j}{ r^3}  )\frac{\partial f}{\partial r}    $

