TITLE: Volume of a hole through cylinder (from the side)
QUESTION [6 upvotes]: I need to calculate the volume of a circular hole in a cylinder and I've come across a problem. The problem is finding the "cap-volume", which is needed to complete the volume of the hole. I created a quick example of the problem. 

Cylinder which will be drilled

Hole. The cap is shown with the magenta coloured curves

REPLY [4 votes]: Let $R$ and $r$ be the radius of the cylinder and the hole.  We will assume $k = \frac{r}{R} < 1$.
We will further assume the hole is drilled toward the center and perpendicular to the axis of the cylinder. Under these assumptions, the volume of the cap is given by
$$\begin{align}
\verb/Vol/_{cap}
&= 4 
\int_0^r \int_0^{\sqrt{r^2-x^2}} \left( \sqrt{R^2-x^2} - \sqrt{R^2 - r^2} \right) dy dx\\
&= 4 \int_0^r \sqrt{r^2 - x^2}\left(\sqrt{R^2 - x^2} - \sqrt{R^2-r^2}\right) dx\\
&= 4Rr^2 \left[ \int_0^1 \sqrt{(1-x^2)(1-k^2x^2)} dx - \frac{\pi}{4}\sqrt{1-k^2}\right]\\
&= 4Rr^2 \left[\frac{(1+k^2)E(k) -(1-k^2)K(k)}{3k^2} - \frac{\pi}{4} \sqrt{1-k^2}\right]
\end{align}
$$
where
$$\begin{align}
K(k) 
&= \int_0^{\frac{\pi}{2}} \frac{1}{\sqrt{1-k^2\sin^2\theta}} d\theta 
 = \int_0^1 \frac{1}{\sqrt{(1-k^2x^2)(1-x^2)}} dx
\\
E(k) 
&= \int_0^{\frac{\pi}{2}} \sqrt{1-k^2\sin^2\theta} d\theta 
 = \int_0^1 \sqrt{\frac{1-k^2x^2}{1-x^2}} dx
\end{align}$$
are the complete elliptic integrals of the first and second kind respectively.
Similarly, the volume of the hole is given by
$$\verb/Vol/_{hole} = 
 8Rr^2 \left[\frac{(1+k^2)E(k) -(1-k^2)K(k)}{3k^2} \right]$$