Understanding the Mandelbrot Fractal

By Paul Butler – August 15, 2018

The Mandelbrot fractal is a shape with incredible visual complexity: as you enlarge it, new details emerge at every level. It's quite possible to explore areas of the fractal that nobody has ever seen before.

A rendering of a Mandelbrot fractal.

Given this complexity, you might assume that the math is beyond your grasp. In fact, the image of a Mandelbrot fractal above was generated with just addition and multiplication. Let's start with a refresher on imaginary and complex numbers, and then build on that to understand where the Mandelbrot fractal comes from.

Imaginary Numbers

One of the core tools in math is abstraction: the idea that we can take a symbol, like xx, and use that as a placeholder for an unknown value.

For example, if I say x2=4x^2 = 4, you can figure out that either x=2x = 2 or x=2x = -2. If I say y2=4y^2 = -4, we know that there is no real value of yy that I could possibly fill in to satisfy this equation. But if we can use symbols to represent an unknown number, why not use symbols to represent an unknowable number?

It turns out that, at least in one case, this is a useful thing to do: the imaginary numbers arise from defining ii such that i2=1i^2 = -1, even though we can't solve ii in the traditional sense. ii is called the imaginary unit, and the remaining imaginary numbers are just multiples of ii.

1.0i×1.0i=1i2=11.0i \times 1.0i = 1i^2 = -1

Let's have a look at what happens when we multiply two imaginary numbers together. Click the sliders above to change the numbers. Notice how the iis from each side combine into i2i^2, which we can replace by 1-1 because we decided earlier that i2=1i^2 = -1.

Complex Numbers

When we add normal numbers to imaginary numbers, we call the resulting numbers complex. These numbers have two parts: a real part and an imaginary part. We can represent complex numbers visually by extending the imaginary sliders above to have a horizontal component.

1+0i1 + 0i

The above plot is interactive; you can change the number by clicking anywhere in the chart area. We'll see more of these, so practice using the selector by finding the number 0.50.1i0.5 - 0.1i.

Complex Addition

Adding complex numbers is straightforward: we add the real parts, and add the imaginary parts, but we keep them separate.

a=1+1ia = 1 + 1ib=1.5+0.4ib = -1.5 + 0.4ia+b=0.5+1.4ia + b = -0.5 + 1.4i

Throughout this page, complex number plots shown in red are interactive. Click within the plot to change the value, and see how the other values (shown in blue) change.

Complex Multiplication

Multiplication is a bit more tricky, but it's really just an application of the FOIL method followed by a simplification using the rule i2=1i^2 = -1.

For example, consider (a+bi)×(c+di)(a + bi) \times (c + di). By FOIL we get ac+adi+bci+bdi2ac + adi + bci + bdi^2. Replacing i2i^2 for 1-1, we can simplify this to (acbd)+(ad+bc)i(ac - bd) + (ad + bc)i.

a=1+1ia = 1 + 1ib=0.5+1.2ib = -0.5 + 1.2ia×b=1.7+0.7ia \times b = -1.7 + 0.7i

Squaring a complex number is just a special case of multiplication: (a+bi)2=(a2b2)+(2ab)i(a + bi)^2 = (a^2 - b^2) + (2ab)i.

A Curious Pattern

It turns out that if we combine complex multiplication and addition in a certain way, an interesting pattern emerges. First, we start with any complex number cc, and start with z=0+0iz = 0 + 0i. Then, we set zz2+cz \gets z^2 + c over and over again.

Try picking a value of cc below, and then hit the step button a bunch of times. Each time you hit step, the value of zz is set to z2+cz^2 + c.

For each value of cc, one of two things will happen: either the point will fly out of the outer ring (maybe after thrashing around within it for a bit), or the point will settle into a pattern in which it will apparently never leave the ring.

c=0.3+0.5ic = 0.3 + 0.5iz=0+0iz = 0 + 0iz2=0+0iz^2 = 0 + 0iz2+c=0.3+0.5iz^2 + c = 0.3 + 0.5i

You might wonder whether there is any pattern to which values of cc cause zz to fly out of the ring instead of remaining inside it. Imagine placing a transparent grid on top of the cc picker. Then, you could methodically move cc to each point on the grid, hit step a bunch of times, and mark a dot over every cc value that did not fly off.

Of course, that would be a time-consuming exercise, but it essentially describes what happens when you brush over the image below. As you mouse over the grid, the plot on the right shows the progression of zz found when calculating the grid cell under your cursor. We color points according to how many steps zz remained inside the outer circle for before it escaped it, up to 200 steps.


As you can see, as you mouse over the image, the Mandelbrot fractal reveals itself. Try double-clicking to zoom in.

I hope that the magic of the Mandelbrot fractal is not diminished by seeing how simple the math is, but instead that seeing such complexity arise from a simple rule gives you a new sense of appreciation for it.

Further Reading

This explorable explanation was created for the 2018 explorables jam. For more stuff I've done, see my homepage or find me on Twitter as @paulgb.