<s>[INST] Is it possible to evaluate $\iiint \frac{2x^2+z^2}{x^2+z^2} dxdydz$ using cylindrical coordinates instead of spherical? I know that this integral is way easier with spherical coordinates, but I would like to understand my mistakes; evaluate
$$\iiint_D \frac{2x^2+z^2}{x^2+z^2} dxdydz$$
Where $D=\{(x,y,z)\in\mathbb{R}^3 \ \text{s.t.} \ 1 \leq x^2+y^2+z^2 \leq 4, \ x^2-y^2+z^2 \leq 0\}$.
Letting $x=\rho \cos \theta$, $y=y$ and $z=\rho \sin \theta$ it follows that
$$\iiint_E (2\cos^2 \theta+\sin^2 \theta)\rho d\rho dyd\theta=\iiint_E (1+\cos^2 \theta)\rho d\rho dyd\theta$$
Where $E=\{(\rho,y,\theta)\in\mathbb{R}^3 \ \text{s.t.} \ 1 \leq \rho^2+y^2 \leq 4, \rho^2 \leq y^2\, \rho \geq 0, 0 \leq \theta < 2\pi\}$.
The point is that now I have a lot of conditions on $y$, because $\sqrt{1-y^2} \leq \rho \leq \sqrt{4-y^2}$, $-y\leq\rho\leq y$ and $\rho \geq 0$.
From the existence conditions of the roots we get $-1 \leq y \leq 1$ and $-2 \leq y \leq 2$, so it follows that $-1 \leq y \leq 1$.
So it remains to discuss the cases of $\max\left\{\sqrt{1-y^2},-y\right\} \leq \rho$ and $\rho \leq \min\left\{y,\sqrt{4-y^2}\right\}$; it is $y \leq \sqrt{4-y^2}$ for $-1 \leq y \leq 1$ and it is always $\sqrt{1-y^2} \leq \sqrt{4-y^2}$, we have that
$$\max\left\{\sqrt{1-y^2},-y\right\}=\begin{cases} -y, \ \text{if} -1 \leq y \leq -\frac{1}{\sqrt2} \\ \sqrt{4-y^2}, \ \text{if} \ -\frac{1}{\sqrt2} \leq y \leq 1  \end{cases}$$
So I end up with
$$\iiint_E (1+\cos^2 \theta)\rho d\rho dyd\theta=\int_0^{2\pi} \left(\int_{-1}^{-\frac{1}{\sqrt2}} \left(\int_{-y}^{\sqrt{4-y^2}} (1+\cos^2 \theta)\rho d\rho\right)dy \right)d\theta+$$
$$+\int_0^{2\pi} \left(\int_{-\frac{1}{\sqrt2}}^{1} \left(\int_{\sqrt{1-y^2}}^{\sqrt{4-y^2}} (1+\cos^2 \theta)\rho d\rho\right)dy \right)d\theta$$
But I get the wrong answer, am I missing some more conditions (maybe the discussion of $\rho \geq 0$ too) or am I making other mistakes? Thanks.
 [/INST] In the $y-\rho$ plane the condition $1\le \rho^2+y^2\le 4$ defines a ring centered at $(0,0)$
with inner radius 1 and outer radius 2. The conditions $\rho^2<y^2$ and $\rho\ge 0$ subselect two
45$^\circ$ sections delimited by $0\le \rho \le y$.
$$
I
=\int\int\int\frac{2x^2+z^2}{x^2+z^2} dxdydz
$$
$$
=
\int_0^{2\pi} d\theta
\int_0^{\sqrt 2} \rho d\rho
\int_{1\le \rho^2+y^2\le 4} dy
\frac{2\rho^2\cos^2\theta+\rho^2\sin^2\theta}{\rho^2}.
$$
Because there is no dependence on $y$ in the integrand and the limits are symmetric functions
of $y$, we may look only at $y\ge 0$
and introduce a factor 2 to collect the part of $y<0$:
$$
I
=
2\int_0^{2\pi} d\theta
\int_0^{\sqrt 2} \rho d\rho
\int_{1\le \rho^2+y^2\le 4,y\ge 0} dy
(2\cos^2\theta+\sin^2\theta)
$$
$$
=
2\int_0^{2\pi} d\theta
\int_0^{\sqrt 2} \rho d\rho
\int_{1\le \rho^2+y^2\le 4,y\ge 0} dy
(1+\cos^2\theta)
$$
$$
=
6\pi
\int_0^{\sqrt 2} \rho d\rho
\int_{1\le \rho^2+y^2\le 4,y\ge 0} dy
$$
The ring geometry suggests to chop this into 2 sections of $\rho$ where the $y-$limits
differ as they are delimited by the circles and the diagonal:
$$
=
6\pi
[
\int_0^{1/\sqrt 2} \rho d\rho
\int_{\sqrt{1-\rho^2}}^{\sqrt{4-\rho^2}} dy
+\int_{1/\sqrt 2}^{\sqrt 2} \rho d\rho
\int_\rho^{\sqrt{4-\rho^2}} dy
]
$$
$$
=
6\pi
[
\int_0^{1/\sqrt 2} \rho d\rho
(\sqrt{4-\rho^2}
-\sqrt{1-\rho^2})
+\int_{1/\sqrt 2}^{\sqrt 2} \rho d\rho
(\sqrt{4-\rho^2}-\rho)
]
$$
$$
=
6\pi
[
\int_0^{\sqrt 2} \rho d\rho
\sqrt{4-\rho^2}
-\int_0^{1/\sqrt 2} \rho d\rho
\sqrt{1-\rho^2}
-\int_{1/\sqrt 2}^{\sqrt 2} \rho^2 d\rho
]
$$
$$
=
6\pi
[
\frac12 \int_0^ 2 du \sqrt{4-u} -\frac12 \int_0^{1/2} du \sqrt{1-u} -\frac{7\surd 2}{12}
]
$$
$$
=
6\pi
[
\frac12 (-\frac{4\surd 2}{3}+\frac{16}{3})
-\frac12 (-\frac{\surd 2}{6}+\frac23)
-\frac{7\surd 2}{12}
]
= 6\pi [ \frac{7}{3}-\frac{7\surd 2}{6} ] =7\pi(2-\sqrt 2)
$$
</s>