Gradient of modulus of vector. I came across this in my lecture notes:

This is using index notation, non-bold r is the modulus of r, and the partials are with respect to the components of r.
I understand most of the steps, but I don't understand how they get from $$\partial_i \sqrt{r_j r_j}$$ to $$\frac{(\partial_i r_j)r_j}{\sqrt{r_j r_j}}$$
Can anybody help?
 A: Let's limit ourselves to 2 dimensions.
Then:
$$ \partial_1 \sqrt{r_jr_j} = \frac{\partial}{\partial x} \sqrt{x^2+y^2}
= \frac{1}{2\sqrt{x^2+y^2}}\cdot \frac{\partial}{\partial x}(x^2+y^2) 
= \frac{x(\partial_x x)}{\sqrt{x^2+y^2}} = \frac{(\partial_1 r_j)r_j}{\sqrt{r_jr_j}}
$$
A: This is just the chain rule.
\begin{equation}
\partial_{i} \sqrt{r_jr_j} = \tfrac{1}{2}(r_jr_j)^{-\tfrac{1}{2}}((\partial_ir_j)r_j+r_j(\partial_ir_j)) = \frac{(\partial_ir_j)r_j}{\sqrt{r_jr_j}}
\end{equation}
A: It's just the chain rule, but the index notation used obscures it. A big thing to note is that the implied summation over $r_j$ is within the square root rather than not a sum over the square roots.
To make the algebra more familiar let $u=\sum_j r_j r_j$ and write everything explicitly:$$\frac{\partial}{\partial x_i} (u^{1/2})=\frac{\partial u}{\partial x_i}\frac{d}{du}(u^{1/2})=\frac{1}{2u^{1/2}}\frac{\partial u}{\partial x_i}=\frac{1}{2u^{1/2}}\frac{\partial }{\partial x_i}\sum_j r_j r_j=\frac{1}{2u^{1/2}}\cdot 2r_j\frac{\partial r_j}{\partial x_i}=\frac{r_j}{u^{1/2}}\frac{\partial r_j}{\partial x_i}$$
In index notation, this is rendered as $\partial_i \sqrt{r_j r_j}=\dfrac{\partial_i (r_j r_j)}{2\sqrt{r_j r_j}}=\dfrac{(\partial_i r_j) r_j}{\sqrt{r_j r_j}}$. The only difference in meaning is that I'm leaving a lot more things implicit in this version, including the use of $u$.
