Iris of Salisbury, MD asks:
Can you explain the mathematics behind the Mandelbrot set?
The Nerd responds:
I will try. I say try not because I don't think people can handle it, but because I think I only have a rudimentary grasp of the whole thing. I will explain what I know, but I can't guarantee that a good mathematician wouldn't look at this answer and proclaim that I got it all wrong.
The mathematics behind the Mandelbrot set always reminds me of Bismarck's quote about government: "People who like government or sausage shouldn't watch them being made." I say this because when you look at the Mandelbrot set and see its chaotically intricate and beautiful design, you can't help but feel that there is something larger than life going on here--that you are staring right at some unexplainable cosmic mystery. Having said that, there is no denying that in many ways, the Mandelbrot set is a purely man-made object (mathematicians might be pulling their hair at this statement). What I mean by this is that you aren't going to spot the Mandelbrot set out in Nature the way you find the logarithmic spiral in the nautilus shell or the Fibonacci spiral in galaxies, because the Mandelbrot set lies in the complex plane, which isn't a part of the ordinary world we live in (and maybe exists only as a mathematical construct). On the other hand, one of the most striking features about the Mandelbrot set is its self-similar geometry which is a geometry you will find throughout Nature.
First things first. If you have never seen the Mandelbrot set, take a look at an image from the Mandelbrot set below. If your browser supports Java, click in the lavender box below the image, and a Java applet will launch (written by Peter Alfeld) consisting of two windows. The window on the left is the control panel, and the one on the right is an image from the mandelbrot set. Use your mouse to select a region of the image. When you release the mouse button, the applet zooms in on the portion you selected.
If you figured out the zoom feature of the Applet, then you probably noticed the self-similar feature of the Mandelbrot set I mentioned earlier. When you zoom in on a piece of the Mandelbrot set, you realize that that piece contains, and consists of, another Mandelbrot set. Zoom in again, and you see that that piece also contains and consists of another Mandelbrot set. Zoom in again. Same thing. In fact, you can zoom in forever and you will always see more Mandelbrot sets! This feature isn't unique to the Mandelbrot set. This self-similar property is true for a class of geometric patterns known as fractals. Fractals are termed infinitely complex because the more closely you look at the object, the more complex it appears.
What makes the Mandelbrot set so interesting is that this infinitely complex patterning is derived from a very simple formula. The basic formula for the Mandelbrot set is:
Z = Z2 + C
The Mandelbrot set is determined by iterating with this equation. By iterating, I mean that we start with a value for Z and C. We plug these into the equation to get a new value for Z. We then plug that value for Z in and get a new Z, and so on. Let's look at a simple example that will help us understand iteration.
Let's start with Z = 0 and C = 1. Let's iterate:
|Z||C||Z = Z2 + C||New Z|
|0||1||Z = 0 + 1||1|
|1||1||Z = 1 + 1||2|
|2||1||Z = 4 + 1||5|
|5||1||Z = 25 + 1||26|
As you can see, in this case Z just keeps getting bigger and bigger. But if we choose different values for C this won't always be the case. Suppose we use Z = 0 and C = -1
|Z||C||Z = Z2 + C||New Z|
|0||-1||Z = 0 -1||-1|
|-1||-1||Z = 1 - 1||0|
|0||-1||Z = 0 - 1||-1|
|-1||-1||Z = 1 - 1||0|
As you can see, in this case, Z just flip flops between 0 and -1.
So far we have been using ordinary integers (0, 1, -1, 2, etc.) to iterate our function. The Mandelbrot set doesn't iterate over these simple numbers. Instead it iterates over complex numbers.
Okay, remember how I told you that the Mandelbrot set wasn't part of the ordinary world? Well here is the reason. The Mandelbrot set you see is drawn in the complex plane. The complex plane is used to describe complex numbers. That's easily said. What's harder to explain is what complex numbers are (and hardest of all is explaining what they are good for! We won't do that...).
Complex numbers come in two parts: a real part and an imaginary part. The real part is easy to grasp. They are regular numbers that you know and love: 1, 0, -5, 4.534343, 232423432.4787865, -0.0000000000002, etc. The imaginary part of a complex number is a real number (like above) multiplied by a unique little number called i.
What is i? Plainly said, i is the square root of -1. Plainly said, but that doesn't make any sense. Let's look at square roots. The square root of 4 is 2 because 2 * 2 = 4. The square root of 1 is 1 because 1 * 1 = 1. The square root of 64 is 8 because 8 * 8 = 64. Now then, (what) * (that same what) = -1 ???? Answer: there is no such thing. The what can't be -1 because -1 * -1 does not equal -1; it equals positive 1. Therefore there is no such thing as the square root of negative one.
Well, this sort of common sense doesn't stop mathematicians. They say, "Oh, there is no such thing as a number that has the value of the square root of -1? Well, in that case that number must be imaginary." And that is just what they call it.
More than likely, you find this frustrating. But for the sake of learning about the Mandelbrot set, we will just have to accept the rationale (or irrationale) of imaginary numbers and move on. Since the beautiful pictures we see from the Mandelbrot set is founded on this logic, we must accept that there is something to it ("Beauty is truth, truth beauty,"—that is all Ye know on earth, and all ye need to know).
As I was saying, complex numbers come in two parts: real and imaginary. Mathematicians write complex numbers in this way:
4 + 3i
With the real part first and the complex part second. When they want to envision complex numbers, they use the complex plane. You will remember from grade school the good old number line. It wasn't too hard to grasp. The numbers were just put out in order, usually with zero as the center, like so:
The same principle goes for complex numbers, but they can't just use the real number line, because that doesn't include information about the imaginary part. So to cover that, they insert another axis (the imaginary axis), and then plot the complex number on this newly formed complex plane. Let's look at an example:
This chart represents the following complex numbers: 2 + 1i, -1.5 + 0.5i, 2 - 2i, -0.5 - 0.5i, 0 + 1i, and 2 + 0i. Let's look a color coded table to make sense of this.
|Complex Number||Real Part||Imaginary Part||Description|
|2 + 1i||2||1i||move right 2 on the real axis (positive) and move up 1 (positive) on the imaginary axis|
|-1.5 + 0.5i||-1.5||0.5||move left 1.5 on the real axis (negative) and move up 0.5 (positive) on the imaginary axis|
|2 - 2i||2||-2||move right 2 on the real axis (positive) and move down 2 (negative) on the imaginary axis|
|-0.5 - 0.5i||-0.5||-0.5||move left 0.5 on the real axis (negative) and move down 0.5 (negative) on the imaginary axis|
|0 + 1i||0||1||stay at 0 on the real axis and move up 1 (positive) on the imaginary axis|
|2 + 0i||2||0||move right 2 on the real axis (positive) and stay at zero on the imaginary axis|
(Note: Images and idea for these numbers come from Introduction to the Mandelbrot Set. By David Dewey.)
So, now that we see how to plot complex numbers on the complex plane, let's tie it back in with the Mandelbrot set. Recall our basic formula:
Z = Z2 + C
For the Mandelbrot set, we start Z at zero as we did in our earlier iteration examples. But our choice for C will be a complex number. Our exact choice for C is what determines the Mandelbrot set. Recall in our earlier iteration examples that some choices for C produced iterations that kept getting bigger and bigger (C = 1, for instance) while with other choices, the iterations never grew much beyond a certain point (when C = -1, for instance). Well, the Mandelbrot set consists of all the choices for C we can find (where Z starts at zero and C is a complex number) so that the iterations never grow beyond the number 2. That is the mathematical definition of the Mandelbrot set.
So how do we go from this definition to the eleborate pictures we see in computer graphics? Well, each value for C can be plotted on the complex plane. In our above figure of the complex plane, we just chose some simple complex values (simple complex?) such as 2 + 0i and -0.5 -0.5i, and put a dot on the complex plane for each point these complex numbers represented. But, of course, there are countless other points in the complex plane, just as there are countless points on the real number line we are more familar with. For example, in between 0 and 1 on the real number line are the points: 0.5, 0.25, 0.33, 0.00232, 0.04575322, etc. And since, the real number line we all know is just the horizontal axis for the complex plane, then clearly, all of these points are also in the complex plane as well as similar points that include the imaginary components: 0.5 +i or 0.5 -4i or 0.33 -4.56334i or 1.4 - 3.3i, etc.
Using computers, we filter through a large sampling of these infinite number of points on the complex plane, and determine which of these points fit the Mandelbrot set criteria for C. The computer does this by running iterations of Z = Z2 +C until it can verify that for that given value of C, Z never gets larger than 2. If the computer is assured of that, then it knows that that C is in the Mandelbrot set and so it plots that value of C on the complex plane by putting a dot of some color (black in the Applet above, but the choice of color is entirely arbitrary) on the computer screen. The only other possibility is that for that value of C, Z eventually does exceed 2. In that case, C is not part of the Mandelbrot set, and the computer does not plot it.
By plotting the millions of C values that are part of the Mandelbrot set, the computer creates the distinctive Mandelbrot geometry that you see on the Applet above. Since Mandelbrot sets are just a huge collection of points plotted on the complex plane, they could easily be just one color. However, you will notice that most of the Mandelbrot sets you see have many colors. The colors you see on most Mandelbrot sets are added for effect. They show points in the complex plain that are not a part of the Mandelbrot set. The color chosen is indicative of how many iterations of the above formula were required before it was shown that that particular value of C was outside the set. Studying how long (how many iterations) it takes to prove a value of C is outside the Mandelbrot set, is interesting to mathematicians, so they color code them to help clarify different regions.