An Explanation of the Mandelbrot Set
(or, how complex-number math can make beautiful pictures.)
(under construction)
M. Eric Carr / Intellectualism.org
Shapes, defined by their points
The Mandelbrot Set (the black area at the center of the image) is the group of points that have a specific property in common. (Exactly what this property is, will take a bit of explaining.)
A filled-in circle has a similar, but simpler, property; it is the group of points that are within a specific distance of the point at the center of the circle.
A filled-in square also has a similar property; it is the group of points which are "within" four line segments. (Math purists, please excuse the informality; it doesn't matter here.)
So, in order to find out how the Mandelbrot Set is made, we need to know what the points that make it up have in common. The explanation has to do with algebra and what happens to numbers when you do a specific bit of math on them over and over. (Computers are really good at the "over and over" part.)
Behavior of numbers subjected to repeated math operations:
When a specific math operation is performed on a number over and over, several things can happen -- depending on what the operation is, and/or what number you started with.
For instance, if the operation is adding one, this will make any number keep getting larger and larger, when you repeat it many times. (Very uninteresting.)
Subtracting one from any number over and over will make the number keep getting smaller and smaller, when you repeat this many times. (Also uninteresting.)
Dividing a number by two many times will make it get closer and closer to zero. (A little more interesting, but not much.)
Multiplying a number by -1 (negative one) is a little more interesting; when this is done over and over, the number will jump back and forth between a positive and negative value.
...but what if there were some kind of operation that ended up doing different things, depending on what number you started with?
...and what if some of these different things were very interesting -- or very complex?
This is what happens with the numbers and mathematical operations involved in the Mandelbrot Set. Each point in the picture represents a special sort of number. (Specifically, a "complex number" -- but we'll get to that.) When a specific math operation is done on these numbers, they do one of several things:
- Some of them speed off away from zero, going faster and faster.
- Some of them are drawn inwards, towards zero or towards certain other interesting points.
- Some of them loop around between several points in a cycle.
- ...and some of them act unpredictably for hundreds or thousands of repetitions of the same operation, before eventually "deciding" what to do.
To understand the specific math operation that is done to these numbers, you need to understand what complex numbers are and how they behave. I'll save this explanation for another day, since it gets pretty technical if you haven't studied complex numbers and/or algebra yet.
Getting pretty pictures from math formulae:
When each of the numbers in the plane is run through a specific function several times, one of the situations above (getting larger, getting smaller, looping etc) eventually happens. What the computer does is to count how many loops of this function it takes for the number to get larger than a certain value (say, two; if the number ever gets larger than this, it will speed off to infinity.) For each number, the computer tries this process until one of two things happens -- either the number gets larger than five, or it "gives up" after reaching a certain number of repetitions (say, 1000).
Once the process is complete for that number, the computer assigns a color to it depending on what happened. If it went all the way to the last repetition without getting large, the computer colors that point black, since it seems to be a part of the Mandelbrot Set. If at some point before the last repetition the number gets too big, the computer colors it according to how many repetitions it took to get that big. (There are thousands of schemes for assigning colors to iteration numbers -- this is best left to artists.)
Each group of points of the same color ends up forming a band around the Mandelbrot Set. The higher the number, the more intricate the band -- but they are all simple bands; that is, if stretched out like a rubber band, each would be a circle.)
The way the animation works is that for each frame in the movie, the computer draws a picture of a smaller and smaller portion of the image. Since it uses the same number of points in each image, these points get closer and closer together in each frame.
This is where the "pretty pictures" part starts to happen. If you zoom in on a circle this way, you wouldn't see anything interesting; the edge of the circle would simply look like a straight line after a while. Zooming into a fractal like the Mandelbrot Set, though, is much more interesting. In fact, if you keep zooming in to any point on its boundary, the border will never smooth out; there will always be finer and finer details as you keep zooming in.
One problem with making really deep zooms, though, is that it takes a lot of computer time. At higher magnifications, the computer has to be more and more precise in the math it does (just like you have to be more precise when balancing a checkbook with five digits in the numbers than if there are only two or three). Also, at the higher magnifications, it usually takes more repetitions to see how each point behaves. Finally, there is a limit to the precision of arithmetic that any computer can do easily (the computer equivalent of "in its head". The computer can do more precise math than this, but it's a long, complicated process. The result of all these is that larger zooms take a really really long time.
The next time, I'll explain specifically how to write a simple computer program to draw the Mandelbrot Set. (If you understand complex numbers and programming and want the gory details, the Mandelbrot Set is located within two units of the origin; the equation to run is Z <-- Z^2 + C (where Z starts out as 0+0i and C is the complex coordinate of the point in question.) Run this until |Z| > 2.0 or you reach an iteration limit (try 100 for starters, then see if 1000 looks any better.)