TITLE: Volume of cube section above intersection with plane
QUESTION [11 upvotes]: Suppose we have a unit cube (side=1) and a plane with equation $x+y+z=\alpha$. I'd like to compute the volume of the region that results once the plane sections the cube (above the plane). There are three cases to analyze, and I can't quite visualize one of them.
Case 1: $0 \le \alpha < 1$
In this case, the section looks like a triangle, and the volume of interest is 1 minus the volume of the lower left tetrahedron, i.e., $$V = 1 - \int_0^\alpha \int_0^{\alpha-x} \int_0^{\alpha-x-y} dz\,dy\,dx = 1 - \frac{\alpha^3}{6}.$$
Case 3: $2 < \alpha \le 3$.
Here, the section is again a triangle, and the volume of interest is the upper right tetrahedron, i.e., $$V = \int_{\alpha-2}^1 \int_{\alpha-x-1}^1 \int_{\alpha-x-y}^1 dz\,dy\,dx = \frac{(3-\alpha)^3}{6}.$$
Case 2: $1 \le \alpha \le 2$.
This is where I'm sort of stuck. The section is a hexagon, with one of the inequalities being $\alpha-x-y \le z \le 1$, hence the innermost integral should be $\int_{\alpha-x-y}^1 dz$. The projection of the hexagon slice onto the $xy$-plane is described by $y \ge \alpha-1-x$ and $y \le \alpha-x$. Hence, the area of the hexagon projection is $$ A = \int_0^{\alpha-1} \int_{\alpha-x-1}^1 dy\,dx + \int_{\alpha-1}^1 \int_0^{\alpha-x} dy\,dx$$
Question: When I move from $A$ to $V$ am I allowed to distribute the innermost integral between the summing terms, i.e. is it correct to write $$V = \int_0^{\alpha-1} \int_{\alpha-x-1}^1 \int_{\alpha-x-y}^1 dz\,dy\,dx + \int_{\alpha-1}^1 \int_0^{\alpha-x} \int_{\alpha-x-y}^1 dz\,dy\,dx \quad ??$$
If not, what's the approach?
Note that there's a neat connection between this problem and figuring out the CDF of a sum of a random variable that has triangular distribution with support on $[0,2]$ and a random variable with uniform distribution on $[0,1]$ (assuming independence). Hence, I know what the answer should be for Case 2 because I worked out the convolution, but I just want to figure out the answer geometrically as well.

REPLY [3 votes]: I had the same problem and I came up with the
following very simple (and very implicit) formula (I'm unfamiliar with stackexchange's maths
notation, forgive me for posting Mathematica code):
volPart[q___, r_] := Module[{v, d, t, h},
  v = Select[Chop[{q}], (# =!= 0) &];
  d = Length[v];
  t = Tuples[{-1, 1}, d];
  h = (t/2).v + r;
  (HeavisideTheta[h] h^d).(Times @@@ t)/(d! Times @@ v)
]

The return value of volPart[q1, q2, ..., r] should be a volume of a part of the unit hypercube centered at $\{0, 0, ...\}$ above the hyper-plane $x1 q1 + x2 q2 + ... + r > 0$. By appropriate scaling and offsetting the arguments, the formula could be generalised to other cases.
For zero valued numerical coefficients in linear form the formula effectively reduces to lower dimension case. For symbolic coefficients approaching zero, the limit must be taken, though.
The basic idea is that the volume above the hyper-plane for fixed arguments
is a linear combination of vertices' "heights" above (but only these
above) the hyper-plane raised to the power of effective dimension. Note
the alternating sign for each connected vertex (Times @@@ t).
In your particular case this reduces to:
$$\frac{\alpha^3{\theta}(-\alpha)+3(1-\alpha)^3{\theta}(1-\alpha)-3(2-\alpha)^3{\theta}(2-\alpha)+(3-\alpha)^3{\theta}(3-\alpha)}{6}$$
By expanding $\theta$, this could also be rewritten as:
$$\begin{cases} 1 & \alpha \le 0\\ 1-\frac{\alpha^3}{6} & 0 < \alpha \le 1 \\ \frac{\alpha^3}{3}-\frac{3 \alpha^2}{2}+\frac{3 \alpha}{2}+\frac{1}{2} & 1 < \alpha \le 2 \\ -\frac{(\alpha-3)^3}{6} & 2 < \alpha \le 3 \\ 0 & 3 < \alpha\end{cases}$$