<s>[INST] Solve $I=\iiint\limits_\Omega z^2 dv$ using spherical coordinate system, $\Omega: x^2 +y^2 + z^2 \le R^2 \cap x^2 +y^2 + z^2 \le 2Rz$ Question: Solve $I=\iiint\limits_\Omega z^2 dv$ using spherical coordinate system. $\Omega$ is the common part of $x^2 +y^2 + z^2 \le R^2 $ and $ x^2 +y^2 + z^2 \le 2Rz$.
My attempt:Because $ r^2 \le R^2 and\ r^2 = 2R r\cos \varphi $, so $ 2R\cos \varphi \le r \le R$.
$$\int_0^{2\pi}d\theta \int_0^{\pi/2}\sin\varphi d\varphi \int_{2R\cos \varphi}^R r^2\cdot (r\cos\varphi)^2 dr = 2\pi\int_0^{\pi/2}\cos^2\varphi \sin \varphi d\varphi \int_{2R\cos \varphi}^R r^4 dr =$$
$$\frac{2\pi}5 \int_0^{\pi/2} cos^2\varphi \sin \varphi [R^5-({2R\cos \varphi})^5  ]d\varphi = \frac{2\pi R^5}5 \int_0^{\pi/2}(cos^2\varphi \sin \varphi-32cos^7\varphi \sin \varphi )d\varphi $$
Can anyone point out where is wrong? Is the lower boundary $ 2R \cos \varphi $ correct？
Update based on the answer:
$$I=\int_0^{2\pi}d\theta \int_0^{\pi/4}\sin\varphi \cos^2\varphi d\varphi \int_0^R r^4 dr - \int_0^{2\pi}d\theta \int_0^{\pi/2}\sin\varphi \cos^2\varphi d\varphi \int_0^{2R\cos \varphi} r^4 dr $$
Is this equation correct?
 [/INST] Your second equation gives $0\leq r\leq 2R\cos(\varphi)$, so $0\leq r\leq \min{(R,2R\cos{\varphi})}$ is the correct bound.
You now need to break up the integral into the regions where each upper bound applies, integrate, and add them.
</s>