The Menger sponge is the fractal you get by starting with a cube, dividing each face into a 3 by 3 grid (like a Rubik’s cube) and removing the middle square of each face and everything behind it.

That’s M1, the Menger sponge at the 1st stage of its construction.

The next stage repeats this process on all the little cubes that make up what’s left.

That’s M2.

Repeat the process over and over, and in the limit you get Menger’s sponge, a fractal with zero volume and infinite area!This business of zero volume and infinite area may sound unreal, but the steps along the way to the limit are very tangible.

Here’s a video by Aaron Benzel that let’s you fly through M3, and watch what happens if you split M3 apart.

You can compute the volume and area at each stage to show thatandFrom these equations you can see that you can make the volume as small and you’d like, and the area as large as you like, by taking n big enough.

And in case that sounds a little hand-wavey, we can get more concrete.

Here’s a little code to find exactly how big a value of n is big enough.

from math import log, ceil def menger_volume(n): return (20/27.

)**n def menger_area(n): return 2*(20/9.

)**n + 4*(8/9.

)**n def volume_below(v): if v >=1: return 1 else: n = log(v)/log(20/27.

) return int(ceil(n)) def area_above(a): if a < 2: return 1 else: n = (log(a) – log(2))/log(20/9.

) return int(ceil(n)) n = volume_below(0.

001) print( menger_volume(n) ) n = area_above(1000) print( menger_area(n) ) Related postsCode to slice open a Menger spongeRandom Sierpinski triangleSierpinski triangle strikes again.. More details