# Order of integration in spherical coordinates

I do not seem to understand the logic behind choosing the correct integration bounds and integration order when dealing with spherical coordinates. For example, consider the following problem: Let $B_R(\textbf0)=\{(x,y,z)\in R^3:x^2+y^2+z^2\le R^2\}$, then evaluate$$\int \int \int_{B_R(\textbf0)} z^2 dxdydz$$

I have tried computing the integral in the following order: $$\int_{0}^{\pi} \int_{0}^{2\pi} \int_{0}^R \rho^4cos^2\theta sin\theta d\rho d\theta d\phi$$

However when I compute this I obtain zero which is obviously incorrect. How should I choose the order of my integration bounds and why?

EDIT:

My azimuthal angle (on the x-y plane) is $\phi$ and my polar angle (the angle with the z-axis) is $\theta$. Therefore $z=\rho cos(\theta)$ and the jacobian is $\rho^2sin(\theta)$

• The $\theta$'s in the integral should be $\phi$'s. – user170231 Jun 7 '16 at 17:26
• $\rho^4 cos^2 \theta \sin\phi$ – Doug M Jun 7 '16 at 17:26

Normally, with your choice of $\phi$ and $\theta$, the allowed values of $\phi$ are $0$ to $2\pi$, and the allowed values of $\theta$ are $0$ to $\pi$. Your use of $0$ to $\pi$ for $\phi$ and $0$ to $2\pi$ for $\theta$ is fine EXCEPT that for certain of these values $\sin\theta$ is negative. Recall that when changing variables the factor you introduce is actually $|\rho^2\sin\theta|$, and it is not true that $|\sin\theta| = \sin\theta$ for $\theta$ between $\pi$ and $2\pi$. You would have to break up your $\theta$ integral into two pieces to account for this.
Hint: Since $\phi$ and $\theta$ are the azimuthal and polar angles respectively, what over what values do these coordinates range? Do these match the limits of integration in your ordering?
• can't I choose the range of $\theta$ as long as I restrain $\phi$? – john melon Jun 7 '16 at 17:31
• You're doing the integration over the surface of the sphere. Therefore the ranges of $\phi,\theta$ are already specified. – Semiclassical Jun 7 '16 at 17:33