# Derive the divergence formula for spherical coordinates

hover

## Homework Statement

The formula for divergence in the spherical coordinate system can be defined as follows:

$\nabla\bullet\vec{f} = \frac{1}{r^2} \frac{\partial}{\partial r} (r^2 f_r) + \frac{1}{r sinθ} \frac{\partial}{\partial θ} (f_θ sinθ) + \frac{1}{r sinθ}\frac{\partial f_\phi}{\partial \phi}$

where $\vec{f} = f_r \widehat{r} + f_θ \widehat{θ} + f_\phi \widehat{\phi}$

Derive the divergence formula for the spherical coordinate system.

## Homework Equations

One way to define divergence is as follows:

$\nabla\bullet\vec{f} = \lim_{volume\rightarrow 0} \frac{flux \space through \space the \space volume}{volume}$

Volume in spherical coordinates can be defined as follows:

$V = volume = r^2 sin(θ) Δθ Δ\phi Δr$

## The Attempt at a Solution

Just before you read into my solution, I do successfully derive the divergence formula. I am questioning if my methodology is correct though. Without further ado here is my attempted solution.

I first write the basic formula from part 2 down:

$\nabla\bullet\vec{f} = \lim_{V\rightarrow 0}\frac{\hat{dS_r}\bullet\vec{f} + \hat{dS_θ} \bullet\vec{f} + \hat{dS_\phi} \bullet\vec{f}}{V}$

I fill in all the dS vectors:

$= \lim_{V\rightarrow 0}\frac{\hat{r} r^2 sinθ Δθ Δ\phi \bullet\vec{f} + \hat{θ} r sinθ Δr Δ\phi \bullet\vec{f} + \hat{\phi} r Δr Δθ \bullet\vec{f}}{V}$

I apply all dot products:

$= \lim_{V\rightarrow 0}\frac{r^2 sinθ Δθ Δ\phi f_r + r sinθ Δr Δ\phi f_θ + r Δr Δθ f_\phi}{V}$

I take the volume formula from part 2 and put it in the denominator:

$= \lim_{V\rightarrow 0}\frac{r^2 sinθ Δθ Δ\phi f_r + r sinθ Δr Δ\phi f_θ + r Δr Δθ f_\phi}{r^2 sin(θ) Δθ Δ\phi Δr}$

I cancel like terms with each other:

$= \lim_{V\rightarrow 0}\frac{1}{r^2 Δr} (r^2 f_r) + \frac{1}{r sinθ Δθ} (f_θ sinθ) + \frac{1}{r sinθ Δ\phi} (f_\phi)$

I apply the limit which makes any part of the volume formula become extremely small:

$= \frac{1}{r^2}\frac{∂}{∂r} (r^2 f_r) + \frac{1}{r sinθ} \frac{∂}{∂θ} (f_θ sinθ) + \frac{1}{r sinθ} \frac{∂}{∂ \phi}(f_\phi)$

This solution I found definitely matches the formula for divergence is spherical coordinates. I guess my question is is my methodology for solving this problem ok??

Thanks,
hover

Jolb
I don't think your solution makes any sense. Your first equation in your "attempt at solution" does not express the real definition of divergence. I think you might be confused by
One way to define divergence is as follows:

$\nabla\bullet\vec{f} = \lim_{volume\rightarrow 0} \frac{flux \space through \space the \space volume}{volume}$
"Flux through a volume" is not a normally used phrase. Surfaces can have flux through them, but a volume has a closed surface so you have to be careful about what you mean by this. Divergence is the limit [as volume approaches zero] of the net flux going out of the volume. So for example, if the volume was a small cube, a flux going rightward into the left side of the cube would have to be subtracted from the flux going rightward out of the right side of the cube.

$\nabla\bullet\vec{f} = \lim_{V\rightarrow 0}\frac{\hat{dS_r}\bullet\vec{f} + \hat{dS_θ} \bullet\vec{f} + \hat{dS_\phi} \bullet\vec{f}}{V}$
So you have a problem with this equation. It is only basically looking at the flux through one half the surface of your volume. You need to subtract flux on one side of the volume from the other side--just like with any derivative you're looking at differences between nearby points.

Also, the step you take between your second to last and last equations is not even remotely correct. You can't turn a 1/Δx into ∂/∂x the way you've written. If you do it correctly, remembering you want to be subtracting something in the numerator of those terms you have in the second to last equation, you should end up with something like Δf/Δx which you are allowed to turn into ∂f/∂x.

Last edited:
Gold Member
2021 Award
The idea is, however, correct.

You can apply
$$\int_{\Delta V} \mathrm{d}^3 \vec{x} \; \vec{\nabla} \cdot \vec{f} = \int_{\partial \Delta V} \mathrm{d}^2 \vec{A} \cdot \vec{f}$$
to an infinitesimal volume $\Delta V$ spanned by coordinate lines.

On the left-hand side you can just take $\vec{\nabla} \cdot{\vec{f}} \, \Delta V$. On the right-hand side, you must be a bit more careful and have to apply the changes of the arguments of $\vec{f}$ on the 6 surfaces into account. Only then all three differentials in the volume element can be cancelled, and only then you get the correct formula for the divergence in spherical coordinates, which is correctly given in your problem statement.

hover
OK! Both of your analyses of my solution make sense and I think I understand why it is lacking. This is why I posted my first solution here because, while I did get the right answer, some of the steps in my first solution felt forced. Let me repost my refined solution now.

## Homework Equations

One way to define divergence is as follows:

$\nabla\bullet\vec{f} = \lim_{volume\rightarrow 0} \frac{flux \space through \space surface \space areas}{volume}$

Volume in spherical coordinates can be defined as follows:

$V = volume = r^2 sin(θ) Δθ Δ\phi Δr$

## The Attempt at a Solution

I first write the basic formula from part 2 down. The change that is made in this first step is that I write the flux going through ALL surface areas:

$\nabla\bullet\vec{f} = \lim_{V\rightarrow 0}\frac{\hat{dS_r}\bullet\vec{f}(R+Δr,θ,\phi) -\hat{dS_r}\bullet\vec{f}(R,θ,\phi) + \hat{dS_θ} \bullet\vec{f}(r,\Theta+Δθ,\phi) - \hat{dS_θ} \bullet\vec{f}(r,\Theta,\phi) + \hat{dS_\phi} \bullet\vec{f}(r,θ,\Phi+Δ\phi) - \hat{dS_\phi} \bullet\vec{f}(r,θ,\Phi)}{V}$

I fill in all the dS vectors:

$= \lim_{V\rightarrow 0}\frac{\hat{r} (r+Δr)^2 sinθ Δθ Δ\phi\bullet\vec{f}(R+Δr,θ,\phi) -\hat{r} r^2 sinθ Δθ Δ\phi\bullet\vec{f}(R,θ,\phi) + \hat{θ} r sin(θ+Δθ) Δr Δ\phi \bullet\vec{f}(r,\Theta+Δθ,\phi) - \hat{θ} r sinθ Δr Δ\phi \bullet\vec{f}(r,\Theta,\phi) + \hat{\phi} r Δr Δθ \bullet\vec{f}(r,θ,\Phi+Δ\phi) - \hat{\phi} r Δr Δθ \bullet\vec{f}(r,θ,\Phi)}{V}$

I apply all dot products:

$= \lim_{V\rightarrow 0}\frac{(r+Δr)^2 sinθ Δθ Δ\phi f_r(R+Δr,θ,\phi) -r^2 sinθ Δθ Δ\phi f_r(R,θ,\phi) + r sin(θ+Δθ) Δr Δ\phi f_θ(r,\Theta+Δθ,\phi) - r sinθ Δr Δ\phi f_θ(r,\Theta,\phi) + r Δr Δθ f_\phi(r,θ,\Phi+Δ\phi) - r Δr Δθ f\phi(r,θ,\Phi)}{V}$

I take the volume formula from part 2 and put it in the denominator:

$= \lim_{V\rightarrow 0}\frac{(r+Δr)^2 sinθ Δθ Δ\phi f_r(R+Δr,θ,\phi) -r^2 sinθ Δθ Δ\phi f_r(R,θ,\phi) + r sin(θ+Δθ) Δr Δ\phi f_θ(r,\Theta+Δθ,\phi) - r sinθ Δr Δ\phi f_θ(r,\Theta,\phi) + r Δr Δθ f_\phi(r,θ,\Phi+Δ\phi) - r Δr Δθ f\phi(r,θ,\Phi)}{r^2 sin(θ) Δθ Δ\phi Δr}$

I cancel like terms with each other:

$= \lim_{V\rightarrow 0}\frac{1}{r^2 Δr} ((r+Δr)^2 -r^2) (f_r(R+Δr,θ,\phi) - f_r(R,θ,\phi))) + \frac{1}{r sinθ Δθ} ((sin(θ+Δθ) - sinθ)(f_θ(r,\Theta+Δθ,\phi) - f_θ(r,\Theta,\phi))) + \frac{1}{r sinθ Δ\phi} (f_\phi(r,θ,\Phi+Δ\phi) - f_\phi(r,θ,\Phi))$

In this new step, I slightly rewrite the equation to make it obvious that this equation is full of definitions of derivatives.

$= \lim_{V\rightarrow 0}\frac{1}{r^2} \frac{((r+Δr)^2 -r^2) (f_r(R+Δr,θ,\phi) - f_r(R,θ,\phi))}{Δr} + \frac{1}{r sinθ} \frac{(sin(θ+Δθ) - sinθ)(f_θ(r,\Theta+Δθ,\phi) - f_θ(r,\Theta,\phi))}{Δθ} + \frac{1}{r sinθ} \frac{(f_\phi(r,θ,\Phi+Δ\phi) - f_\phi(r,θ,\Phi))}{Δ\phi}$

When I apply the limit, it makes any part of the volume formula become extremely small. This means that Δr, Δθ and Δ$\phi$ approach 0:

$= \frac{1}{r^2}\frac{∂}{∂r} (r^2 f_r) + \frac{1}{r sinθ} \frac{∂}{∂θ} (f_θ sinθ) + \frac{1}{r sinθ} \frac{∂}{∂ \phi}(f_\phi)$

End of solution.

This new solution makes more sense than my last one and doesn't seem as forced. Does it look ok to you guys?

Thanks,
hover

Jolb
I take the volume formula from part 2 and put it in the denominator:

$= \lim_{V\rightarrow 0}\frac{(r+Δr)^2 sinθ Δθ Δ\phi f_r(R+Δr,θ,\phi) -r^2 sinθ Δθ Δ\phi f_r(R,θ,\phi) + r sin(θ+Δθ) Δr Δ\phi f_θ(r,\Theta+Δθ,\phi) - r sinθ Δr Δ\phi f_θ(r,\Theta,\phi) + r Δr Δθ f_\phi(r,θ,\Phi+Δ\phi) - r Δr Δθ f\phi(r,θ,\Phi)}{r^2 sin(θ) Δθ Δ\phi Δr}$

I cancel like terms with each other:

$= \lim_{V\rightarrow 0}\frac{1}{r^2 Δr} ((r+Δr)^2 -r^2) (f_r(R+Δr,θ,\phi) - f_r(R,θ,\phi))) + \frac{1}{r sinθ Δθ} ((sin(θ+Δθ) - sinθ)(f_θ(r,\Theta+Δθ,\phi) - f_θ(r,\Theta,\phi))) + \frac{1}{r sinθ Δ\phi} (f_\phi(r,θ,\Phi+Δ\phi) - f_\phi(r,θ,\Phi))$

Now you are on the right track but I believe you have an algebraic mistake going between the two lines in the quote above. You factored things in a way that introduces some cross terms that shouldn't be there. For example
(r+Δr)2fR(r+Δr)-r2fR(r) ≠ ((r+Δr)2-r2)(fR(r+Δr)-fR(r))
since the right hand expression would have cross terms not in the left hand side. [Also, the RHS gives the wrong sign on one of the terms you do want.]

Instead you want to identify derivatives like [(r+Δr)2fR(r+Δr) - r2fR(r)]/Δr = ∂/∂r [r2fR]

Last edited:
• 1 person
hover
Now you are on the right track but I believe you have an algebraic mistake going between the two lines in the quote above. You factored things in a way that introduces some cross terms that shouldn't be there. For example
(r+Δr)2fR(r+Δr)-r2fR(r) ≠ ((r+Δr)2-r2)(fR(r+Δr)-fR(r))
since the right hand expression would have cross terms not in the left hand side. [Also, the RHS gives the wrong sign on one of the terms you do want.]

Instead you want to identify derivatives like [(r+Δr)2fR(r+Δr) - r2fR(r)]/Δr = ∂/∂r [r2fR]
Oh! Actually that makes perfect sense! A little while afterward I thought about the new solution I wrote down and saw that if the limit of (r+Δr)^2-r^2)/Δr is taken, you get 2r which isn't apart of the derived solution. The same thing can be said for the second term dealing with θ. Like you said, it really just is a simple algebraic mistake. I think I keep skipping a few steps because I know what I want to achieve. Well that and writing in Latex here and checking what is written over and over can be a lot of work with equations like these so I guess I was bound to overlook some error at some point.

It does make sense though and if I fix this simple algebraic error then I do believe that I have a correct derivation for divergence in spherical coordinates.

Thanks!!! 