# Gauss divergence theorem

I'm trying to solve the following problem using the Gauss divergence theorem. I have to calculate the Flux through a sphere. The sphere is given as $$x^2 +y^2+z^2==4$$ where as the z is resticted from $$\sqrt{3} \; to \; 2$$ I determined the divergence to $$4z$$ I first tried to use spherical coordinates which resolve to:

$$\int _{\sqrt{3}}^2\int _0^{\pi /6}\int _0^{2\pi }4 *r*\text{Cos}[o]*r^2*\text{Sin}[o]dpdodr = \frac{7 \pi }{4}$$

To confirm this solution I tried to solve this problem using a regular volume integral. Which resolve to: $$\int _{\sqrt{3}}^2\int _{-\sqrt{4-z^2}}^{\sqrt{4-z^2}}\int _{-\sqrt{4-y^2-z^2}}^{\sqrt{4-y^2-z^2}}(4 *z) dxdydz = \pi$$ I guess the error lies in my changed z variable. I replaced it with $$r*\text{Cos}[o]$$ Could you guys please take a look into it? Thanks

-

I am taking up this neglected problem, as it left an apparent conflict unresolved, and it seems to present an opportunity to discuss volume integration in the various commonly-used coordinate systems (and the importance of setting integration limits correctly).

The problem calls for evaluating the volume integral $\iiint \ \nabla \cdot \overrightarrow{F} \ dV \ ,$ with $\ \nabla \cdot \overrightarrow{F} = 4z \$ , over the interior of the spherical cap $\ \sqrt{3} \ \le \ z \ \le 2 \$ of the sphere $\ x^2 + y^2 + z^2 = 4 \$ . We'll be able to show that the set-up by the OP of the integral in spherical coordinates has used an incorrect limit.

For the sake of checking technique, we'll first just calculate the volume of the spherical cap. One of the lessons here is that, although the region may be based on a sphere, spherical coordinates are not automatically the best choice for working out a problem.

Because the lower bound of the problem is a flat surface parallel to a coordinate plane, and the divergence function is simply proportional to a coordinate value which is oriented perpendicularly to that plane, the symmetry of the region is reduced from "radial" to "axial". We'll see that cylindrical coordinates are the simplest choice for setting up the computation:

The volume in this case can be treated as a "stack of slices" along the z-axis having circular cross-sections, their radii given by

$$(x^2 + y^2) + z^2 = r^2 + z^2 = 4 \ \Rightarrow \ r = \sqrt{4 - z^2} \ .$$

Because there is axial symmetry of these slices, the "azimuthal angle" integration is separable. The volume integral becomes

$$\int_{\sqrt{3}}^2 \ \int_0^{2 \pi} \int_0^{\sqrt{4 - z^2}} \ r \ dr \ \ d\theta \ dz \ = \ \int_0^{2 \pi} d\theta \ \int_{\sqrt{3}}^2 \ \ (\frac{1}{2} r^2) \ |_0^{\sqrt{4 - z^2}} \ \ dz$$

$$= \ 2 \pi \ \int_{\sqrt{3}}^2 \ \ \frac{1}{2} (4 - z^2) \ \ dz \ = \ \pi \ (4z - \frac{1}{3}z^3) \ |_{\sqrt{3}}^2 \ = \ \pi \ (8 - \frac{8}{3} - 4\sqrt{3} + \sqrt{3})$$

$$= \ \pi \ (\frac{16}{3} \ - 3\sqrt{3} ) \ \ \text{or} \ \ \frac{16 \pi}{3} \cdot \ (1 - \frac{9\sqrt{3}}{16} ) \ .$$

The geometric formula for a spherical cap of height $\ h \$ from a sphere of radius $\ R \$ is $\ V = \frac{\pi}{3} h^2 \ (3R - h) \ .$ Here, we have $\ R = 2 \$ and $\ h = 2 - \sqrt{3} \ ;$ hence,

$$V = \frac{\pi}{3} (2 - \sqrt{3})^2 \cdot (3 \cdot 2 - [2 - \sqrt{3}]) \ = \ \frac{\pi}{3} (7 - 4\sqrt{3}) \cdot (4 + \sqrt{3}) \ = \ (\frac{16}{3} - 3\sqrt{3} ) \ \pi \ ,$$

which jibes with our integration result (well, after all, the integral we just did is how we might derive the formula).

We will carry out the integration in rectangular coordinates next, which makes the determination of limits as straightforward as possible, at the cost of complicating the integrands produced along the way. For each circular "slice" along the z-direction, we need to make "strips" along the x-direction, which we will in turn integrate along the y-direction. The "height" of each "strip" at a particular value of $\ x \$ runs from $\ -\sqrt{(4 - z^2) - y^2 } \$ to $\ +\sqrt{(4 - z^2) - y^2 } \$ , and at each level of $\ z \$ , the range for $\ y \$ passes from $\ -\sqrt{4 - z^2 } \$ to $\ +\sqrt{4 - z^2 } \$ . So we find the limits that kornnflake shows, leading to the integration

$$\int_{\sqrt{3}}^2 \ \int_{-\sqrt{4 - z^2}}^{+\sqrt{4 - z^2}} \ \int_{-\sqrt{(4 - z^2) - y^2 }}^{+\sqrt{(4 - z^2) - y^2 }} \ \ dx \ dy \ dz \ = \ \int_{\sqrt{3}}^2 \ \int_{-\sqrt{4 - z^2}}^{+\sqrt{4 - z^2}} \ 2 \sqrt{(4 - z^2) - y^2 } \ \ dy \ dz$$

$$= \ 2 \int_{\sqrt{3}}^2 \ \frac{1}{2} \cdot [ \ y \cdot \sqrt{(4 - z^2) - y^2 } \ + \ (4 - z^2) \cdot \arctan( \frac{y}{\sqrt{(4 - z^2) - y^2 }}) \ ] |_{-\sqrt{4 - z^2 }}^{+\sqrt{4 - z^2 }} \ \ dz$$

$$= \ \int_{\sqrt{3}}^2 \ [ \ \sqrt{4 - z^2 } \cdot \sqrt{(4 - z^2) - (4 - z^2) } \ + \ (4 - z^2) \cdot \arctan(\frac{\sqrt{4 - z^2 }}{\sqrt{(4 - z^2) - (4 - z^2) }} )$$

$$- \ [ \ -\sqrt{4 - z^2 } \ ] \cdot \sqrt{(4 - z^2) - (4 - z^2) } \ - \ (4 - z^2) \cdot \arctan(\frac{-\sqrt{4 - z^2 }}{\sqrt{(4 - z^2) - (4 - z^2) }} ) \ ] \ \ dz$$

$$= \ \int_{\sqrt{3}}^2 \ [ \ 0 \ + \ (4 - z^2) \cdot (\frac{\pi}{2}) \ - \ 0 \ - \ (4 - z^2) \cdot (-\frac{\pi}{2}) \ ] \ dz \ = \ \int_{\sqrt{3}}^2 \ \pi \ \cdot \ (4 - z^2) \ \ dz \ ,$$

which has led us to the integral which arises in cylindrical coordinates, with the same result.

To carry out the integral in spherical coordinates, the OP has correctly found that since $\ z = 2 \cos \theta \$ , with $\theta$ being the "polar angle" here, then the integration must run from $\ \theta = 0 \$ to $\ \theta = \frac{\pi}{6} \$ .

However, because the spherical cap has a "flat bottom", a ray extending from the origin to the surface of the sphere has imposed upon it a polar angle-dependent length. The integration in the radial direction extending from $\ z = \sqrt{3} \$ to $\ z = 2 \$ must be now run from $\ r \cos \theta = \sqrt{3} \$ to $\ r = 2 \ ,$ or $\ r = \frac{\sqrt{3}}{\cos \theta} \$ to $\ r = 2 \ .$ The volume integral for the "cap" becomes

$$\int_0^{2 \pi} \ \int_0^{\pi / 6} \ \int_{\sqrt{3} \sec \theta}^2 \ r^2 \sin \theta \ \ dr \ \ d\theta \ d\phi \ = \ \int_0^{2 \pi} d\phi \ \int_0^{\pi / 6} \ (\frac{1}{3} r^3) |_{\sqrt{3} \sec \theta}^2 \ \sin \theta \ \ d\theta$$

$$= 2 \pi \ \cdot \ \frac{1}{3} \ \int_0^{\pi / 6} \ (8 \ - \ 3 \sqrt{3} \ \sec^3 \theta) \ \sin \theta \ \ d\theta$$

$$= \ \frac{2 \pi}{3} \ \int_0^{\pi / 6} \ (8 \sin \theta \ - \ 3 \sqrt{3} \frac{\sin \theta}{\cos^3 \theta}) \ \ d\theta \ = \ \frac{2 \pi}{3} \cdot \ (-8 \cos \theta \ - \ 3 \sqrt{3} \cdot \frac{1}{2 \cos^2 \theta}) |_0^{\pi / 6}$$

$$= \ \frac{2 \pi}{3} \ \cdot \ [ \ (-8 \cos \frac{\pi}{6} \ - \ \frac{3 \sqrt{3}}{2} \sec^2 \frac{\pi}{6} ) \ - \ (-8 \cos 0 \ - \ \frac{3 \sqrt{3}}{2} \sec^2 0 ) \ ]$$

$$= \ \frac{2 \pi}{3} \cdot \ (-4 \sqrt{3} \ - \ \frac{3 \sqrt{3}}{2} \cdot (\frac{2}{\sqrt{3}})^2 \ + \ 8 \ + \ \frac{3 \sqrt{3}}{2} )$$

$$= \ \frac{2 \pi}{3} \cdot \ ( 8 \ - \ \frac{9 \sqrt{3}}{2} ) \ = \ \frac{16 \pi}{3} \cdot \ ( 1 \ - \ \frac{9 \sqrt{3}}{16} ) \ ,$$

as before.

$$\\$$

So we have found that the integrations in the three coordinate systems do agree for the volume of the spherical cap, which is $\ V \approx 0.1372 \pi \$ . This would be a good point to make a "sanity check" for the divergence integral: since $\sqrt{3} \ \le \ z \ \le 2 \ ,$ we should expect that

$$4 \ \cdot \ \sqrt{3} \ \cdot V \ \approx \ 0.951 \pi \ < \ \iiint \nabla \cdot \overrightarrow{F} \ dV \ < \ 4 \ \cdot \ 2 \ \cdot V \ \approx \ 1.097 \pi ,$$

which indicates that something has gone wrong in OP's first integral (but likely not the second one). We will now make the divergence integral calculations in each coordinate system, reprising as briefly as possible the details.

cylindrical coordinates --

$$\int_{\sqrt{3}}^2 \ \int_0^{2 \pi} \int_0^{\sqrt{4 - z^2}} \ 4z \ \ r \ dr \ \ d\theta \ dz \ = \ 4 \cdot 2 \pi \ \int_{\sqrt{3}}^2 \ \ z \ \cdot \ \frac{1}{2} (4 - z^2) \ \ dz \$$

$$= \ \ 4 \pi \ \int_{\sqrt{3}}^2 \ \ (4z - z^3) \ \ dz \ = \ 4\pi \ (2z^2 - \frac{1}{4}z^4) \ |_{\sqrt{3}}^2 \ = \ 4 \pi \cdot \ (8 - \frac{16}{4} - 2 \cdot 3 + \frac{9}{4})$$

$$= \ 4 \pi \ \cdot \ \frac{1}{4} \ = \ \pi \ .$$

rectangular coordinates --

$$\int_{\sqrt{3}}^2 \ \int_{-\sqrt{4 - z^2}}^{+\sqrt{4 - z^2}} \ \int_{-\sqrt{(4 - z^2) - y^2 }}^{+\sqrt{(4 - z^2) - y^2 }} \ \ 4z \ \ dx \ dy \ dz \ = \ 8 \int_{\sqrt{3}}^2 \ \int_{-\sqrt{4 - z^2}}^{+\sqrt{4 - z^2}} \ z \ \sqrt{(4 - z^2) - y^2 } \ \ dy \ dz$$

$$= \ 4 \int_{\sqrt{3}}^2 \ z \cdot [ \ y \cdot \sqrt{(4 - z^2) - y^2 } \ + \ (4 - z^2) \cdot \arctan( \frac{y}{\sqrt{(4 - z^2) - y^2 }}) \ ] |_{-\sqrt{4 - z^2 }}^{+\sqrt{4 - z^2 }} \ \ dz$$ $$= \ 4 \int_{\sqrt{3}}^2 \ z \ \cdot \ \pi \ \cdot \ (4 - z^2) \ \ dz \ = \ 4\pi \int_{\sqrt{3}}^2 \ (4z - z^3) \ \ dz \ ,$$

and continuing as for the cylindrical-coordinate integration.

spherical coordinates (using $\ z \ = \ r \cos \theta \$ ) --

$$\int_0^{2 \pi} \ \int_0^{\pi / 6} \ \int_{\sqrt{3} \sec \theta}^2 \ 4r \cos \theta \ \cdot \ r^2 \sin \theta \ \ dr \ \ d\theta \ d\phi$$

$$= \ 4 \int_0^{2 \pi} d\phi \ \int_0^{\pi / 6} \ r^3 \ \sin \theta \cos \theta \ \ dr \ d\theta \ = \ 4 \ \cdot 2\pi \ \int_0^{\pi / 6} \ (\frac{1}{4} r^4) |_{\sqrt{3} \sec \theta}^2 \ \sin \theta \cos \theta \ \ d\theta$$

$$= \ 2 \pi \ \int_0^{\pi / 6} (16 \ - \ 9 \sec^4 \theta) \ \cdot \ \sin \theta \cos \theta \ \ d\theta \ = \ 2 \pi \ \int_0^{\pi / 6} \ (8 \sin 2\theta \ - \ 9 \frac{\sin \theta}{\cos^3 \theta}) \ \ d\theta$$

$$= \ 2 \pi \ \cdot \ (-4 \cos 2\theta \ - \ \frac{9}{2} \sec^2 \theta) \ |_0^{\pi / 6}$$

$$= \ 2 \pi \ \cdot \ [ \ (-4 \cos \frac{\pi}{3} \ - \ \frac{9}{2} \sec^2 \frac{\pi}{3}) \ - \ (-4 \cos 0 \ - \ \frac{9}{2} \sec^2 0) \ ]$$

$$= \ 2 \pi \ \cdot \ (-4 \cdot \frac{1}{2} \ - \ \frac{9}{2} \cdot \frac{4}{3} \ + \ 4 \ + \ \frac{9}{2} \cdot 1 ) \ = \ 2 \pi \cdot \frac{1}{2} \ = \ \pi \ .$$

So we are able to confirm OP's second integration result. (It is somewhat amusing that though the expression for the volume of the spherical cap is a bit complicated, the divergence integral proves to give a very simple value.

-
Just a side comment here on the application of the Divergence Theorem. Integrating $\text{div}\,\vec F$ over the spherical cap gives the flux of $\vec F$ over the boundary of the spherical cap, which consists of the spherical portion and the disk in the plane. If that was not the original problem — and it doesn't sound like it was — we must add the flux of $\vec F$ upwards across that disk. –  Ted Shifrin May 19 '13 at 2:40
Quite so. I've no idea what the full problem may have looked like; my interest here was largely in whether either of OP's calculations was correct and, ultimately, where the integral in spherical coordinates went wrong. –  RecklessReckoner May 19 '13 at 2:47
Nice answer for an old question +1 –  Shuhao Cao Jun 17 '13 at 2:33