TITLE: Calculate leftover volume of a drilled out cube
QUESTION [6 upvotes]: Say you have a cube with sidelengths $2r$, now you use a cylindrical drill with radius $r$ to hollow out the cube along the $x$, $y$ and $z$ axes through the middle of the cube so that you're left with something like this, meaning we're left with the 8 corners of the cube which each resemble some kind of spike-like structure. I want to calculate the total volume $V$ of the leftover spikes.
Since this is a symmetric problem we can calculate the volume $V_{spike}$ of 1 spike and multiply with 8 to get the full volume.
Now, I can set up an integral and calculate the volume of 1 spike if we only use 1 drill (the area under a circle), just to simplify things at the start (using the result from here):
$$V_{spike\_1\_drill}=r^3 - r\int_0^r \sqrt{r^2-x^2} dx$$
$$V_{spike\_1\_drill}=r^3\left(1-\frac{\pi}{4}\right)$$
And then I get stuck when trying to add another drill, I just can't visualize how to set up the remaining integration functions and limits such that it interacts properly with what I already have up above. I don't know if it would be a better approach to calculate the volume of the drilled out volume instead, but then you still have the problem of layering things correctly so you don't include any overlaps.
Any help/hints is appreciated.

REPLY [5 votes]: As suggested by Ted Shifrin in comments, place the center of the cube at the origin with its faces parallel to coordinate planes.

Then the equation of drills' cylindrical surfaces are,
$x^2 + y^2 = r^2$
$y^2 + z^2 = r^2$
$z^2 + x^2 = r^2$
Now take example of the left-out piece of solid on the right bottom corner (corner $2$) -
If you see the face shaded in dark blue and dark grey (corner $2$), that is to the right of $x^2 + z^2 = r^2$. Now at the intersection of other two cylinders,
$x^2 + y^2 = y^2 + z^2 = r^2 \implies x = \pm z$. As it's corner $2$, $x = - z$
So for $x \leq - z$, $y$ is bound below by the surface shaded in dark blue and above by the cylinder $x^2 + y^2 = r^2$.
Now at the intersection of $x = -z$ and $x^2 + z^2 = r^2, z = \pm \frac {r}{\sqrt2}$. As it's corner $2$, $z = - \frac{r}{\sqrt2}$
That leads to the bounds,
$-r \leq y \leq - \sqrt{r^2 - x^2}$
$\sqrt{r^2 - z^2} \leq x \leq - z$
$- r \leq z \leq - \frac{r}{\sqrt2}$
for the order of integration $dy ~ dx ~ dz$.
For $x \geq - z, $ you will have the same volume and then there are $8$ such corners.
So once you evaluate the integral, multiply by $16$.

Given your quest for further clarity on bounds, let me provide a bit more detail. The upper bound of $z$ is $ - \frac {r}{\sqrt2}$ because we divided the volume of corner $2$ into two. We did so because we did not have a single bound of $y$ for the whole face of corner 2 which is in the plane $y = -r$. For $x \leq - z$, $y$ is bound above by the cylinder $x^2 + y^2 = r^2$ and for $x \geq -z$, $y$ is bound above by the cylinder $y^2 + z^2 = r^2$. The bounds that I wrote in my answer above is for the part shaded in dark blue. For the part above plane $x = -z$ (shaded in dark grey), the bounds will be -
$- r \leq y \leq - \sqrt{r^2-z^2}$
$- x \leq z - \sqrt{r^2 - x^2}$
$\frac{r}{\sqrt2} \leq x \leq r$
for the order of integration $dy ~ dz ~ dx$. But the volume is same by symmetry so you can just evaluate the first integral I originally wrote and multiply it by $2$ to find the volume of corner $2$. Then multiply by $8$ for $8$ corners.
To further show what's going on, let me take corner $4$.
The surface marked in yellow is part of cube drilled by $x^2 + z^2 = r^2$; the part marked in light blue is by the drill $x^2 + y^2 = r^2$ and the part marked in green is by the drill $y^2 + z^2 = r^2$. As you can see, the plane $z = x$ is the intersection of drills $x^2 + y^2 = r^2$ and $y^2 + z^2 = r^2$ and should be used to split the volume integral to get right bounds of $y$ for the face of  corner $4$, which is in the plane $y = r$.