Fractals – a bridge between maths, computing and the arts.

A few months ago, I became involved with a group called Moss Code. Their aim is to use computer coding to inspire and engage with people from the strongly Afro-Carribean Manchester suburb, Moss Side. I was made aware that the Afro-Carribean culture actually has a strong heritage using fractal-like sequences in their art and architecture. Please see this TED talk on the subject. My hope is to try and make a simple computer program for people to generate their own unique fractal patterns, with the possibility of printing them onto t-shirts and fabric bags! So in this post I want to share some of the amazing details of fractals and how such complex behaviour arises from surprisingly simple mathematics.

Figure 1. A range of different Julia Set fractals, all share classic fractal properties including self-similarity and symmetry.

Figure 1 shows a range of different Julia Set fractals despite containing very different patterns, they are all generated by the same equation, z = z² + c. So how does such complex behaviour arise from this simple equation? It all hinges on how the variable z grows when you iterate the equation. To clarify, when you iterate an equation you use the answer from the previous calculation as the input to the next.

Lets use a simple example. Say z starts at 0, and c = 1. The value c is a constant and cannot change, only z is able to change. The first iteration gives z = 0² + 1 which is 1. Now z=1, so the next iteration will be z = 1² + 1, which is 2. The next iteration gives 5, then 26, then 677, then 458330, then 210066388901, and so on. You can clearly see that z grows very quickly.

However, for some values of c, the value z stays much the same even after many iterations. You can try to tweak c to find the point between z remaining stable and shooting off towards infinity. If you try this, you’ll find that there is no simple cut-off point but a complex, chaotic region that we recognise is actually the basis of the fractal pattern. In Figure 2, I show this chaotic region by plotting the number of iterations the equation goes through before z reaches a predefined limit.

Figure 2. By changing c in the above equation even by a very small amount, we can see the number of iterations needed to reach a predefined threshold changes, at first steadily, but then chaotically.

It begins changing very slowly and predictably, but at some point it becomes chaotic. Sometimes the equation requires many iterations to reach the limit, while given another very similar value of c, the number of iterations required becomes very low. What is causing this behaviour? The simplest answer is positive feedback, or a runaway effect.

Figure 3. The equation z = z2 + c is iterated 30 times. The changing absolute value1 of z is shown for two similar values of c. Note the drastically different behaviour.

This effect is illustrated in Figure 3. Here the blue line increases sharply upwards while the green line fluctuates only slightly. The differences between the two lines is that the value c is altered by 0.003577. For the blue line this change is enough to make it go through a very rapid self-sustaining increase. While the green line goes up but then decreases again. It is this property of z and c that lies at the heart of creating the beautiful fractals in Figure 1.

Getting complex

The fact that the equation z = z² + c can decrease might be confusing. Surely, as z gets large, squaring it would just make it larger. Even if z is negative then squaring it will just turn it positive. So why doesn’t z get ridiculously large for all values of c? At this point it is important to say that both the values of c and z are not actually normal numbers, they are complex numbers.

Normal numbers are exactly what you would expect…each number is a single value which can be positive, negative or a fraction/decimal or all of these things. Complex numbers are a bit more…well, complex. They contain two components; a real number and an imaginary number. The real number is essentially the same as a normal number but the imaginary number (which is represented using either i or j) can become a negative number when it is squared, a normal number can never do that. It is this imaginary component of c and z that allows the equation z = z² + c to decrease when it is iterated.

Now we have cleared that up, lets break down what’s going on in a fractal image. The fractals shown in Figure 1 are simply showing the number of iterations needed for z to reach a threshold (in this case, 100). The two axes represent the different values of the real and imaginary components of the complex number c.

Figure 4. A fractal with the number of iterations needed for z to reach 100 labelled to 3 locations.

To get the colour of the image, we simply count the number of iterations needed for z = z² + c to reach 100. In the bottom of Figure 4, only 30 iterations were required, meaning the z increased quickly. Closer to the nucleus of the spiral, z increased more slowly, meaning the number of iterations the rises. If you followed the spiral inwards for ever, you would find that z would never reach the threshold and the number of required iterations would be infinite.

So to summarise, the amazing complexity of fractals is actually based on a simple equation or rule. In this post, I have only covered one type of fractal…the Julia Set. There are of course many others, such as the famous Mandelbrot set, Cantor set, Koch snowflake and many others, each with their own set of rules and equations. In my opinion, fractals are most remarkable because these abstract mathematical patterns are actually seen everywhere in the natural world; from small-scales such as Alveoli in your lungs or crystals of ice on a windscreen, to the large-scales like the outline of a coastline or the structure of galaxys. Fractals really bridge the gap between the simple mathematical world and the real world whilst providing amazing beauty along the way.

Post by: Dan Elijah.