We all know \(1 \times 1=1^2=1\). And \(-1 \times -1=(-1)^2=1\). So what's \(\sqrt{-1}\)?

Obviously it doesn't exist. It's a completely imaginary number — so let's all it \(i\), use it anyway and see what happens. Now we can say \(i^2=-1\), \((-i)^2=-1\) and \((2i)^2=-4\).

Now that we have ‘real’ numbers (multiples of one) and ‘imaginary’ numbers (multiples of \(i\)), let’s make the next logical step and define ‘complex’ numbers, which have real *and* imaginary parts. A complex number \(z=x+yi\), and you can work out with a bit of algebra that \(z^2=x^2-y^2+2xyi\).

Since numbers now have an \(x\) and a \(y\) part, the ‘number line’ needs to be two-dimensional: it becomes a number *plane*, which we call ‘the complex plane’.

Now we’re ready to draw the Mandelbrot Set. The screen becomes the complex plane, with \(0\) in the middle, \(1\) on the right, \(-1\) on the left, \(i\) at the top, and \(-i\) at the bottom (although it turns out \(i\) and \(-i\) are basically equivalent).

So each pixel represents a complex number \(z\). We take that number and calcluate some new ones: \[ z_0 = z^2 + z \] \[ z_1 = z_0^2 + z \] \[ z_2 = z_1^2 + z \]

One of two things will happen: either the series of \(z\)s will hover around the original value, or it will eventually go crazy and become huge numbers. If it stays small, we colour the pixel black. If not, we colour it some shade of blue depending on how long it takes to become large.

In theory there are carefully defined definitions for all this, but for the purposes of drawing it in a finite length of time, we take ‘small’ to mean below five and assume that if \(z_{3000}\) is small then it's staying small forever. You can change these settings to suit your computer.

The Mandelbrot Set is interesting because it is a fractal: it has finite area but an infinitely long perimiter. And no matter how far you zoom in, it always looks about the same. Until, that is, you zoom in too far and the numbers become too small for your computer to work with. Then it gives up and shows you a blue screen and you have to start again.