You are currently browsing the tag archive for the ‘fractals’ tag.

In the last post we looked at the Mandelbrot set, a beautiful 2d fractal with infinite complexity along its boundary. The challenge is to find a three dimensional version of the set, the Mandelbulb, which we can then lovingly render with dynamic lighting and shadows.

The three-dimensional Mandelbulb

Mathematicians were doing work related to the Mandelbrot set in the very early 20th century. However, it wasn’t until the 1980s that computers were powerful enough to draw high quality pictures of it. The Mandelbulb is even more complicated, and requires even more computational power (once you’ve located the object, you then need to render it — this is where the computer spends most of its time). This is why we’ve not been able to see pictures of the Mandelbulb until very recently.

The first problem is determining the rule which will generate the Mandelbulb. For technical reasons there is no such thing as a 3d analogue of the complex numbers (the quaternions are the closest 4d analogue) and thus coming up with the ‘correct’ map is tricky. The key is to re-use the ideas of multiplying the radius, rotating the angles and then translating. Mathematicians use a set of coordinates for 3d space called spherical polar coordinates, which tell you location of a point in terms of the distance from the origin, $r$, and two other angles, $\theta$ and $\phi$.

For those with the appropriate background, the map which takes you from one point to the next is given by composing a stretching and rotation:

$(r,\theta,\phi) \to (r^n,n\theta,n\phi)$

with a constant translation:

$(x,y,z) \to (x+a,y+b,z+c)$

A zoom of the Mandelbulb

We use spherical coordinates to do the first transformation, and cartesian coordinates to do the second. If the sequence of iterates remains bounded when using the parameters a, b and c then the point with coordinates (a,b,c) is part of the Mandelbulb. If the sequence diverges, then it is not.

We’ve introduced a parameter n into the map — this tells you how much to rotate the angles. If n is 2, that means we double the angles. If n is 3 we triple them, and so forth (in the 2d Mandelbrot set we only looked at n = 2). In three dimensions, the low values of n don’t give us a very interesting object. As we increase n the object gets progressively more complex. It turns out that n = 8 gives a nice balance between beauty and novelty.

Another zoom of the Mandelbulb

Now that we have the ingredients, all we need to do is complete the renders. This is a very computationally intensive process, but the results are worth it! By playing around with the color of lighting and the depth of shadows, we can create some truly stunning images — certainly the most striking examples of fractal beauty that I’ve ever seen.

All of the information in this post is sourced from the Mandelbulb page at Skytopia, which is well worth a visit!

It sounds like a poorly thought through Pokémon name from 1995. But in fact the Mandelbulb is a beautiful three-dimensional mathematical object that generalises the two-dimensional Mandelbrot set, which has become well known as an example of a fractal.

The Mandelbrot set (black) with additional coloring (blue to white).

The Mandelbrot set is generated by a very simple idea: we take a point in the 2d plane, and use that as the input to a rule which generates a new point. We then use the new point as the input to the same rule, to generate a third point, then a fourth point, and so on. If we start with the point $z_0 = 0$ (the origin) we generate the sequence $z_1, z_2, z_3,\dots$ from it. This simple but powerful idea, iteration, is at the heart of chaos theory and fractal images.

The rule that generates the Mandolbrot set is given by the following formula, where $c$, $z_n$ and $z_{n+1}$ are complex numbers:

$z_{n+1} = z_n^2 + c$

If we think of a point in the plane defined by its magnitude (or distance from the origin) and the angle it makes with the horizontal, then this rule simply says: “to get the next point in the sequence you square the magnitude, double the angle, and then shift the point by a constant amount $c$.”

There are two possibilities when we start iterating points in this way: for some values of $c$ the points get further and further away from where they started, and head off to infinity (we say that the sequence diverges) but for other values of $c$ they never stray further away than some limit (in which case we say that the sequence is bounded.) To make the Mandelbrot set we color a point $c$ black if the sequence for that value of $c$ is bounded, and leave it white if the sequence diverges.

The boundary of the Mandelbrot set is infinitely complicated: no matter how far you zoom into it, you never stop seeing more and more detail. This never-ending detail qualifies it to be a fractal. We can make prettier pictures by coloring the points that diverge according to how long they take to diverge: in the image above the points that diverge quickly are shown in blue, whereas points that diverge only after many iterations (i.e. they’re nearly in the Mandelbrot set) are shown in white.

The challenge of the Mandelbulb is to extend this concept into three dimensions, to allow fully 3d renders that incorporate dramatic lighting and shadows. As we’ll see this isn’t as easy as it sounds at first.