<s>[INST] Computing a divergent integral $\iiint r^5sin\theta cos\theta$ Problem
Evaluate
$$I =  \iiint_V z \sqrt{x^2+y^2+z^2}dxdydz$$  
Where V is :
$$\sqrt{x^2+y^2} \leq z\leq \sqrt{1-x^2-y^2}$$
Solution:
I must use spherical coordinates so:
$$x=r\cos\psi \sin{\theta}$$
$$y=r \sin{\psi} \sin{\theta}$$
$$z = r \cos \theta$$ 
$$r \geq 0;  0 \leq \psi \leq 2 \pi; 0 \leq \theta \leq \pi$$
Jacobian matrix J= $r^2sin\theta$
The new V looks like this:
$$\sqrt{r^2\cos^2 \psi \sin^{2} \theta + r^2 \sin^{2} \psi \sin^{2} \theta} \leq r\cos \theta \leq \sqrt{1-(r^2\cos^2 \psi \sin^2 \theta + r^{2}\sin^2\psi \sin^{2}\theta)}$$
From these we conclude that:
$$\sin \theta \leq \cos \theta$$
$$r \leq \frac{1}{\sqrt{2}\sin \theta}; r \leq 1$$
And so the new V is:
$$ 0 \leq r \leq \frac{1}{\sqrt{2}\sin \theta}$$
$$ 0 \leq \theta \leq \pi/4$$
$$0 \leq \psi \leq 2\pi$$
And so our integral is:
$$\int \limits_0^{2\pi }\int \limits_0^{\frac{\pi \:}{4}}\int \limits^{\frac{1}{\sqrt{2}\sin\left(\theta \right)}}_0r^4\cos\left(\theta \right)\sin \left(\theta \right)drd\theta \:d\psi $$
Question here somewhere I a may be making a mistake, because later on the integral is diverging
\begin{align}
\int \limits_0^{2\pi }\int \limits_0^{\frac{\pi \:}{4}}\int \limits^{\frac{1}{\sqrt{2}\sin\left(\theta \right)}}_0r^4\cos\left(\theta \right)\sin \left(\theta \right)drd\theta \:d\psi &= \frac{1}{5} \int \int r^{5}\cos\theta \sin{\theta} \in[0, \frac{1}{\sqrt{2}}\sin\theta]\\
&=\frac{1}{20\sqrt{2}} \int \int \frac{d \sin\theta}{\sin^{4}\theta}\\
&= \frac{-3}{20\sqrt{2}} \int_{0}^{2\pi} \frac{1}{\sin^{2}\theta} |^{\pi/4}_{0} d\psi
\end{align}
 and here in $\sin(0)$ the integral is diverging
Question:
What can I do about this problem? Am I making a mistake? What Should I fix? What is the solution to this Integral?
Update
$$\sqrt{x^2+y^2} \leq z\leq \sqrt{1-x^2-y^2}$$
to spherical coordinates
$$\sqrt{r^2\cos^2 \psi \sin^{2} \theta + r^2 \sin^{2} \psi \sin^{2} \theta} \leq r\cos \theta \leq \sqrt{1-(r^2\cos^2 \psi \sin^2 \theta + r^{2}\sin^2\psi \sin^{2}\theta)}$$
$$r \sin{\theta} \leq r \cos{\theta} \leq \sqrt{1-r^{2} \sin^{2}{\theta}}$$
And From here:
$$\sin{\theta} \leq  \cos{\theta}$$
$$r \leq 1 $$
$$r^{2} \sin^{2}{\theta} \leq 1 - r^{2} \sin^{2}{\theta} <=> r^{2} \sin^{2}{\theta} +r^{2} \sin^{2}{\theta} \leq 1 <=> r^{2} \leq \frac{1}{2 sin^{2} \theta} <=> r \leq \frac{1}{\sqrt{2} sin{\theta}} $$
 [/INST] There is not the slightest reason why the integral of a nice function over a compact domain should be divergent.
I'm using geographical longitude $\phi$ and geographical latitude $-{\pi\over 2}\leq\theta\leq{\pi\over2}$. The condition $z\geq\sqrt{x^2+y^2}$ then translates into $r\sin\theta\geq r\cos\theta$, or $\theta\geq{\pi\over4}$, and the condition $z\leq\sqrt{1-x^2-y^2}$ translates into $r\leq 1$. Since the Jacobian is $r^2\cos\theta$ we obtain
$$I=2\pi\int_0^1\int_{\pi/4}^{\pi/2} r\sin\theta\ r\ r^2\cos\theta\>d\theta\>dr=2\pi\int_0^1r^4\>dr\int_{\pi/4}^{\pi/2}\sin\theta\cos\theta\>d\theta={\pi\over10}\ .$$
</s>