If you’ve been following *Chalkdust* for a while, you’re probably already aware of the MathsJam gathering. You might even have been yourself. For those who aren’t aware, it is an annual event where maths lovers get together to talk, play, sing and generally have fun with maths. One feature is a baking competition: attendees bring a maths-related cake and there are prizes for the prettiest cake, the tastiest cake and the best maths in a cake. This is the story of one of those cakes: the diagonal cross-sections of a Menger sponge.

#### Why a Menger sponge?

I was looking around for a cake subject, and had considered a famous fractal known as the Menger sponge. Then I came across an article that showed what it looks like when you make a diagonal cut through the middle. It was totally unexpected! I decided then and there that I *had* to make this cake.

A Menger sponge is a self-similar fractal made from a cube. To make a level 1 Menger sponge, divide a cube into 27 smaller cubes and remove the centre cube from each face and the cube in the very centre. To make a level 2 sponge, carry out the same process on each of the 20 remaining small cubes. And so on.

As this process is repeated, the volume of the sponge decreases, because part of it is removed at each stage. Conversely, the surface area increases, going from 6 square units in the original cube, to 8 square units in a level 1 sponge to $13 \frac{1}{3}$ in a level 2 sponge. If the process is repeated indefinitely, the volume approaches zero and the surface area approaches infinity. This makes an interesting prospect for a cake: the more levels you do, the less cake there will be, but the more icing you will need to cover it.

This odd behaviour comes about because the Menger sponge cannot comfortably fit into two dimensions, but neither can it fully occupy three; fractals such as this are somewhere in between, which can’t be measured by the usual concept of dimension. One way to measure the dimension of such a space is to calculate its Hausdorff dimension, which should be somewhere between 2 and 3 for a Menger sponge. If $c$ is the number of copies of itself that a fractal contains, and $1/s$ is the scale of those copies compared to the original, then the Hausdorff dimension of a self-similar fractal is given by

\begin{equation*}

\frac{\log c}{\log s}.

\end{equation*}

A Menger sponge contains 20 copies of itself (we divided the original cube into 27 sub-cubes, then removed 7 of them) and each copy is scaled by $1/3$, so the dimension of a Menger sponge is

\begin{equation*}

\frac{\log 20}{\log 3} = 2.727,

\end{equation*} (to 3 decimal places). However, a cake sits firmly in three dimensions, so my Menger sponge cake required some compromises.

## Compromise 1: Infinity

It was clear from the outset that I wasn’t going to produce an infinite Menger sponge cake. It would have been stale long before I got anywhere close. So I had to make a decision about what level I could go to.

One restriction was the size of the smallest cube of cake that can reasonably be cut and handled without crumbling. In trials, I found that cubes with 1 cm sides were too small to deal with, but 1.5 cm sides were just about comfortable. For a level $n$ cake, this would give an edge length of $1.5\times3^n$ cm, where $n$ is the number of times the fractal process is carried out. The following analysis made the decision easy.

## Compromise 2: Holes

The problem with holes in a cake is that, with nothing to support the parts above the holes, the cake is likely to collapse. I made my holes with chocolate cake, so even if I had been able to produce an infinite sponge it would not have had volume approaching zero (sorry, calorie counters). Note, for the seven level 1 holes I used bigger 4.5 cm chocolate cubes instead of building them from the smaller 1.5 cm cubes.

## Compromise 3: Construction

Officially, the construction method for a Menger sponge starts with a large cube and removes parts of it, as described above. I chose instead to build the cake up layer by layer using cubes. An unfortunate side effect of making the cake from smaller cubes is that there are visible lines where the cubes are joined together, where there would be no lines in a true Menger sponge. However, this also meant that there was plenty of icing throughout the cake to stop it being too dry, so I decided to live with it.

## The cut

All the artistry in this cake came directly from the maths. All I did was cut cubes and stick them together.

The main cut went through the midpoints of six edges, at an angle of 45° to the top face. I have to confess that I was shaking when I made this cut. I’d spent more hours than I care to admit constructing the cake, and there was every possibility that it would fall apart as I cut through it. Either that, or I would get the cut in the wrong place. The relief I felt when the star appeared in the centre was tremendous! Nobody has been mean enough to point out that the cut was slightly off—the small chocolate triangles around the edge should have been small stars, but only the bottom right one made it. Regardless of that, I was pleased with the result.

It’s fun to work out where the stars come from, so I won’t say too much about it. Think about the shape of the hole inside a Menger sponge, and about the shapes you can get by cutting a cube or cuboid at different angles.

I made two more cuts, both parallel to the first. The exact placement of these cuts wasn’t important—the diagonal cross-sections make interesting shapes wherever they are. There is a good animation to show this at Zachary’s blog; *spoiler alert*: the site also shows where the stars come from.

## Now it’s your turn!

If you would like to make your own Menger sponge sponge, here are a few tips to help you on the way.

I found the best type of cake for cutting to be a Madeira cake (which is a sponge cake, so we can officially call it a Menger sponge sponge). There are lots of recipes online—find one that suits you. Madeira cake is stronger and less crumbly than a Victoria sponge; chilling the cake first makes it even easier to cut it neatly, without making crumbs.

The level 1 holes require cubes with an edge length of 4.5 cm. This meant baking a deep cake—at least 5 cm, to give some allowance for cutting off the crust. Deep cakes can be difficult, as the outside cooks a lot quicker than the inside, so you can end up with burnt edges and a doughy centre. I recommend using a flower nail, which is a nail with a big flat head, normally used for mounting icing flowers; they’re available cheaply from eBay. Stand it upside down in the middle of the cake tin before pouring the dough in and it will conduct heat directly into the centre, helping it to cook at a similar rate to the sides. As a bonus, this also makes the cake rise more evenly and gives a flatter top.

This cake requires 7 large cubes (chocolate) and 540 small cubes (400 vanilla and 140 chocolate). It would therefore be helpful to have a quick and reliable method of cutting accurate cubes. Unfortunately, I’ve yet to find one!

You need something strong and firm to stick the cubes together. I used buttercream, and chilled the cake overnight before cutting it, to make the buttercream as firm as possible. This meant that when I made my first diagonal cut, the cake stayed in one piece. In an early trial I used jam, and that definitely didn’t work!

Finally, make sure that you have plenty of time set aside. The construction took nearly a whole day. When I finished making the cake, my joints were stiff from standing in the same position for so long, and I had ten minutes to gobble down a very late lunch before running to get the kids from school. Was it worth it? Well, looking back at the final result, I would have to say yes.