I decided to indulge myself with the visual side of mathematics by generating some fractal images. This was something I'd tried to do back in the 1980's, but the speed of PC's in those days made the exercise prohibitive.

Although these images are complex, the maths and programming isn't. ( I can only assume that those people who choose to use ready written program like Apophysis, either don't understand the maths or can't program - I'm for doing it all myself).

Take for instance the Julia sets (one example is given below).

Julia Set for z^{2}+ 0.32 + 0.043i |

The Julia sets live in the complex plane and are crucial to the understanding of iterations of polynomials like z

^{2}+ c.

For the construction of Julia sets we fix c, and choose some initial value for z = z

_{0}, say. Then we repeat the process and calculate z

_{1}= z

_{0}

^{2}+ c, z

_{2}= z

_{1}

^{2}+ c, and so on.

In other words, for an arbitrary but fixed value of c, we generate a sequence of complex numbers {z

_{0}, z

_{1}, z

_{2},......, z

_{n}, z

_{n + 1}, ......} for each pixel. That's 1600

^{2}= 2,560,000 pixels in the images shown here.

Each sequence has one of two properties, either:

- the sequence remains bounded, i.e. you can draw a circle of (predefined), radius M around z
_{0,}and all members of the sequence will lie within its boundary, or - the sequence becomes unbounded, i.e. after a number of iterations the members of the sequence move outside the boundary of the circle.

*prisoner*set for c, while the sequence of points which lead to the second kind of behaviour is called the

*escape*set for c.

By writing a simple program we can investigate the behaviour of a whole range of starting values for z, and determine which starting values belong to the

*prisoner*and

*escape*sets.

In order to illustrate graphically if a point is in an

*escape*or

*prisoner*set we need to assign a colour to each point. Now if we define K to be the number of colours we can use, we can assign a colour number, that lies in the range 0 to K-1, to each starting point. That is, for each starting value, if the k

^{th}iteration (k < K), escapes the circle then assign the starting value the colour k. But if after K iterations all members of the sequence are still within the circle then assign the starting value the colour 0. Thus all

*prisoner*values will have colour 0 and all

*escape*values will have a colour in the range 1 to K-1.

In the fractals shown here, all pixels coloured Red represent

*prisoner*values and all the other pixels (including those coloured a lighter shade of red, represent

*escape*values.

zoomed in at 3 times magnification |

So how do we plot the values? Well if you remember we said that z is a complex number, i.e. z is of the form z = x +

We call x the

This means we can represent any value z as a pixel in the (x,y) plane with a colour k. Here is the Algorithm I used:

*i*y, where the numbers x and y are real numbers and*i*is the special number equal to the square root of -1, (so*i*^{2}= 1).We call x the

*Real*part of z and y the*imaginary*part of z.i is called animaginarynumber. Like infinity it cannot be calculated it is a mathematical definition, a convenience that enables mathematicians to investigate complex mathematical problems - like fractals.

This means we can represent any value z as a pixel in the (x,y) plane with a colour k. Here is the Algorithm I used:

**Algorithm:**

Decompose the complex numbers z and c into their real and imaginary parts,

i.e. z = x +

*i*y and c = p +*i*q, then (using the definition i^{2}= 1)z

= x

=x

^{2}+ c = (x+iy)^{2}+ p +*i*q= x

^{2}+ 2*i*xy +*i*^{2}y^{2}+p +*i*q*(but i*^{2}= -1, so substituting -1 for i^{2}and rearranging we have)=x

^{2}- y^{2}+ p +*i*(2xy + q).In other words the

*real*part of z^{2}+ c is x^{2}- y^{2}+ p, and the imaginary part (the bit multiplied by*i*)is 2xy + q.So in order to evaluate the sequence of complex values z

_{k}= z_{k-1}^{2}+ c we evaluate:x

_{k}= x_{k-1}^{2}- y_{k-1}^{2}+ p,y

_{k}= 2x_{k-1}y_{k-1}+ q...........

**Eqns 1**Now; assume the image we are going to produce has a graphical resolution of

*a*times*b*pixels, (1600 x 1600 say). Let there be K+1 colours that can be displayed simultaneously, numbered 0 through K, (K = 512 say).

*Step 0:*Choose a parameter c = p +

*i*q, (0.32 + 0.043*i*say)Choose x

_{min}= y_{min}= -1.5, x_{max}= y_{max}= 1.5 say,and define M (=100, say. i.e. our boundary circle will have a radius of 10).

Set d

_{x}= (x_{max}- x_{min})/(a-1), andd

_{y}= (y_{max}- y_{min})/(b-1).Then for all pixels (n

_{x}, n_{y}) with n_{x}= 0, ....., a-1 andn

_{y}= 0, ......, b-1we go through the following routine:

**:**

*Step 1***Set**

x

_{0}= x_{min}+ n_{x}d_{x}y

_{0}= y_{min}+ n_{y}d_{y}k = 0

**(iteration step):**

*Step 2:*Calculate (x

_{k + 1}, y_{k + 1}) from (x_{k}, y_{k}) using**Eqns 1**.Increase the counter k by 1 (k = k + 1).

**(evaluation step):**

*Step 3:*Calculate r = x

_{k}

^{2}+ y

_{k}

^{2}

- If r > M then choose colour k and go to Step 4.
- If k = K then choose colour 0 and go to Step 4.
- r ≤ M and k < K. Go back to Step 2.

**Assign colour k to the pixel (n**

*Step 4:*_{x}, n

_{y}) and go to the next pixel, starting with Step 1.

*: Varying the values of x*

**Remarks**_{min}, x

_{max}, ... in Step 0 you may produce blow ups. For example: the first image was produced using values -1.5 to 1.5, while the second image was produced by substituting values -0.5 to 0.5.

You can experiment by programming this algorithm in any language, Basic, Java, C, etc. but I used a favourite package of many mathematical programmers called Mathematica. Below is the actual code I used.

The boundary of the

*prisoner*set is simultaneously the boundary of the

*escape*set, and that joint boundary is the Julia set for the given c (and M).

## No comments:

## Post a Comment