# 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.

• When you say "area enclosed," do you mean "volume enclosed?" Apr 22 '15 at 1:53
• yes; edited. Thank you. Apr 22 '15 at 2:07

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.

• Awesome, I just ran this through with a couple of different cases and it seems to handle them all! I found that in the case when A+d<R, a complex number is returned whose real part is equivalent to the volume. Thank you so much, this will help a ton! Apr 22 '15 at 4:14
• No prob. I just noticed a typo in the code (see image). It should read $Sqrt[A^2-r^2-d^2+2rd \cos\theta]$. I guess I manually put in a $1$ for the $d$ when coding. Apr 22 '15 at 17:19
• Saw that as well. No biggie, I knew what you meant. Unfortunately this integral takes obnoxiously long to evaluate in Mathematica, and I can't get it to evaluate it at all in Matlab so running it a few thousand times is unfortunately out of the question. I thank you anyways though for satisfying my general curiosity! Apr 22 '15 at 20:48