<s>[INST] Dot product with a scalar function Example 5: Find $\nabla\cdot\left(\frac{\boldsymbol r}{r^2}\right)$ where $\boldsymbol r(x,y,z)=x\boldsymbol i+y\boldsymbol j+z\boldsymbol k$, $r=\sqrt{x^2+y^2+z^2}$.
In this case, why can we not bring the scalar function $r^{-2}$ outside the dot product? 
When I leave the function in place, I calculate a result of $\frac{1}{r^{2}}$. When I pull it out, I find $\frac{3}{r^{2}}$.
 [/INST] $$\nabla \cdot \left( \frac{\vec{r}}{r^2} \right) = \nabla \cdot \left( \frac{x}{x^2+y^2+z^2}\vec{i} + \frac{y}{x^2+y^2+z^2}\vec{j} + \frac{z}{x^2+y^2+z^2}\vec{k} \right) \\ = \frac{y^2+z^2-x^2}{(x^2+y^2+z^2)^2} + \frac{x^2+z^2-y^2}{(x^2+y^2+z^2)^2} + \frac{x^2+y^2-z^2}{(x^2+y^2+z^2)^2} = \frac{x^2+y^2+z^2}{(x^2+y^2+z^2)^2} \\ = \frac{1}{x^2+y^2+z^2} = \frac{1}{r^2}.$$
</s>