Volume of cube section above intersection with plane

Solution 1:

For $1 \le \alpha \le 2$, it is much easier to visualize the integral by subtracting instead of adding pieces of the volume.

As shown in the picture below, when $1 \le \alpha \le 2$, the volume of cube section below intersection of the plane $x + y + z = \alpha$ is the difference of the volume of one big tetrahedron with width/height/depth $= \alpha$ with three smaller ones with width/height/depth $= \alpha-1$. So the volume above the intersection becomes

$$1 - \left( \frac16 \alpha^3 - 3 ( \frac16 (\alpha-1)^3 )\right) = 1 - \frac16 \alpha^3 + \frac12 (\alpha-1)^3$$

Cube section 1

Update

About the question whether this argument can be extended to higher dimension, the answer is yes. Let's look at the 3-dimension $2 \le \alpha \le 3$ case first.

Cube section 2

As one increases $\alpha$ beyond $2$, the three tetrahedron in first figure start overlap. As shown in second figure, the intersection of the three tetrahedra are now three even smaller tetrahedra of width/height/depth = $\alpha -2$.

Previous way to compute the "volume" of cube section below the plane $x + y + z = \alpha$ now subtract too much from this three even smaller tetrahedron. One need to add them back. As a result, the volume above the plane becomes:

$$\begin{align}&1 - \left( \frac16 \alpha^3 - 3(\frac16 (\alpha-1)^3 + 3(\frac16 (\alpha-2)^3 \right)\\ = & 1 - \frac16 \alpha^3 + \frac12 (\alpha-1)^3 - \frac12 (\alpha-2)^3\\ = & \frac{(3-\alpha)^3}{6} \end{align}$$

Let us switch to the $k$-dimension case. To compute the "volume" of the hypercube section above the hyperplane $x_1 + \ldots + x_k = \alpha$, the first step is to subtract the volume of a $k$-simplex of size $\alpha$ from 1.

  1. if $\alpha \le 1$, we are done.
  2. if $\alpha > 1$, we over subtract the volume of $\binom{k}{1}$ simplices of size $\alpha-1$ and need to add them back.
  3. if $\alpha > 2$, the $\binom{k}{1}$ simplices of size $\alpha-1$ in step 2 intersect and the intersection is a union of $\binom{k}{2}$ $\;k$-simplices of size $\alpha-2$. This means in step 2, we have added back too much and need to subtract the volume again.

Repeat these arguments and notice in the middle of the process, we need to either add or subtract the volumes of $\binom{k}{i}$ $\;k$-simplices of size $\alpha-i$. The "volume" of interest finally becomes:

$$1 -\sum_{i=0}^{\lfloor \alpha \rfloor} (-1)^i \binom{k}{i} \frac{(\alpha-i)^k}{k!}$$

Solution 2:

Put $\alpha:=1+\beta$ with $0<\beta<1$. Then the plane $x+y+z=1+\beta$ cuts the top face of the cube in the segment connecting $(0,\beta)$ with $(\beta,0)$ at $z$-level $1$, and cuts the bottom face of the cube in the segment connecting $(\beta,1)$ with $(1,\beta)$ at $z$-level $0$.

Consider the vertical stalk through a fixed point $(x,y)$ on the bottom face $Q$ of the cube. It intersects your polyhedron $P$ in a vertical segment whose length $\ell(x,y)$ is given by $$\ell(x,y)=\cases{0&$(x+y<\beta)$ \cr x+y-\beta\quad&$(\beta\leq x+y\leq \beta+1)$ \cr 1&$(x+y>\beta+1)$\cr}\ .$$ The volume of $P$ is then given by $$\eqalign{{\rm vol}(P)&=\int\nolimits_Q \ell(x,y)\ {\rm d}(x,y)\cr &=\int_0^\beta\int_{\beta-x}^1 (x+y-\beta)\ dy\ dx+\int_\beta^1\int_0^{1+\beta-x}(x+y-\beta)\ dy\ dx +{1\over2}(1-\beta)^2\ .\cr}$$

Solution 3:

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}$$

Solution 4:

This can be interpreted as trying to find $1$ minus the CDF of the sum of three uniformly distributed random variables in $[0, 1]$. The PDF is the quadratic B-spline given by

$$f(x)=\begin{cases} \frac{x^2}{2} & x\in[0,1] \\ \frac{x^2}{2} - \frac{3(x-1)^2}{2} & x\in[1,2]\\ \frac{x^2}{2} - \frac{3(x-1)^2}{2} +\frac{3(x-2)^2}{2} & x\in[2,3] \end{cases} $$

The CDF follows from this by integration.

Solution 5:

The object created by slicing is a polyhedron, obviously. Then, the volume of a polyhedron can be computed conveniently by decomposing it into tetrahedra and adding up the (signed) volumes of these tetrahedra. You can find an explanation of the technique in this document. There is also a paper by Michael Kallay on the same subject that gives slightly simpler formulae. Ask again if this is of interest and you can't find it.

All of this is still computation of volume intergals, really. But, in the case of tetrahedra, the values of the integrals can be expressed by simple closed-form formulae, so the integration is somewhat hidden.

You'll still need to consider several cases (depending on where/how the plane slices the cube).

Actually, I think there are three cases, depending on whether the planar slice has three, five, or six sides. These are shown in the picture below:

cube slices

The blue and brown slices are 3-sided, the red and green ones are 5-sided, and the pink one is 6-sided.