The code used to generate the header image can be found at: https://github.com/ravidashputre/mandelbrot

Fractals are a popular topic covered by math outreach programs, and with good reason. Getting kids excited about math is often a difficult task for teachers, and the beauty of these objects is enough to get anyone to pay attention. I mean, just look at them:

While these presentations do get kids excited about mathematical objects, they almost always give no explanation of their origin and why people discovered them in the first place. This article explores some of the math behind the Mandelbrot set, the most well known fractal.

A Refresher on Complex Numbers and Vectors

To start, we first need to know that the Mandelbrot set lives in the complex plane. Complex numbers are interesting because unlike real numbers, they each contain two pieces of information: the value of their real part and the value of an imaginary part. This means that while it takes two real numbers to create a 2 dimensional vector in the real plane, it only takes one complex number to make a 2 dimensional vector in the complex plane.

This extra information carried by complex numbers leads to some interesting consequences for operations performed on them. To understand the Mandelbrot set, we need to know what happens to the vector that represents a complex number when that numbers is exponentiated.

The multiplication of two complex numbers creates a third vector, whose magnitude and direction can be derived from the equation to the right. A complex vector raised to a power is therefore just a stretched (or shrunk) and rotated version of the original vector, as exponentiation is just the repeated multiplication of the same number.

Where the Mandelbrot Set Comes From

There are a lot of questions you could ask about complex exponentiation, but an interesting one you could ask is “when complex numbers are repeatedly exponentiated, which ones blow up and shoot out further into the complex plane, and which ones stay close to origin?” To answer this, we need to be more rigorous with how we define our question.

Let “repeated” exponentiation mean applying our exponentiation rule and infinite number of times. Let the points that “blow up” be the ones whose repeated exponentiation causes the limit of their magnitudes to approach infinity as the number of exponentiations increases. Let the points that “stay close” be the points with finite magnitudes no matter how many times you exponentiate them. There is still some ambiguity about how we’re going to exponentiate our complex numbers though. For the complex number c=a+bi, do we chose c2, c3 or something else? What rule should we repeatedly apply to points on the plane?

As it turns out the Mandelbrot set is the collection of points that follows the above rules where our rule for exponentiation is:

When we start with the condition that z=0 for the first iteration. Let’s take a look at how this rule is applied for the number c = 3+3i.

Iteration 1: z1 =z2 + c = c = 3+3i.

Iteration 2: z2 = z12 + c = c2 + c = 3 + 21i

Iteration 3: z3 = z22 + c = (c2 + c)2 + c = -429 + 129i

It looks like if you kept doing this, the magnitude of each iteration would keep increasing. This means that 3+3i can’t be in the Mandelbrot set, because it “blows up”. To actually prove this, you would of course have to present a more rigorous argument or iterate infinitely. But for the purpose of the article, just know that the numbers that look like they’re blowing up do blow up and the points that don’t look like they’re blowing up don’t blow up for a large number of iterations.

If you now repeat this process for every value of c in the complex plane, and you only keep the points that don’t blow up, you have the Mandelbrot set!

Programs that generate images of the Mandelbrot set find its points much in the same way we did for 3+3i. They set an arbitrary maximum value for zn after n iterations of applying the rule above. At the top of this article, I’ve attached code I wrote to generate an animated plotting of the Mandelbrot set for 30 iterations with a maximum value of 100. Play around with the variables and see what happens when you change these values! Please excuse the lack of comments and slow render speed; I’m still working on it and it takes some time to check our rule for all those points!

Why This Is Cool

The Mandelbrot’s true beauty stems from the fact that something so infinitely detailed, and for a lack of a better term, complex, can come from something that naturally falls out of the way multiplying complex numbers is defined. One of the wonderful parts of mathematics is that the extension of simple, intuitive ideas to realms where different rules hold can lead to some spectacularly surprising results. Complex numbers are often confusing to students when they first learn them. We are not hardwired to imagine the square roots of negative numbers. What are the side lengths of a square table that takes up less than no space? But when we ignore our instinct to dismiss the unintuitive and instead dive deeper, sometimes something with intrinsic beauty pops out from our alternate universe. The Mandelbrot is one of those somethings.