I have a confession to make. I suck at math. I always have, and maybe always will. Despite possessing two engineering degrees and being very close to completing a third, I can’t say that I am comfortable with math. So you might be surprised if you ever drop by my office on a Sunday afternoon. You’ll find me with a broad smile on my face, leafing through a big fat book titled something like ‘Advanced Engineering Mathematics’. I read it because I want to, and I read it because it is fun.

“But math is hard!”, you say. I agree, but great difficulty does not always breed contempt. On the contrary, years of struggling with math have actually pushed me to a level where I have started to see the beauty in it.

To the uninitiated, the very notion of finding beauty in numbers and rigid logic might seem absurd. Nothing could be farther from the truth. Case in point – the pictures below:

Even the most soulless among us would have to admit that there is a certain beauty in the patterns that appear in the images above. Your first thought might be that this is the result of some artist’s Frankensteinian combination of LSD, M.C. Escher, and Pink Floyd. The truth, though, is far stranger – the pictures you see were created by no human artist at all! They are just mathematical plots, much akin to the graphs 9th-grade algebra students make. These particular images are plots of a deceptively simple mathematical expression:

z ← z2 + K

I’m no math whiz, but I certainly do remember plotting lots of equations in high school, and none of those plots produced anything quite so spectacular. What is it about this expression that gives its graphs such charm?

For one thing, ‘z’ isn’t your run-of-the-mill everyday number. If you remember your middle school math classes, you’ll remember the number line:

We were taught that every number you can think of exists somewhere on this line. This statement is actually only partly true. The numbers that we deal with on a day-to-day basis are called ‘real’ numbers and they certainly are on this line. However, there do exist numbers that are not on this line. Lines are one-dimensional. You might be tempted to think that numbers are one-dimensional too, but in fact they are not. Numbers actually exist in a two dimensional plane.1 This plane looks something like this:

The black line that you see i.e. the x-axis of the plot is the number line that you know from high school. The blue line i.e. the y-axis is a line called the ‘imaginary’ line. Numbers that exist on this plot are called ‘Complex numbers’.2 This is what a complex number looks like:

3 + 2i

This number exists at a point which is at ‘3’ on the x-axis and ‘2’ on the y-axis on our plot:

Whatever you can do with a real number, you can also do with a complex number: addition, multiplication, trigonometry, calculus – they all work. The rules are a bit different, but we needn’t worry about them here. For now, let’s focus on a specific quantity called the magnitude of a complex number. The magnitude is the distance of that number from the 0+0i point. I’ve marked this distance on our plot with a green line:

Any point on the plot above will represent a specific complex number. The pretty pictures from the beginning of the article were obtained by plugging in the complex number corresponding to each point on the plot, into the expression below:

z ← z2 + K

In addition to the numbers being unusual, this expression itself is special: it’s an iterative expression. What this means is that you won’t just calculate the result of the expression once. You would instead calculate this repeatedly over and over for as many times as you can. This is what it looks like when you compute this expression for our number by setting K=3+2i:

Now, if you plot the magnitudes (distances from the 0+0i point) of the sequence for our number 3+2i, you get something that looks like this:

The exact values of the plot themselves don’t matter, but look at the trend of the plot. You’ll see that the numbers get larger and larger as the sequence progresses. I’ve only plotted the first four values of the sequence, but no matter how far you compute the sequence, the magnitudes will just keep increasing to infinity. The number 3+2i is not special in any way because of this. A lot of numbers will cause this expression to go to infinity.

But not every number will make the sequence go to infinity. Take, for instance, the sequence you get from the number -1.02 + 0.1i:

You can see that in this sequence, the numbers don’t keep growing larger. You can keep calculating more and more items in this sequence, but the numbers will never grow very big.

Every single complex number that you can think of will either increase to infinity when you apply this equation, or it will always stay within some finite distance from the center. Going back to our plot, if the complex number at a certain point will not make our sequence go to infinity, we will mark it with a black point. If it does make the sequence go to infinity, we leave it unmarked.

If you do this for every single complex number, the result is a plot that looks like this:

The plot that you see above is that of the famous Mandelbrot set. The Mandelbrot set is the set of all numbers that do not make our sequence go to infinity. To help us understand why this set is famous, I’ve marked a portion of the plot with a box. Let’s zoom into that box.

Zoomed in version:

I’ve now marked a new box in blue in the picture above. This is what you get if you zoom into the blue one:

No, your eyes aren’t deceiving you. The two pictures above look exactly identical even though we went from one to the other by zooming in. In fact, if you keep zooming in more, you’ll see the same thing.

This isn’t specific to the part that we zoomed in. You can zoom into other regions and see the same effect. Add some color3, and you’ll start seeing the beautiful pictures from earlier.

You will notice that the shapes on the left of the last image are more or less identical to the shapes in the center of the first (albeit rotated a little). The more you keep zooming in, the more you will see repeated shapes and structure which are identical to previously seen shapes. And these patterns will continue forever as long you keep zooming!

Simpsons fans like me might get reminded of a famous couch gag, which I’ve attached as a gif below. Since the gif loops infinitely, it is continuously zooming out, and you see the same patterns recurring again and again. This is exactly identical to what is happening in the Mandelbrot plots. But unlike the Simpsons scene which is artificially constructed, the Mandelbrot set exists in real life.

This kind of recursive pattern (the technical term is self-similar) where smaller parts are similar to the larger whole is called a fractal. The Mandelbrot set that I’ve been showing you is but one tiny part of a fractal universe:

Fractal Fractal, burning bright,

In the darkness of my mind,

What immortal hand or eye,

Could frame thy fearful symmetry?

(my apologies to William Blake)

To this day, I still struggle with mathematics. I often have to ask for help when I get mired in math while reading a paper. But then, I can’t play a violin either; and that certainly doesn’t stop me from enjoying Tchaikovsky’s violin concerto. Why should math be any different?

1. Actually, there do exist number systems such as Quaternions and Octonions which possess more than two dimensions.

2. Real numbers are complex numbers too. The number 3 for instance is the complex number 3+0i.

3. Some complex numbers make the sequence grow much faster than others do. Color versions are generated by making the faster-growing complex numbers a darker color, and the slower-growing complex numbers a brighter color.