<s>[INST] Question about divergence of $\vec{F} = \frac{1}{r^2} \hat{r}$ I am looking at the divergence of this famous expression:
$\vec{F} = \frac{1}{r^2} \hat{r}$
i saw this calculation which looks reasonable ...
$\hat{r} = (x,y,z)/\sqrt{x^2 + y^2 + z^2}$
$$
F(x,y,z) = \frac{1}{(x^2 + y^2 + z^2)^{3/2}} (x,y,z) \\
\frac{\partial}{\partial x} F_x = \frac{\partial}{\partial x} \frac{x}{(x^2 + y^2 + z^2)^{3/2}} = \frac{-2x^2 + y^2 + z^2}{(x^2 + y^2 + z^2)^{5/2}} \\
\frac{\partial}{\partial y} F_y = \frac{\partial}{\partial y} \frac{y}{(x^2 + y^2 + z^2)^{3/2}} = \frac{x^2  -2y^2 + z^2}{(x^2 + y^2 + z^2)^{5/2}} \\
\frac{\partial}{\partial z} F_z = \frac{\partial}{\partial z} \frac{z}{(x^2 + y^2 + z^2)^{3/2}} = \frac{x^2 + y^2  -2z^2}{(x^2 + y^2 + z^2)^{5/2}} \\
$$
Putting together :
$$
\nabla\cdot F = \frac{\partial}{\partial x} F  + \frac{\partial}{\partial y} F + \frac{\partial}{\partial z} F = \frac{0}{(x^2 + y^2 + z^2)^{5/2}} = 0
$$
However I am confused about one thing.

*

*Suppose vector field $\vec{F}$ has a value $F_1$ at (1,1,1).


*Now if x changes by dx, that is x2 = 1+dx, y and z remaining unchanged,


*Then the change in x component vector F will be 0 since partial derivative of $\vec{F_x}$ w.r.t to x evaluates to 0. Similarly the change in y and z component will also be 0, since their partial derivatives also evaluate to 0 at (1,1,1).
This seems confusing to me. How can there be no change in the vector when x changes by dx, at (1,1,1) ?
What am I doing wrong ?
 [/INST] $
\def\l{\lambda}
\def\n{\nabla}
\def\L#1{\l^{-#1}}
\def\qiq{\quad\implies\quad}
\def\tr{\,{\rm Trace}}
\def\c#1{\color{red}{#1}}
$Differentiate the length $\l$ of the position vector $r$
$$\eqalign{
\l^2 &= r\cdot r \\
2\l\:d\l &= 2r\cdot dr \\
d\l &= \L1r\cdot dr \\
}$$
Then calculate the gradient of $F$
$$\eqalign{
F &= \L3r \\
dF &= \L3dr - r(3\L4d\l) \\
   &= \L3I\cdot dr - r(3\L5\,r\cdot dr) \\
   &= (\L3I - 3\L5rr)\cdot dr \\
\n F &= \L3I - 3\L5rr \\
}$$
Finally, calculate the divergence
$$\eqalign{
\n\cdot F &= \tr(\n F) \\
 &=  \L3\tr(I) - 3\L5\tr(rr) \\
 &=  \L3(n) - 3\L5(\l^2) \\
 &=  (n-3)\L3 \\
}$$
Therefore in three dimensions $(n=3)$ the divergence is equal to zero, but in any other dimension it is non-zero.
Note however, that the Taylor series at $r=r_1$  uses the gradient of $F\,$ not its divergence
$$\eqalign{
F(r_2) - F(r_1) &= (r_2 - r_1)\cdot\c{\n F(r_1)}
  \;+\; {\cal O}\left(\|r_2-r_1\|^2\right) \\
dF &\approx dr\cdot\c{(\L3I - 3\L5r_1r_1)} \\
dF &\approx \L3dr - 3\L5(dr\cdot r_1)\,r_1 \\
}$$
So the change in the function value is $dF$ which (as you suspected) is not equal to zero.
</s>