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.
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.
One of the core tools in math is abstraction: the idea that we can take a symbol, like , and use that as a placeholder for an unknown value.
For example, if I say , you can figure out that either or . If I say , we know that there is no real value of 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 such that , even though we can't “solve” in the traditional sense. is called the imaginary unit, and the remaining imaginary numbers are just multiples of .
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 s from each side combine into , which we can replace by because we decided earlier that .
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.
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 .
Adding complex numbers is straightforward: we add the real parts, and add the imaginary parts, but we keep them separate.
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.
Multiplication is a bit more tricky, but it's really just an application of the FOIL method followed by a simplification using the rule .
For example, consider . By FOIL we get . Replacing for , we can simplify this to .
Squaring a complex number is just a special case of multiplication: .
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 , and start with . Then, we set over and over again.
Try picking a value of below, and then hit the “step” button a bunch of times. Each time you hit step, the value of is set to .
For each value of , 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.
You might wonder whether there is any pattern to which values of cause to fly out of the ring instead of remaining inside it. Imagine placing a transparent grid on top of the picker. Then, you could methodically move to each point on the grid, hit “step” a bunch of times, and mark a dot over every 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 found when calculating the grid cell under your cursor. We color points according to how many steps 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.
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.