Volume between sphere and cylinder with different centers I am working on a tumor model and need to calculate the volume enclosed between the sphere given by
$$(x-d)^2+y^2+z^2=r^2$$
and the cylinder given by
$$x^2+y^2=R^2.$$
I have worked it out by using surfaces of revolution but this is tedious and required numerous cases. When I try to use cylindrical coordinates I end up the integral
$$\int^{2\pi}_0 \int^R_0 \int^{\sqrt{r^2-R^2+d^2-2dR\cos (\theta )}}_{-\sqrt{r^2-R^2+d^2-2dR\cos (\theta )}} R~dz~dR~d\theta$$
which won't compute. I suspect either I am making an error in my transformation to cylindrical coordinates or a different method is needed.
 A: Watch out. You're mixing constants and variables ($R$ is a constant in the cylinder equation but a variable in the integral). Let's employ some revised definitions. Let the radius of the sphere be $A$ and that of the cylinder be $R$. We're looking for the volume enclosed between these two surfaces:
$$(x-d)^2+y^2+z^2=A^2$$
$$x^2+y^2=R^2$$
Note that by symmetry, the volume enclosed above the $xy$ plane is equal to the volume enclosed below it. We'll integrate for the top half of the volume from $z=0$ up to $z$ at the sphere, then double the result.
Knowing this, we can employ a double integral over the circular region in the $xy$ plane. We'll integrate the function $z = \sqrt{A^2 -(x-d)^2 -y^2}$. Since we'll use polar coordinates $(r,\theta)$, we express $z$ as $z= f(r,\theta)$ using $x=r\cos\theta$ and $y=r\sin\theta$.
$$z = f(r,\theta) = \sqrt{A^2 -d^2 -r^2 + 2rd\cos\theta}$$
$$V= 2\iint f(r,\theta) r dr d\theta$$
$$= 2\int_0^{2\pi} \int_0^R \sqrt{A^2 -d^2 -r^2 + 2rd\cos\theta}\ r dr d\theta$$
Here's what Mathematica gives for chosen values of $A,d,and R$. Hopefully this helps.

