The Mandelbrot set is flat. People spent decades looking for its three-dimensional twin, and the search turned up something odd: there is no honest way to do it, only some very beautiful dishonest ones. This chapter shows what was found, and how a computer draws a shape that has no surface you can write down.
Common mix-up: the Mandelbulb is not "the 3D Mandelbrot set". There is no three-dimensional number system that multiplies the way complex numbers do, so there is no single natural 3D version. The Mandelbulb is one invented rule among many; it happens to look wonderful.
The Mandelbrot set comes from one rule, z → z² + c, repeated. The rule works because complex numbers can be multiplied: squaring a complex number doubles its angle and squares its length (Chapter 7). That one operation, rotate and stretch, is what folds the plane into spirals and bulbs.
To make a 3D version, the obvious plan is to find numbers with three parts instead of two, and multiply them the same way. William Rowan Hamilton spent years on exactly that problem in the 1830s and 1840s. He never found a three-part system. In 1843 he found a four-part one instead, the quaternions, written a + bi + cj + dk, and he famously carved the rule i² = j² = k² = ijk = −1 into a Dublin bridge. Quaternions multiply and divide, but they give up something: the order matters, so ij is not the same as ji.
Hamilton's failure was not bad luck. In 1877 Ferdinand Frobenius proved that the only number systems of this kind (finite-dimensional, real, associative, and with division) are the real numbers, the complex numbers and the quaternions. One, two, four. There is no three.
So people tried quaternions. Run z → z² + c with quaternions, start from zero, and look at the points that stay bounded. The result is disappointing in a precise way: it is the ordinary Mandelbrot set spun around its real axis, like a vase on a potter's wheel. Every slice through the axis is the same flat picture. Nothing new happens in the third direction, and the surface between the slices is smooth.
Quaternion Julia sets are more interesting, because their constant c can point in any direction. Alan Norton rendered them in 1982, and in 1989 John Hart, Daniel Sandin and Louis Kauffman ray traced them with a distance estimate, the technique this chapter ends on. They look like melted wax and coral. But they still have the rotational smoothness that quaternion squaring brings with it: the extra dimensions mostly get swept around, not folded.
Write a quaternion as a real part a plus a vector part v (the i, j, k bits). Squaring gives (a + v)² = a² − |v|² + 2a·v. The vector part of the answer points in the same direction as v; only its length changes.
Now iterate from zero with a quaternion constant c = a + v. Every number in the orbit is built from c by squaring and adding c, so every one of them is a real number plus some multiple of the same direction v. The whole orbit lives in a flat plane: the real axis together with the line through v. Inside that plane, quaternion arithmetic is just complex arithmetic with v playing the part of i.
So whether c escapes depends only on a and on the length of v, not on which way v points. Spin v around and nothing changes. That is the definition of a solid of revolution.
If no 3D number system exists, you can still invent a 3D operation that behaves like squaring in the way that matters to the eye: it rotates and stretches. That is the Mandelbulb's idea. Describe a point in 3D by its distance from the center, r, and two angles, θ (tilt down from the pole) and φ (the compass direction around it). Complex squaring doubles the one angle a flat point has. The Mandelbulb's "power" multiplies both angles and raises the distance to the same power.
Daniel White started looking for such a formula in 2007 and posted versions to the Fractal Forums community, where Paul Nylander and others joined in. The power-2 version, the most natural guess, looked lumpy and smeared. Raising the power to 8 changed everything: the shape broke out into bulbs on bulbs, valleys, spines and swirling canyons. White and Nylander's power-8 Mandelbulb, published in late 2009, is the version people mean today. White called the format "triplex" numbers: three-part values with this invented multiplication.
The iteration is the familiar one: start with v = c, replace v by vⁿ + c over and over, and keep the points whose orbit never runs off past a radius of 2. With n = 2 in a flat plane the formula is complex squaring again, so the bulb's equator echoes the Mandelbrot set. With n = 8 the picture has an eightfold flower around the pole, which is why the bulb looks like a cauliflower seen from above.
It is not a perfect fractal in the strict sense. The triplex power stretches space by different amounts in different directions (mathematicians say it is not conformal), so small copies of the shape get squashed rather than shrunk faithfully. Large regions of the surface come out as smooth "whipped cream" with no fine detail at all. That is the price of the cheat, and the reason people kept looking for other formulas.
To draw the bulb with ray marching (below) you need to know, for any point, roughly how far it is from the surface. The trick is to carry a running derivative along with the orbit: a number dr that measures how fast the orbit stretches small changes. Each step, dr becomes n · rⁿ⁻¹ · dr + 1, starting from dr = 1.
The formula is a three-dimensional borrowing of the Mandelbrot distance estimate, where it can be proved: for the flat set, the true distance lies between a quarter of 2|z|·ln|z| / |z′| and that value itself. For the bulb nobody has proved bounds like that, which is why renderers usually take a slightly shorter step than the estimate allows.
In 2010 Tom Lowe, also on Fractal Forums, gave up on number systems entirely. His Mandelbox uses folds: operations you can picture as bending space back on itself, the way you fold a sheet of paper. Each step does three things to a point.
With s = 2 the result looks like a box built of smaller boxes; with s = −1.5 it looks like a cathedral of arches and pipes. Folds and inversions are conformal where the triplex power is not: they preserve angles, so the small copies keep their shape. That is why Mandelbox renders often feel more architecturally crisp than Mandelbulbs.
Not every 3D fractal needs a formula hunt. The Menger sponge is Chapter 3's Sierpinski carpet with an extra dimension, and it is genuinely, exactly self-similar. Take a cube. Cut it into 27 smaller cubes, three by three by three. Remove the one in the very center and the six in the middle of each face: seven gone, twenty kept. Do the same to each of the twenty. Repeat forever.
Karl Menger described it in 1926, in his work on what "dimension" should mean for strange sets. After n steps there are 20ⁿ cubes, each a third the size of the last generation, so the dimension is log 20 / log 3 ≈ 2.7268. The volume is multiplied by 20/27 at every step, so it shrinks toward zero; the surface area grows at every step without limit. In the end the sponge is a shape with no volume and infinite surface, and every face of it is a Sierpinski carpet.
It holds a more surprising title too. Menger showed that the sponge is a universal curve: any one-dimensional shape you can draw, however tangled, can be found, bent but unbroken, somewhere inside it. A solid-looking object turns out to be, topologically, a curve.
The sponge is also the easiest of the three to draw with a distance estimate. The distance to a cube is simple to compute, and the holes are crosses of square tunnels, which are boxes too. The instrument below uses Iñigo Quilez's well-known version of that calculation.
| Shape | Year | Rule | Exactly self-similar? | Dimension |
|---|---|---|---|---|
| Menger sponge | 1926 | Keep 20 of 27 sub-cubes, forever | Yes | log 20 / log 3 ≈ 2.7268 |
| Quaternion M-set | 1980s | z² + c with quaternions | No: a spun Mandelbrot set | Surface: 3 (a spun boundary of dimension 2) |
| Quaternion Julia | 1982 | z² + c, c fixed, z a quaternion | No | Not generally known |
| Mandelbulb | 2009 | Triplex power n, usually 8 | No: copies are distorted | Not known |
| Mandelbox | 2010 | Box fold, ball fold, scale, add | Approximately, in places | Not known |
Start with a cube of side 1: volume 1, surface 6. After one step there are 20 cubes of side ⅓, so the volume is 20 × (⅓)³ = 20/27. After n steps it is (20/27)ⁿ, which goes to zero because 20/27 is less than one.
The surface is a race. Every step multiplies the number of cubes by 20 and each cube's face area by 1/9, so the surface of all the little cubes would grow like (20/9)ⁿ. Faces hidden where cubes touch take some of that back, but the exposed surface still grows by more than a factor of two per step. Any growth factor above one runs off to infinity.
This is a real ray marcher running on your processor, no 3D card involved. Every pixel fires a ray and steps along it using a distance estimate, exactly as described in the next section. It renders at a low internal resolution and refines in four passes, coarse blocks first, so you can drag to orbit and still see the shape. A plain sphere is there for comparison: watch how few steps it needs.
Drag to orbit. Each pass quarters the block size: 8, 4, 2 and finally 1 internal pixel. Iterations: sponge levels, or Mandelbulb escape iterations (the bulb uses at least 6).
Ordinary 3D graphics draws triangles. A fractal has no triangles: its surface has detail at every scale, so any mesh is either wrong or enormous. Classic ray tracing has a different problem. It fires a ray from the eye through each pixel and solves an equation for where the ray meets the surface, and for a fractal there is no equation to solve.
What you can often get is a distance estimator, or DE: a function that takes any point in space and returns a number guaranteed (or at least trusted) to be no bigger than the distance to the nearest bit of surface. It does not say which direction the surface is in. It only says: within this radius, there is nothing.
That is enough. Stand at the eye. Ask the DE how far the nearest surface is; call the answer d. A sphere of radius d around you is empty, so you can safely walk d along the ray. Ask again from the new point. Walk again. Far from anything the steps are big; as the ray approaches the surface, the safe distance shrinks and the steps shrink with it. Stop when d is smaller than the size of a pixel at that distance: you have hit. Stop when the ray has gone too far, or taken too many steps: you have missed. John Hart named this sphere tracing in 1996, because each step is the radius of an empty sphere.
t = 0 repeat up to max steps: p = eye + t · direction d = DE(p) if d < pixel size: hit t = t + d if t > far limit: miss
A ray marcher needs only that loop and a DE, which is why 3D fractals became common once graphics cards could run the loop for millions of pixels at once. The cost lives in two places. First, every step calls the DE, and a fractal DE iterates its own formula ten or twenty times. Second, rays that skim past an edge without hitting it crawl along in tiny steps, because the surface stays close the whole time. Look at the "average steps per ray" readout above: the sponge and the bulb need many more steps than the sphere, and most of those steps are spent on grazing rays.
Two practical details matter. The hit threshold should grow with distance, because a pixel covers more space far away; that also gives level-of-detail for free, since distant surfaces stop at coarser detail. And because fractal DEs are estimates, renderers often multiply each step by a "fudge factor" a little under 1, trading speed for not overshooting into the surface. The second instrument lets you push that factor too far and watch a ray tunnel through.
For simple shapes, the distance is exact. A sphere of radius 1 at the origin: |p| − 1. A box: a short formula with absolute values and maxima. Unions of shapes take the minimum of their distances; intersections take the maximum; cutting one shape out of another is the maximum of one and the negative of the other. The Menger sponge's DE is a box with crosses cut out at every scale, folded so one calculation serves every copy.
For escape-time fractals, the idea comes from the flat Mandelbrot set. In the 1980s it was shown how to estimate the distance from any outside point to the set using the orbit and its derivative; Peitgen and Saupe's The Science of Fractal Images (1988) presented it as the distance estimator method. Hart, Sandin and Kauffman carried it to quaternion Julia sets in 1989, and the Mandelbulb and Mandelbox DEs are the same recipe again: track how much the iteration stretches space, and divide the final radius by that stretch.
The same algorithm in two dimensions, where you can see every step. The ray starts at the large dot and heads toward a fractal. At each step the circle shows the distance estimate: the empty disc the ray may safely cross. Drag the dot to move the start, or tap anywhere else to aim. Shrink the threshold and watch the steps pile up near the edge; raise the step multiplier above 1 and the ray starts to overshoot, and with enough of it, tunnels into the set.
Threshold is in units of the view's width (10⁻³ means a thousandth of it). The shaded rings outside the shape are contours of the distance estimate, each one twice as far out as the last. For the Mandelbrot set the estimate is ½·|z|·ln|z| / |z′|, a safe lower bound; for the carpet and the circle it is exact or nearly so.
A hit point is not yet a picture. To shade it you need to know which way the surface faces, the normal. A DE gives it almost for free: the distance grows fastest in the direction pointing straight away from the surface, so sample the DE a hair to each side of the hit point and the differences give that direction. The viewer above does it with four extra DE calls per pixel, at the corners of a tiny tetrahedron.
Two cheap tricks then do most of the work of making a fractal look like an object. Ambient occlusion: step a short way out along the normal and ask the DE how far away the surface is; if it is much closer than the distance you stepped, you are in a crevice, so darken the point. Soft shadows: march a second ray from the hit point toward the light, and keep track of how closely it skims past anything on the way; a near miss means the point is in partial shadow, which gives soft penumbras without tracing any extra rays. Both reuse the same DE, so they cost steps, not new machinery.
Colour usually comes from the orbit, not the surface. The viewer tints the Mandelbulb by how close its orbit came to the center (an orbit trap, the subject of Chapter 17), and tints the sponge by which level of the recursion carved the nearest face.
Everything above is what dedicated programs do at much higher resolution, with more steps, real anti-aliasing and depth of field. Mandelbulber, a free open-source renderer, and Mandelbulb 3D are the two best known; both grew out of the same Fractal Forums community that found the shapes.
| Effect | How it uses the DE | Extra cost per pixel |
|---|---|---|
| Hit | Step by the DE until it is smaller than a pixel | Tens to hundreds of DE calls |
| Normal | Differences of the DE around the hit point | 4 (tetrahedron) or 6 (axis pairs) |
| Ambient occlusion | Compare the DE with the distance stepped out along the normal | About 5 |
| Soft shadow | March toward the light, track the closest approach | About 15 to 60 |
| Fog / glow | Count steps, or the closest miss, along the main ray | None: already computed |
Along the shadow ray, at distance t from the hit point, the DE says the nearest surface is h away. The ratio h/t is roughly the angle by which the ray cleared that obstacle, as seen from the hit point. Keep the smallest k·h/t along the ray, clamp it to between 0 and 1, and use it as the amount of light. A large k makes hard shadows; a small k makes soft ones. Iñigo Quilez's write-up of this trick is the one most renderers cite.