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.

  • 1
    $\begingroup$ 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$. $\endgroup$ Jun 6, 2016 at 13:58
  • $\begingroup$ @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}$$ $\endgroup$
    – bluemoon
    Jun 6, 2016 at 14:02
  • $\begingroup$ @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$? $\endgroup$
    – bluemoon
    Jun 6, 2016 at 14:03
  • $\begingroup$ 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. $\endgroup$ Jun 6, 2016 at 14:06
  • $\begingroup$ @Semiclassical The task is to do it in spherical coordinates because it is supposed to be "much easier" according to our tutor. $\endgroup$
    – bluemoon
    Jun 6, 2016 at 14:08

2 Answers 2


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

  • $\begingroup$ 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)$. $\endgroup$
    – Winther
    Jun 6, 2016 at 19:04
  • $\begingroup$ You're right, that's what I've mentioned for $n$-dimensional case in math.stackexchange.com/questions/1751963/… $\endgroup$ Jun 6, 2016 at 19:11
  • $\begingroup$ @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. $\endgroup$
    – bluemoon
    Jun 7, 2016 at 8:39
  • $\begingroup$ @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? $\endgroup$
    – bluemoon
    Jun 7, 2016 at 8:43
  • $\begingroup$ @bluemoon That's hybrid. In pure Cartesian, it should read $-GMm\frac{(x,y,z)}{(x^2+y^2+z^2)^{3/2}}$ $\endgroup$ Jun 7, 2016 at 13:32

$\newcommand{\angles}[1]{\left\langle\,{#1}\,\right\rangle} \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace} \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack} \newcommand{\dd}{\mathrm{d}} \newcommand{\ds}[1]{\displaystyle{#1}} \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,} \newcommand{\half}{{1 \over 2}} \newcommand{\ic}{\mathrm{i}} \newcommand{\iff}{\Longleftrightarrow} \newcommand{\imp}{\Longrightarrow} \newcommand{\Li}[1]{\,\mathrm{Li}} \newcommand{\ol}[1]{\overline{#1}} \newcommand{\pars}[1]{\left(\,{#1}\,\right)} \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\ul}[1]{\underline{#1}} \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,} \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}} \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$ \begin{align} \color{#f00}{-\nabla\cdot\pars{{1 \over r^{2}}\,{\vec{r} \over r}}} & = -\nabla\cdot\nabla\pars{-\,{1 \over r}} = \nabla^{2}\pars{1 \over r} = \color{#f00}{-4\pi\, \delta\pars{\vec{r}}} \\[5mm] \mbox{because}\ \color{#f00}{\int_{V} \bracks{-\nabla\cdot\pars{{1 \over r^{2}}\,{\vec{r} \over r}}}\dd^{3}\vec{r}} & = -\int_{S}{1 \over r^{2}}\,{\vec{r} \over r}\cdot\dd\vec{\mathsf{S}} = -\int\dd\Omega_{\vec{r}} = \color{#f00}{-4\pi}\,,\qquad\vec{0} \in V \end{align}


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .