The Mandelbrot Set is the big daddy of fractal images, of the type that seemed to be everywhere in the 1990s. It is a strange, beautiful and literally infinitely complex mathematical object, and what is particularly strange about it (and other fractals) is that this infinite complexity is generated by the application of a very simple procedure.
Benoit Mandelbrot (1924-2010) was a mathematician born in Poland, raised in France and spending most of his working life in the USA. He worked in a wide range of fields, but is best known for inventing the word 'fractal' (a figure of fractional dimension), and collating and bringing to wider attention the properties of what had previously been regarded as diverse and discrete curiosities in the mathematics of complex numbers.
The first imaginary number is simply the square root of minus one. It's 'imaginary' because if you multiply any real number, even a negative number, by itself, the result is always positive, so the concept of having the square root of a negative number doesn't make sense1. It is usually2 indicated by the letter i. Any real number (-1, 2, 0.5, etc) can be multiplied by i to give the corresponding imaginary number (-i, 2i, 0.5i etc). You can multiply imaginary numbers by each other. 2i multiplied by 3i, for instance, is 6i², which is -6. Note that two imaginary numbers multiplied gives a real number.
A complex number is a number with a real part, and an imaginary part. For instance, 1+i, or 2-3i.
You can multiply complex numbers by each other. For instance, if I want to multiply (1+i) by (2-3i), here's how it comes out:
Real part: 1 × 2 = 2.
Imaginary part: i × -3i = 3. Note that here, because i is the square root of minus 1, i × i = -1. So that's 1 × -3 × -1.
First complex bit: 1 × -3i = -3i
Second complex bit: 2 × i = 2i.
So now we just add all that up: 2 + 3 - 3i + 2i = (5 - i)
So two complex numbers have been multiplied together, and we've got another complex number. Simple enough.
The Complex Plane
One way to teach children about the concept of negative numbers is with a 'number line', with zero in the middle, and the positive numbers stretching off to the right and the negative numbers off to the left.
Imaginary numbers don't appear anywhere on this number line, so we draw another line, at right angles, through zero, and call that the Imaginary Axis.
Now, any real number is a point on the Real Axis (the normal number line you're familiar with). Any imaginary number is a point on the Imaginary Axis.
The clever bit is, any complex number – a number with a real bit and an imaginary bit – is simply a point somewhere that's not on either axis. For instance, 5+i is 5 steps to the right along the real axis, and one step up, parallel to the imaginary axis.
So you can think of any complex number as a set of (x,y) coordinates on a graph. The plane you're drawing on is known as the 'the complex plane'.
The Mandelbrot Set Process
Take a complex number, any complex number. For the sake of argument, let's call it c.
Multiply it by itself, and let's call the result z.
Add z to c.
Multiply the result by itself.
Add c again.
Multiply the result by itself.
Add c again.
Keep doing that. It's called 'iterating'.
For some points (for instance 1.9+1.9i), you'll immediately get a number where one or other of the parts is bigger than 2, and once that happens they get much bigger quite quickly, and will keep on getting bigger and bigger forever. This is called 'diverging'.
For some other points, the numbers will remain finite and less than 2. This is called 'converging'. Some will converge quickly and obviously (eg 0.1+0.1i). Others will bobble around all over the place for a bit before starting to get smaller and smaller. Others still will bobble around for bit before diverging. There's no shortcut way to find out which points do which – you just have to do the sums.
Your First Mandelbrot Set
Do the sums for every number between -2-2i, and 2+2i, in 0.1 increments. That is to say, do the iteration on -2-2i, then do it on -1.9-2i, then -1.8-2i, and so on, until you get to 2-2i, then move on to -2-1.9i, and so on. For each number, do the iteration just five times. Now... this is a lot of sums. Even at this low resolution (just twenty 'pixels' square) and with just a few iterations, you're still looking at needing to do 20 × 20 × 5 = two thousand complex number sums.
It now becomes clear why the Mandelbrot set was not discovered until after the invention of the computer.
Do your five iterations for each value of C. If it diverges, leave it blank. If not, colour it in black.
What you should end up with is a vaguely buttock-shaped blob, with a circular blob to its left, smaller blobs top and bottom, and crinkly edges. The black dots are points inside the Mandelbrot set.
Higher Resolution = a Closer Look at the Edge
You're looking at the set through a rather crude lens at this point. It's perfectly possible to increase the resolution of your image. All you need to do is do the sums every 0.01 instead of every 0.1. Of course, this multiplies the number of sums you have to by a hundred. Now you really do need a computer. Your resolution is limited only by how many calculations you want to do – you can easily 'zoom in' on just one small section by just doing the sums in that region.
More Iterations = More Crinkles
Another variable you can control is the number of iterations. The thing is, you can see the edge of your set, but how sure are you, really, that all the dots you've coloured in are really inside the set? With just a few iterations, the edge can look quite smooth, especially if you zoom in. A few more iterations, though, and it will start to look crinkly again. The more iterations you have, the more crinkly and fractal the edges will look, up to the limit of the resolution of your monitor.
The startling thing about the set is this: you can zoom in forever. No matter how much you zoom in on the edge of the set, as long as you do enough iterations, the edge will always look crinkly and complex. This incredibly simple process (multiply the number by itself, add the original number, repeat) gives rise to a literally infinitely complex object.
The other important feature of fractals is self-similarity. The regions of the set look crinkly in the same way all the way down. Indeed, if you look around, there are at first sight little copies of the set dotted around the edges. Closer inspection reveals that they are not, in fact, exact copies, but areas of similarity. Aside from the symmetry about the real axis, no two parts of the set are identical.
For a while in the 1980s and 90s, fractal images were popular as posters, book covers and similar. They are usually brightly coloured. Your own set can easily be coloured this way.
Do the sums for a plot of a Mandelbrot set, but, crucially, record how many iterations you do before the number diverges.
If it diverges after, say, less than 10 iterations, leave the point white. Between 10 and 20, colour it blue. Between 20 and 30, colour it red, 30 and 40 green, and if it hasn't diverged after 40, colour it black.
This will, of course, increase the amount of calculating you'll have to do. In the 1980s, when fractals first came to public notice, producing detailed coloured images required access to huge, expensive graphics workstations and hours or days of computing time. Simple Mandelbrot sets were, however, possible to plot even on cheap home computers.
A 21st-Century PC is more than capable of allowing the user to explore the set in great detail very rapidly. It's still interesting to try to plot it yourself with a simple home-brew program, however, and doing so is an interesting way to learn about complex numbers.