Why do each of these cylindrical triple integrals evaluate differently? The problem in question is thus:
Find the volume cut out of the sphere of a radius $a$ centered at the origin by the polar curve $r = a\cos\theta$. I attempted to solve the problem using this cylindrical triple integral, taking advantage of $x$-axis symmetry.
$$
2\int_0^{\frac{\pi}{2}}\int_0^{a\cos\theta}\int_{-\sqrt{a^2 - r^2}}^{\sqrt{a^2 - r^2}}r\,dz\,dr\,d\theta = \frac{2\pi a^3}{3} - \frac{8a^3}{9}
$$
However, when this, similar integral is evaluated (which in my mind should yield the same results as the first one), the answer is different as the last term cancels out.
$$
\int_{-\frac{\pi}{2}}^{\frac{\pi}{2}} \int_0^{a\cos\theta}\int_{-\sqrt{a^2 - r^2}}^{\sqrt{a^2 - r^2}} r \, dz\,dr\,d\theta = \frac{2\pi a^3}{3}
$$
Which one of these answers is correct and why is the other one wrong? I understand that it has something to do with the theta integral, but I have no idea where my error is in assuming that these two triple integrals should produce identical results.
Thanks! This is my first time on the Math Stack Exchange so let me know if there is anything else I can do to improve the nature of my question.
THANK YOU ALL!!! Many wonderful explanations below, have a great day everyone!
 A: The working is not shown, so the following is conjecture on how the first and second integrals were worked out.
$$I(\theta)=\int_0^{a\cos\theta}\int_{-\sqrt{a^2-r^2}}^{\sqrt{a^2-r^2}}r\, dz\,dr=\int_0^{a\cos\theta}2r\sqrt{a^2-r^2}\,dr=\frac{4}{3}\Big[(a^2-r^2)^{3/2}\Big]_0^{a\cos\theta}=\frac{4a^3}{3}(\sin^3\theta-1)$$
Then $2\int_0^{\pi/2}\sin^3\theta\,d\theta=\frac{4}{3},\qquad\int_{-\pi/2}^{\pi/2}\sin^3\theta\,d\theta=0$ give out different answers.
The problem occurs because the last expression $\sin^3\theta-1$ is not correct. Substituting $\cos\theta$ into $(1-r^2)^{3/2}$ gives $(\sin^2\theta)^{3/2}=|\sin\theta|^3$ which is always non-negative.
A: $2\pi a^3/3$ is the volume of the hemisphere so it is clear that the second answer is
wrong. But the integral itself seems to be correct since $2\int_0^{\pi/2}f(\cos\theta)\,d\theta=\int_{-\pi/2}^{\pi/2} f(\cos\theta)\,d\theta$ due to the evenness of $\cos\theta$ so it is likely that you made some calculation error.
In fact it seems symbolab is making the same error. The second integral is$$2\int_{-\pi/2}^{\pi/2}\int_0^{a\cos\theta}r\sqrt{a^2-r^2} \, dr~d\theta=-\int_{-\pi/2}^{\pi/2} \int_{a^2}^{a^2\sin^2\theta}\sqrt m\,dm~d\theta$$where $m=a^2-r^2$. This gives$$V=-\frac23\int_{-\pi/2}^{\pi/2}(\color{red}|a\sin\theta\color{red}|^3-|a|^3)\,d\theta$$So you have probability forgotten to take the modulus and landed at the answer of $2\pi a^3/3$.
A: I did the case $a=1$.  The inner integral is
$$
\int_{-\sqrt{1-r^2}}^{\sqrt{1-r^2}} r\;dz = 2r\sqrt{1-r^2}
$$
The next integral is
$$
\int_0^{\cos\theta} 2r\sqrt{1-r^2}\;dr = \frac{2}{3}\left(
1+(\cos^2\theta-1)\sqrt{1-\cos^2\theta}\right)
$$
In case $\theta > 0$, this simplifies to
$$
\frac{2}{3}\left(1+(\cos^2\theta-1) \sin \theta\right)
$$
But in case $\theta < 0$, it simplifies to
$$
\frac{2}{3}\left(1-(\cos^2\theta-1) \sin \theta\right)
$$
Now it is clear that for the outer integral, $\int_{-\pi/2}^{\pi/2}\cdots \;d\theta$
is not equal to $2 \int_{0}^{\pi/2}\cdots\;d\theta$ .

This is a good thing to warn calculus students about.  Do not (without thinking) simplify $\sqrt{1-\cos^2\theta}$ to $\sin \theta$.
