# Calculating the divergence of the Gravitational field $\nabla \cdot \vec{F}$

I want to calculate the divergence of the Gravitational field: $$\nabla\cdot \vec{F}=\nabla\cdot\left( -\frac{GMm}{\lvert \vec{r} \rvert^2} \hat{e}_r\right )$$ in spherical coordinates.

I know that in spherical coordinates: \begin{aligned} & x=r \sin\theta \cos \phi \\&y=r\sin\theta \sin \phi \\& z=r\cos\theta \end{aligned}

and the unit vector are:

\begin{aligned} & e_r=\begin{pmatrix}\sin\theta\cos\phi\\\sin\theta \sin\phi\\\cos\theta \end{pmatrix} \\ & e_{\theta}=\begin{pmatrix}\cos\theta\cos\phi\\\cos\theta \sin\phi\\-\sin\theta \end{pmatrix}\\&e_{\phi}=\begin{pmatrix}-\sin\phi\\\cos\phi\\0\end{pmatrix}\end{aligned}

Now I need to convert my original vector field into spherical coordinates (this is the part I am not really sure about):

$$\vec{F}=-\frac{GMm}{x^2+y^2+z^2} \hat{e}_x-\frac{GMm}{x^2+y^2+z^2} \hat{e}_y-\frac{GMm}{x^2+y^2+z^2} \hat{e}_z$$

transforming the coordinates: $x^2+y^2+z^2=(r\sin\theta\cos\phi)^2+(r\sin\theta\sin\phi)^2+(r\cos\theta)^2=r^2$

$$\implies\vec{F}=\frac{-GMm}{r^2}\left(\hat{e}_x +\hat{e}_y +\hat{e}_z \right )$$

How can I transform the unit vectors now? Do I just replace them by the spherical unit verctors?

Is there a short really cool way to calculate the divergence of this vector field? I know that the answer should be zero except at $r=0$ the divergence should be undefined.

• One obvious issue: Your initial $\vec{F}$ was spherically symmetric, but your final one is not! ($\hat{e}_x+\hat{e}_y+\hat{e}_z$ has a definite orientation.) The factor should actually be $\frac{x}{r}\hat{e}_x+\frac{y}{r}\hat{e}_y+\frac{z}{r}\hat{e}_z$ instead. Also, your initial vector field was basically in spherical coordinates already since $|\vec{r}|^2=r^2$. – Semiclassical Jun 6 '16 at 13:58
• @Semiclassical Yeah you are right. Because $$e_r=\frac{1}{\lvert r \rvert} \vec{r} \iff e_r=\frac{1}{\sqrt{x^2+y^2+z^2}} \begin{pmatrix}x \\ y \\ z \end{pmatrix} \\ \implies \frac{-GMm}{\lvert r\rvert ^3} \begin{pmatrix}x \\ y \\ z \end{pmatrix}$$ – bluemoon Jun 6 '16 at 14:02
• @Semiclassical But all my coordinates were not in spherical coordinates. Am I making this much harder than it actually is? When you write $\frac{x}{r}e_x+\frac{y}{r}e_y+\frac{z}{r}e_z$, are those $r$'s the absolute value of$\vec{r}$: $\lvert \vec{r} \rvert$? – bluemoon Jun 6 '16 at 14:03
• In your initial expression for $\vec{F}$, they certainly were all in spherical coordinates (once you replace $|\vec{r}|$ with $r$). What I'd suggest is computing the divergence in Cartesian coordinates (it'll be tedious but straightforward) using the last expression in your comment, and use that as a point of reference. – Semiclassical Jun 6 '16 at 14:06
• @Semiclassical The task is to do it in spherical coordinates because it is supposed to be "much easier" according to our tutor. – bluemoon Jun 6 '16 at 14:08

Since there's only $r$ dependence,

\begin{align*} \nabla \cdot \mathbf{F} &= \frac{1}{r^{2}} \frac{\partial}{\partial r} (r^{2} F_{r}) \\ &= \frac{1}{r^{2}} \frac{\partial}{\partial r} (-GMm) \\ &= 0 \end{align*}

for $\mathbf{r}\in \mathbb{R}^{3} \backslash \{ \mathbf{0} \}$.

May refer to this

• This does not apply at the origin $r=0$. If we had $\nabla\cdot \vec{F} = 0$ for all $r$ then by the divergence theorem and the fact that $\vec{F}$ is spherically symmetric we would have $\vec{F} = 0$ everywhere. A more precise statement is that $\nabla\cdot \left(\frac{\vec{r}}{r^3}\right) = 4\pi \delta(r)$. – Winther Jun 6 '16 at 19:04
• You're right, that's what I've mentioned for $n$-dimensional case in math.stackexchange.com/questions/1751963/… – Ng Chung Tak Jun 6 '16 at 19:11
• @NgChungTak Thank you for you answer and sorry for the late reply. I have two questions. You write in your answer: "since there is only $r$ dependence,...". But there is "only" $r$-dependence in cartesian coordinates right? If I transform the coordinates I will also have an angle dependence. – bluemoon Jun 7 '16 at 8:39
• @NgChungTak Second question: The real "comprehension problem" I have is the fact that I can't get why my original vector field: $$\frac{-GMm}{\lvert r\rvert^3}\begin{pmatrix}x\\y\\z\end{pmatrix}$$ is already in spherical coordinates (according to a comment by semiclassical). Isn't it the case that it is in cartesian coordinates. Why can I suddenly use the divergence in spherical coordinates and apply it to a vector field in cartesian coordinates? – bluemoon Jun 7 '16 at 8:43
• @bluemoon That's hybrid. In pure Cartesian, it should read $-GMm\frac{(x,y,z)}{(x^2+y^2+z^2)^{3/2}}$ – Ng Chung Tak Jun 7 '16 at 13:32
