# What is the error hiding in this trivial integral with spherical polar coordinates and divergence theorem?

I am working in spherical polar coordinates $$(r,\theta,\phi)$$ where $$\theta$$ and $$\phi$$ are the polar and azimuthal angles respectively. I define a vector field $$\mathbf{V}=\phi \hat{\boldsymbol{\phi}}$$, which has divergence $$\boldsymbol{\nabla}\cdot\mathbf{V}=\frac{1}{r^2}\frac{\partial}{\partial r}(0)+ \frac{1}{r\sin\theta}\frac{\partial}{\partial \theta}(0) + \frac{1}{r\sin\theta}\frac{\partial}{\partial \phi}(\phi) = \frac{1}{r\sin\theta} .$$

Also define $$u=e^{-r^2}$$, with gradient $$\boldsymbol{\nabla}u=\Bigg(\hat{\mathbf{r}}\frac{\partial}{\partial r} + \frac{1}{r}\hat{\boldsymbol{\theta}}\frac{\partial}{\partial \theta} + \frac{1}{r\sin\theta} \hat{\boldsymbol{\phi}} \frac{\partial}{\partial \phi}\Bigg) e^{-r^2} = -2r e^{-r^2} \hat{\mathbf{r}} .$$

Then I can write $$\boldsymbol{\nabla}\cdot(u\mathbf{V}) = u\boldsymbol{\nabla}\cdot\mathbf{V} + \boldsymbol{\nabla}u\cdot\mathbf{V} = \frac{e^{-r^2}}{r\sin\theta}$$

I want to integrate the above expression over all $$\mathfrak{R}^3$$. I apply divergence theorem to the left hand side, evaluated at the surface of a sphere at infinity. So I get

$$LHS= \int\boldsymbol{\nabla}\cdot(u\mathbf{V}) dV= \int u \mathbf{V}\cdot d\mathbf{S} = \int u \mathbf{V}\cdot \hat{\mathbf{r}} dS = 0,$$

as expected. But for the RHS I get $$RHS=\int \frac{e^{-r^2}}{r\sin\theta} dV = 2\pi \int_{0}^{\infty} dr\, r e^{-r^2} \int_{0}^{\pi} d\theta = \pi^2 .$$

Obviously this cannot be right! I have pored over this but I cannot figure out what is happening. Thanks in advance.

• What happens to the vector field on the $xz$ plane? Commented Jan 13, 2021 at 6:34
• @AlexOrtiz while that is a good guess, the origin is not the problem here. If the integral were set up as the half sphere with $x\leq 0$ the surface integral and and volume integral would match. The problem is that the vector field effectively has two separate boundary surfaces on the front $xz$ plane. In fact it would match for any spherical slice, up to, but not including, the "whole" slice Commented Jan 13, 2021 at 6:45
• Ah ok. So there is a discontinuity on the $xz$ plane when the azimuthal angle jumps from $2\pi$ back down to $0$, which means the application of divergence theorem is not valid here?
– Nick
Commented Jan 13, 2021 at 7:05
• Not valid in the classical sense, yes, but not valid is still a strong word. The divergence theorem is used to define the existence of a Dirac delta where the jump discontinuity was (which means the delta is just defined to be whatever fixes the divergence theorem pieces to agree with each other). I would reserve the use of not valid for vector fields that have a divergence that even a Dirac delta can't fix, for example $\hat{r}$, which has an infinite divergence at the origin, and it cannot be fixed. Commented Jan 13, 2021 at 7:11

What the volume integral is really calculating is the following limit. Take the spherical "slice" which goes from $$\phi = 0$$ to $$\phi = \beta$$. The volume integral calculation is altered by

$$\beta\int_0^\infty re^{-r^2}dr\int_0^\pi d\theta = \frac{\pi\beta}{2}$$

The surface integral now has three components: The spherical surface itself is $$0$$ as before, what's new is the addition of the semicircular planes at $$\phi = 0$$ and $$\phi = \beta$$. The contribution from the first plane is $$0$$, but the contribution from the second plane is

$$\int_{\phi=\beta} u\mathbf{V}\cdot d\mathbf{S} = \int_0^\infty \int_0^\pi e^{-r^2}\beta\hat{\phi}\cdot\hat{\phi}(rdrd\theta) = \beta\int_0^\infty re^{-r^2}dr\int_0^\pi d\theta = \frac{\pi\beta}{2}$$

Ordinarily as you take the limit $$\beta\to2\pi$$, the two planes would close up and since the function takes on the same values but with faces oriented opposite ways, they would cancel. But the vector field has a jump discontinuity at the $$xz$$ plane, $$x>0$$, so this does not happen. Instead,

$$\lim_{\beta\to2\pi}\int_{S_{\beta}} u\mathbf{V}\cdot d\mathbf{S} = \pi^2 \neq 0$$

Since the vector field had a discontinuity, it's divergence was hiding a secret Dirac delta on the "prime meridian" of the sphere. The divergence theorem is valid if the delta is considered properly.