## Fractals

I love fractals! The maths is is not complex* and yet simplicity can create such beauty. Fractal geometry is basically the maths of describing shapes. The essence of the idea is that you can define apparently highly complex patterns (like shapes) with relatively simple mathematical expressions. To generate images as below, typically a simple function (or formulae) is applyed repeatedly to each x,y co-ordinate of a grid of numbers (forming the canvas). After each calculation, the result is fed back in to the function. This is done a set number of times and depending on the final value, a colour is applied to that point of the canvas. * Mathematical irony fans, that was for you.

I made these pictures with a program I wrote in Perl, basically to prove that I could. Many have gone before me and done it much better. Take, for example my mate Mat Holton who wrote a brilliant Java application for his CS BSc project. OK, enough bigging-up Mat. More about Perl and fractals… OK, how does this work? The basic algorithm used here was devised by Benoit Mandelbrot and does it’s work on a plane of complex numbers. You might start to feel a bit lost or freaky in a moment but hang in there, it really is quite simple… This plane of complex numbers is basically a big grid of sums where each ‘cell’ in the grid holds a value that is the sum of a ‘real’ number and an ‘imaginary’ number. Imaginary numbers are real numbers multiplied by i, which is the square root of -1. I know what your thinking… You can’t make a square root of a negative number! Well with a bit of jiggery-pokery, that is way beyond my understanding, you can. so there. Anyway, it turns out that these complex numbers are pretty usefull in all sorts of situations (usually engineering). What do we do with each of these complex numbers in a big grid? We bung them through Mandlebrot’s equation! Each complex number is depicted by z in this algorithm. z0 is the starting value whilst z is the current value. This current value of Z gets repeatedly run through the equation and as it does so, the current value changes. The actual equation I used in my programs was: z = z² + z0 Each cell in our grid (i.e. values of z in our plane of complex numbers) gets put through this equation a specified number of times (e.g. 300). For some starting values of z, it will change but always remain very small (less than 2). For other starting values, it will get big, small and big again untill eventually it goes larger than 2 and it heading off to become a very big number indeed. Basically, you can count the number of times (and stop somewhere around 300 itterations) the starting value for z can go through the equation before it gets big (goes to infinity) and depending on how long it lasts, plot it’s position in the grid as a colour. and there you go. The picture drawing is handled by creating a bitmap where each cell in the grid (plane of complex numbers) is a pixel on the bitmap. The program starts at the top left corner with a certain value of z corresponding to the topleft corner of the grid defined by the user. It runs the calculation and checks to see how far through the maximum number of itteratons (specified by the user) the cell got before its value of z got larger than 2. The colouring was (sometimes) as follows:

• more than the maximum itterations – Red
• 7/8ths of the maximum itterations – Orange
• 6/8ths of the maximum itterations – Yellow
• 5/8ths of the maximum itterations – Green
• 4/8ths of the maximum itterations – Light Blue
• 3/8ths of the maximum itterations – Dark Blue
• 2/8ths of the maximum itterations – Violet
• 1/8th of the maximum itterations – Black 