<s>[INST] Calculating volume using cylindrical coordinates. 
A solid $D$ is defined by the following inequalities: $$\begin{align}x^2+y^2+(z-1)^2 &\le 1\\ z^2 &\le x^2+y^2\end{align}$$ Calculate the volume of $D$.

Attempt to solve:
$$\begin{align}x&=r\cos\theta \\ y&=r\sin\theta\end{align}$$
Plugging in these values into the first equation we get :
$$\begin{align}
r^2+(z-1)^2&=1 \\
(z-1)^2&=1-r^2 \\
z&=1\pm\sqrt{1-r^2}
\end{align}$$
Since $z^2=r^2$ from the 2nd inequality, we'll have $z=\pm r$.
Solving for $r$:
$$r=1+\sqrt{1-r^2} \implies r=1$$
and $0<\theta<2\pi$.
However, I'm confused about how to define the limits of $z$ since it could be equal to $1+\sqrt{1-r^2}$ or $1+\sqrt{1-r^2}$.
Thanks in advance.
 [/INST] For limits of $z$ your lower bound is the lower hemisphere $z=1-\sqrt {1-r^2}$ and the upper limit is the cone $ z=r $.
</s>