The volume of the 4-ball
building up the intuition for higher dimensions
This is the first entry in the high-dimensional space blog series.
In the familiar low-dimensional spaces around us, we have a way to quantify how much room something takes up.
In one dimension it is the length, in two dimensions it is the area, and in 3D we have the volume.
What do we call this notion with higher dimensions? It’s called the hypervolume1.
The two most basic geometric objects we have are cubes and balls. The unit cube is not as interesting at first, because it always occupies $1 \times 1 \times … \times 1 = 1$ unit of space regardless of its dimension.
In contrast, the ball is a lot more fun.
Some definitions
We denote by $V_{n}(R)$ the hypervolume of the $n$-ball, which is the generalization of a ball in $n$-dimensional space.
The closed $n$-ball with center $\mathbf{x} \in \mathbb{R}^{n}$ and radius $R$ is defined as
\[B(\mathbf{x}; R) := \lbrace \mathbf{y} \in \mathbb{R}^{n} \mid d(\mathbf{x}, \mathbf{y}) \leq R \rbrace.\]So it’s just all of the points around a point $\mathbf{x}$ that are at most $R$ units away from $\mathbf{x}$ based on some distance metric $d$.
In this post we are concerned with Euclidean distance $d(\mathbf{x}, \mathbf{y}) = \lVert\mathbf{x} - \mathbf{y} \rVert_{2}$, and the ball centered at the origin (so $\mathbf{x} = 0$). Thus, our ball definition simplifies to just a set containing points $\mathbf{p} = (p_{1}, …, p_{n})$, such that
\[p_{1}^{2} + p_{2}^{2} + ... + p_{n}^{2} \leq R^{2}.\]That’s all nice, but how do we compute the hypervolume of an $n$-ball?
Naturally, we start from $n=1$ and build up.
$1$-ball
The $1$-ball of radius $R$ is an interval $[-R, R]$ around the origin. It has a length of $R - (-R) = 2R$, which is also its 1-dimensional hypervolume $V_{1}(R) = 2R$.
It is not very round, is it? However, it is in fact the roundest thing one can ever find in 1D.
$2$-ball
The closed $2$-ball is our good old friend, the disk. From school we know by heart that it has area equal to $V_{2}(R) = \pi R^{2}$.
$3$-ball
The $3$-ball is the most intuitive one, in that it is what you would call a ball in everyday life. It has volume equal to
\[V_{3}(R) = \frac{4}{3}\pi R^{3}.\]We again learn it by heart during school.
However, in multivariate calculus we are able to show it with the aid of the following idea: a ball is a vertically stacked arrangement of two-dimensional disks:
With our knowledge of integrals, we know that we can represent this infinite sum of disks as an integral as we move in the $z$-axis. However, we also notice that each disk has its own radius that depends on the particular value of $z$. Geometrically, we can show it as this:
For each disk with height $h$, the radius is
\[r_{h} = \sqrt{R^2 - h^2}, \tag{1}\]and its area is $\pi r_{h}^2$. Thus, the total volume is
\[V_{3}(R) = \int_{-R}^{R}\pi r_{h}^{2}\,dh = \frac{4}{3}\pi R^{3}.\]Calculating the integral
No tricks needed here, we can just evaluate it head on:
\[\begin{align} V_{3}(R) &= \int_{-R}^{R}\pi r_{h}^{2} \,dh \\ &= \int_{-R}^{R}\pi\left(\sqrt{R^{2} - h^{2}}\right)^{2}\,dh \tag{from (1)} \\ &= \pi\int_{-R}^{R}(R^2 - h^2) \,dh \\ &= \pi \left(R^2 h - \frac{h^3}{3} \right) \Big\vert_{-R}^{R} \\ &= \pi (2R^3 - 2\frac{R^3}{3}) \\ &= \frac{4\pi}{3}R^{3}. \tag*{$\Box$} \end{align}\]Which brings us to the case of the 4-ball. What’s one more dimension?
4-ball
Unfortunately, we can’t visualize the $4$-dimensional ball.
We don’t know what a 4-dimensional ball looks like; all we know is that it is composed of points $\mathbf{p} = (x, y, z, w)$ such that
\[\lVert \mathbf{p} \rVert _{2}^2 = x^2 + y^2 + z^2 + w^2 \leq R^{2}.\]How can we calculate the (hyper-)volume of this thing that we can’t visualize?
To progress, we actually have to go backwards.
Retracing our steps
Upon closer inspection, we can see that our stack-of-disks explanation for the $3$-ball is just as applicable for the two-dimensional disk as well. The disk is a stack of horizontal intervals, which are actually $1$-balls as we discussed earlier!
Again, each $1$-ball has some radius $r$ that depends on the current $y$, with ${r_{y} = \sqrt{R^2 - y^2}}$ as $y$ moves along $[-R, R]$. They have a length of $2 r_{y}$, which we’ll sum up to obtain the area.
The integral here is actually slightly trickier than the 3-dimensional case, but it turns out that
\[V_{2}(R) = \int_{-R}^{R}2 r_{y}\,dy = \pi R^2,\]as we would expect.
Calculating the integral
We start off with:
\[\begin{align} V_{2}(R) &= \int_{-R}^{R}2 r_{y} \, dy \\ &= 2\int_{-R}^{R}\left(\sqrt{R^{2} - y^{2}}\right) dy \\ &= 4\int_{0}^{R}\left(\sqrt{R^{2} - y^{2}}\right) dy. \tag{by symmetry} \end{align}\]We then apply the change of variables
\[\begin{align} y &= R \sin\theta, \\ dy &= R \cos\theta \, d\theta. \end{align}\]which also means the limits of integration $(0, R)$ change to $(0, \pi / 2)$.
Now,
\[\begin{align} V_{2}(R) &= 4\int_{0}^{\pi / 2}\sqrt{R^2 - (R\sin\theta)^2}R\cos\theta \, d\theta \\ &= 4R^2\int_{0}^{\pi / 2}\sqrt{1 - \sin^{2}\theta} \cos\theta \, d\theta \\ &= 4R^2\int_{0}^{\pi / 2}\sqrt{\cos^{2}\theta} \cos\theta \, d\theta \\ &= 4R^2\int_{0}^{\pi / 2}\cos^{2}\theta \, d\theta. \tag{$\cos\theta \geq 0$} \end{align}\]It is known that $\int_{0}^{\pi / 2}\cos^{2}\theta \, d\theta = \frac{\pi}{4}$, but it is also easy to derive (see the appendix). Plugging it in we have
\[\begin{align} V_{2}(R) &= 4R^2 \cdot \frac{\pi}{4} \\ &= \pi R^2. \tag*{$\Box$} \end{align}\]This even works for the $1$-ball (interval) as well, if we consider it to be a stack of points (zero-dimensional balls), each of volume $V_{0} = 1$. The integral for the 1D case is just
\[\begin{align} V_{1}(R) &= \int_{-R}^{R}1\, dx \\ &= 2R. \end{align}\]To summarize, we see that constructing the $n$-dimensional ball is possible by vertically stacking $(n-1)$-dimensional balls along the new dimension and summing up their respective hypervolume.
Back to the $4$-ball
Before we continue, I want to sketch one aspect of the $4$-ball.
- When we slice the 1D interval on $x$, we get a point.
- When we slice the disk along the new dimension $y$, we get an interval (a $1$-ball).
- When we slice the $3$-ball along the new dimension $z$, we get a disk (a $2$-ball).
That means that when we slice the $4$-ball, we’re going to get a $3$-ball when we look at the cross-section.
This is my best attempt at actually visualizing this idea, slicing across the new dimension $w$:
Let’s not be fooled, these balls are actually not intersecting. All of the cross-sections live in their own three-dimensional hyperplane with a constant $w$. None of them share any points, and they have zero thickness2 along $w$. It’s also incredibly interesting how the cross-sections stay quite large for most of the way, and only collapse near $w=R$.
This idea of summing up cross-sections is called Cavalieri’s principle, and the rigorous version is known as Fubini’s theorem.
The $4$-ball, revisited
We’re back here again, but equipped with new machinery. Our idea is simple: Given a fixed $w$, the points $\mathbf{p} = (x, y, z, w)$ are in the cross-section
\[x^2 + y^2 + z^2 \leq R^2 - w^2 \tag{2}\]of the $4$-ball centered at the origin with radius $R$. We know that (2) is the definition of a $3$-ball with radius $r_{w} = \sqrt{R^2 - w^2}$ and volume $\frac{4}{3}\pi r_{w}^3$. We can sum their volumes together over $w$ to obtain our prize, the hypervolume of the $4$-ball.
We express this as the integral
\[V_{4}(R) = \int_{-R}^{R} \frac{4}{3}\pi r_{w}^{3}\,dw\]which turns out to be… with drum roll please…
\[\boxed{V_{4}(R) = \frac{1}{2}\pi^2 R^{4}}.\]Calculating the integral
Our approach is similar to the 2-dimensional case, which actually isn’t surprising.
We start off with:
\[\begin{align} V_{4}(R) &= \int_{-R}^{R}\frac{4}{3}\pi r_{w}^3 \, dw \\ &= \frac{4\pi}{3}\int_{-R}^{R}\left(\sqrt{R^{2} - w^{2}}\right)^{3} \, dw \\ &= \frac{8\pi}{3}\int_{0}^{R}\left(R^{2} - w^{2}\right)^{3/2} dw. \tag{by symmetry} \end{align}\]We again apply the change of variables
\[\begin{align} w &= R \sin\theta, \\ dw &= R \cos\theta \, d\theta. \end{align}\]and that also means the limits of integration $(0, R)$ change to $(0, \pi / 2)$.
Now,
\[\begin{align} V_{4}(R) &= \frac{8\pi}{3}\int_{0}^{\pi / 2}\left(R^2 - R^2\sin^2\theta\right)^{3/2} R\cos\theta \, d\theta \\ &= \frac{8\pi}{3}R^{4}\int_{0}^{\pi / 2} \left(\cos^{2}\theta\right)^{3/2} \cos\theta \, d\theta \\ &= \frac{8\pi}{3}R^{4}\int_{0}^{\pi / 2} \cos^{4}\theta \, d\theta. \tag{$\cos\theta \geq 0$} \end{align}\]It is known that $\int_{0}^{\pi / 2}\cos^{4}\theta \, d\theta = \frac{3\pi}{16}$, and we derive it in the appendix to keep things short. Plugging it in, we arrive at
\[\begin{align} V_{4}(R) &= \frac{8\pi}{3}R^{4} \cdot \frac{3\pi}{16} \\ &= \frac{1}{2}\pi^2 R^4. \tag*{$\Box$} \end{align}\]What’s really nice is that this method extends to the $5$-ball, a $100$-ball, or any arbitrary $n$-ball hypervolume by summing up cross-sections of $(n-1)$-balls.
Its recursive nature also allows us to obtain closed-form solutions for any high-dimensional ball. We’ll explore general properties of the $n$-ball in the next post.
Appendix
Deriving $\int_{0}^{\pi / 2}\cos^2\theta \, d\theta$
This one is kinda pretty. Substituting $\theta \to \frac{\pi}{2} - \theta$, we have the useful
\[\int_0^{\pi/2}\cos^2\theta\, d\theta = \int_0^{\pi/2}\sin^2\theta\, d\theta.\]Over the same interval we sum them together:
\[2\int_{0}^{\pi/2}\cos^2\theta\,d\theta = \int_0^{\pi/2}(\cos^2\theta + \sin^2\theta)\,d\theta = \frac{\pi}{2},\]making use of $\sin^2\theta + \cos^2 \theta = 1$.
Therefore,
\[\int_{0}^{\pi / 2} \cos^2 \theta \, d\theta = \frac{1}{2}\cdot\frac{\pi}{2} = \frac{\pi}{4}. \tag{3}\]Deriving $\int_{0}^{\pi / 2}\cos^{4}\theta\,d\theta$
Note that we have $\cos^{4}\theta = \cos^{2}\theta(1-\sin^{2}\theta)$, meaning that we can write everything as
\[\int_{0}^{\pi/2}\cos^4\theta\,d\theta = \int_{0}^{\pi/2}\cos^2\theta\,d\theta - \int_{0}^{\pi/2}\cos^2\theta\sin^2\theta\,d\theta.\]The first term, the one with $\cos^{2}\theta$, is exactly what we want. We showed that it is equal to $\frac{\pi}{4}$ in the previous section.
For the second term, we can use the double angle identity $\sin\theta\cos\theta = \frac{1}{2}\sin 2\theta$:
\[\int_{0}^{\pi / 2}\cos^2\theta\sin^2\theta\, d\theta = \frac{1}{4}\int_{0}^{\pi / 2}\sin^2 2\theta\, d\theta.\]Applying the change of variables $u = 2\theta$, so that $d\theta = \frac{1}{2}\,du$ and the limits become $[0, \pi]$:
\[\frac{1}{4}\int_{0}^{\pi / 2}\sin^2 2\theta \, d\theta = \frac{1}{8}\int_{0}^{\pi} \sin^2 u \, du.\]We can reuse our previous result. Since $\sin^2(\pi - u) = \sin^2 u$, the halves $[0, \frac{\pi}{2}]$ and $[\frac{\pi}{2}, \pi]$ contribute equally, so
\[\begin{align} \int_{0}^{\pi}\sin^2 u \, du &= \int_{0}^{\pi/2}\sin^2 u \, du + \int_{\pi/2}^{\pi}\sin^2 u \, du \\ &= 2\int_{0}^{\pi/2}\sin^2 u \, du \\ &= 2 \cdot \frac{\pi}{4} \\ &= \frac{\pi}{2}, \end{align}\]where we used $\int_0^{\pi/2}\sin^2 \theta\, d\theta = \int_0^{\pi/2}\cos^2 \theta \, d\theta = \frac{\pi}{4}$ from (3). Therefore
\[\int_{0}^{\pi /2} \sin^{2}2\theta \, d\theta = \frac{1}{2} \cdot \frac{\pi}{2} = \frac{\pi}{4}.\]Putting it all together:
\[\begin{align} \int_{0}^{\pi / 2}\cos^4 \theta\, d\theta &= \int_{0}^{\pi / 2}\cos^2 \theta \, d\theta - \frac{1}{4}\int_{0}^{\pi /2} \sin^{2}2\theta\,d\theta \\ &=\frac{\pi}{4} - \frac{1}{4}\cdot\frac{\pi}{4} \\ &= \frac{\pi}{4} - \frac{\pi}{16} \\ &= \frac{3\pi}{16}. \tag*{$\Box$} \end{align}\]-
More formally, the hypervolume of a subset of $\mathbb{R}^{n}$ corresponds to its $n$-dimensional Lebesgue measure. ↩
-
It might be more honest to draw them as flat disks when expanding towards $w$ to emphasize this, however then it looks just like the 3D case. Also, that would be worse as we’d be showing the cross-sections as disks rather than $3$-balls! ↩