The Programmer's Guide to Fractals |
Written by Mike James | ||||
Thursday, 18 July 2019 | ||||
Page 2 of 3
The Fractional DimensionSelf-similarity may sound like an innocent concept but it leads to most of the clever things we associate with fractals and, in particular, their name. If you think about a theoretically perfect line then it is clear that it’s one-dimensional. Similarly a perfect plane is a two-dimensional surface and there really doesn't seem to be a way that you can make a line into something two-dimensional. Well if it wiggles enough you can! The idea is that if a curve can wiggle enough then it can visit enough points to have an area and not just a length. Consider for example a line that passes though every point in the unit square. The line when you look at any part of it must be just a line and hence one dimensional. However as the line passes though every point in the square it must have an area of one just like the square. So a such a line has an area and in some sense must be more than one dimensional. Curves that pass through every point in some space are called space filling and the first were thought up by the mathematician Giuseppe Peano (1852-1932). Peano curves are very similar to better known fractal curves such as the snowflake but they are designed so that they provably pass though every point. So lines can behave as if they are more than one dimensional but the problem is to find a measure of the dimension that works and gives the usual answer for standard lines, areas and volumes. Mandelbrot defined the fractal dimension of a line as the ratio of the log of its lengths at two zoom factors and the log of the zoom factors. Using this definition of dimension, a line can have a fractional dimension between 1 and 2 – hence the name “fractal”, i.e. fractional dimension. Mandelbrot's dimension is just one of a number of possible measures and it isn't the most convenient to work with in most cases but it is where it all started from. Iterated mapsOK, so now we know that fractals are about wiggly lines and the possibility of fractional dimension – but what has all of this got to do with the part of fractals that everyone knows about, that is the Mandelbrot set and perhaps fractal compression. The link is two-fold. The first thing to realise is that self-similarity of a curve at all levels of zoom implies a fractional dimension between 1 and 2 and hence fractals are often self similar. The second link is that there are many processes which give rise to self-similar curves and patterns. Most involve some sort of iteration, i.e. repeated operation. For example the Sierpenski triangle is a fractal created by drawing a triangle and then drawing a triangle inside of it. This process of drawing a triangle inside of another is then iterated by drawing a triangle inside each of the triangles so formed by the previous drawing of a triangle – look at a Sierpenski triangle again and it will become obvious.
A Sierpenski triangle- nothing but triangles within triangles, within triangles...
There are many types of iterated process that we could examine to see if they produce fractals but the best known is the one that produces the Mandelbrot set and so we had probably better look at this one in some detail. I should warn you at this point that the Mandelbrot set is simple to define but much misunderstood. The Mandelbrot IterationThe definition of the Mandelbrot set is very simple, as long as you know how to do arithmetic with complex numbers. The iteration at the heart of the set is just: z2+c -> z That is, we take an initial z, square it and add the constant c to produce the new value of z. We just repeat this over and over to generate a sequence of values of z. For example, if c is 2 and we start z off at 0 we get 2, 6, 38 and so on at each iteration. It is clear that for any value we choose this particular sequence is just going to get bigger and bigger but, and this is important, if we choose to use complex numbers this isn’t always the case. A complex number is really a two-dimensional thing and can be written as: z=x+iy where x and y are just ordinary real numbers. In this form the iteration can be written as: z<- x2-y2+a+i(2xy+b) where a and b are the real and imaginary parts of the constant c (c=a+ib). In this case you can see that it isn’t 100% certain that the value that you get will simply increase. The minus y squared term might well rescue the sequence from infinity. Of course in this case we have to define what we mean by “getting bigger” or the “size” of a complex number. If you think of c defining a point a,b in the plane then each iteration moves the point to a new location. There are only two possibilities – either the point moves off further and further away from the origin (i.e. 0,0) or it doesn’t. The set of points that doesn’t vanish off to infinity is the Mandelbrot set. That is the Mandelbrot set is the set of values of c for which the iteration doesn't diverge to infinity. Coloring The Mandelbrot SetThere are many things that are interesting about the Mandelbrot set and the first is that it isn’t colored as shown in almost every picture of it. In fact the Mandelbrot set is the black shape in the usual picture not the amazingly colored region that everyone enjoys looking at! These pictures are colored by assigning a color to points that go off to infinity according to how fast they do it! In other words, the color points in the picture are definitely NOT part of the Mandelbrot set!
The Mandelbrot set is the black bit in the middle!
The really interesting thing about the Mandelbrot set is how complicated it is. You would think that points that don’t go off to infinity would be close to other points that do go off to infinity and that this would be determined by some simple condition and hence the set should have a simple shape. Well none of these obvious facts seem to be true and the Mandelbrot set is very complicated and far from smooth. If you zoom in on it then you see more and more detail that seems to go on without end. The Mandelbrot set is fractal. |
||||
Last Updated ( Thursday, 18 July 2019 ) |