# How to compute triple integral in spherical coordinates

I need to compute: $\displaystyle\int \int \int z dxdydz$

over the domain: $\left\{x^2+y^2+z^2\leqslant 16,z\geqslant 0\right\}$

Im trying to use spherical coords as:

$$\int_{0}^{2\pi} \int_{0}^{\frac{\pi}{2}} \int_{0}^{4} r \cos(\theta )r^2\sin(\varphi ) \;dr\,d\theta \,d\varphi$$

It gives me $0$ as result. But i know that is wrong, the same formula computed with Mathematica software returns $64 \pi$.

{x, y, z} =
r {Cos[ϕ] Sin[θ], Sin[ϕ] Sin[θ], Cos[θ]};

Integrate[
z Abs[Det[D[{x, y, z}, {{r, θ, ϕ}}]]],
{r, 0, 4}, {θ, 0, π/2}, {ϕ, 0, 2 Pi}]


My procedure is:

$$\int_{0}^{2\pi} \int_{0}^{\frac{\pi}{2}} \int_{0}^{4} r \cos(\theta )r^2\sin(\varphi ) \;dr\,d\theta \,d\varphi=\int_{0}^{2\pi} \int_{0}^{\frac{\pi}{2}} \int_{0}^{4} r^3 \cos(\theta )\sin(\varphi ) \;dr\,d\theta \,d\varphi=$$ $$=\int_{0}^{2\pi} \int_{0}^{\frac{\pi}{2}}64 \cos(\theta ) \sin(\varphi ) d\theta d\varphi = \int_{0}^{2\pi} -64 \sin(\varphi ) d\varphi = 64 \cos(2\pi ) - 64 \cos(0)=0$$

EDIT: I see the name of the angles can be confusing, so this is mi current notation:

$x=r \sin(\theta ) \cos (\varphi )$

$y=r \sin(\theta ) \sin (\varphi )$

$z=r \cos(\theta)$

$\varphi$ should be the azimuthal angle, and $\theta$ the polar angle

• This will be zero because sine is integrated over its period. Could you please designate the task more precisely? Jun 28, 2014 at 4:53
• Even WolframAlpha agrees with the result of 0, are you sure that's supposed to be $\sin{\varphi}$ and not $\sin{\theta}$? Jun 28, 2014 at 4:53
• You appear to be using $\ \theta \$ as the "polar angle" and $\ \phi \$ as the "azimuthal angle". So the factor $\ \sin \ \phi \$ ought to be $\ \sin \ \theta \$ . (After your edit: Yes, if you have $\ z \$ as $\ r \ \cos \ \theta \$ , then that factor with sine is incorrect and you will get a non-zero result if you are integrating over a hemisphere. [Were you to integrate over the full sphere, the integral would be zero again...] ) Jun 28, 2014 at 4:55
• Yes. The integral is "separable" as $$\int_{0}^{2\pi} d\varphi \ \int_{0}^{\frac{\pi}{2}} \cos(\theta )\sin(\theta) \ d\theta \ \int_{0}^{4} r^3 \ dr\ \ \ .$$ You will now obtain $\ 64 \pi \$ . Jun 28, 2014 at 5:33
• It would seem so -- this happens to people a lot because of the differing notations for the spherical angles. So beware... Jun 28, 2014 at 5:43

The problem is in (1) where $\sin\varphi$ should be $\sin\theta$.
$$\int_{0}^{2\pi}\sin\theta d\varphi \int_{0}^{\frac{\pi}{2}}d\theta \int_{0}^{4}r^2dr (r \cos\theta )$$
$$=\int_{0}^{2\pi} d\varphi \int_{0}^{\frac{\pi}{2}}\sin\theta \cos\theta d\theta \int_{0}^{4}r^3dr =2\pi*(1/2)* 64=64\pi$$