     The Mandelbrot Set : An Exercise in Complex Number Dynamics
     ___________________________________________________________


Besides being regarded as the 'father of Fractals', Benoit B. Mandelbrot
also discovered the potential of computer graphics for studying the
behaviour of complex numbers.  This has led to the beautiful graphics
derived from the 'Mandelbrot Set'.


COMPLEX NUMBERS

A complex number is one which involves the square root if -1.  There is no
real number with a negative square so an 'imaginary' quantity called i is
used to denote the square root of -1.  A complex number has the form x+iy
where x is the real part and iy is the imaginary part.  [If you are an
electrician you will use j instead of i because i denotes electrical
current.]

It helps to visualise a complex number as a point on a plane.  In this
way, just like on a graph, the x axis is the real part of the number and
the y axis is the imaginary part.  A complex number is a point on that
complex plane and the size of a complex number is its distance from the
origin.

So, if we have a number x+iy it has a size defined as the square root of
x-squared + y-squared.  In BASIC this is SQR(x^2+y^2).

Similarly in BASIC the square of x+iy is x^2+2ixy-y^2 since (iy)^2=-y^2.


THE MANDELBROT SET

Mandelbrot took a complex number z and a formula where z=z^2+c where c is
also complex.  Starting with z=0+i0 he used the formula to produce another
value of z, used that new value to produce another value, and so on.  This
iterative process is repeated while the size of z is watched at each
stage.  The iteration is carried out for a range of values of c.  For most
values of c the size of z will soon start to rise sharply towards
infinity.  It is said to be attracted towards infinity.  However for a few
values of c the size of z will never rise in this way and these values
comprise the Mandelbrot Set.

This all sounds rather dry on paper, so here we can turn to computer
graphics to produce a dramatic result.

The values of c for which the iteration is carried out can be laid out
across the computer screen.  As c is complex the horizondal axis of the
screen can be the real axis and the vertical axis can be the imaginary
axis.  For each point on the screen, and hence value of c, the iteration
of z into z^2+c is carried out.  The number of iterations it takes for the
size of z to reach a certain value is discovered.  This certain value is
representing infinity in the calculation but it actually need only be
SQR(2) since if the size is going to reach SQR(2) it will certainly reach
infinity.  The number of iterations determines the colour of the pixel on
the screen at c and so a pattern is produced.


THE PROGRAM 'MANSET'

In this Telesoftware transmission is a program called MANSET which is a
BASIC program to produce these graphics AND SAVE THEM TO DISC AS A SCREEN
DUMP.  It scans the screen in MODE 2 and colours the Mandelbrot set itself
black.  The iterations that do not tend towards infinity are coloured from
RED to WHITE in cycles.

Make sure you have a disc in the active drive with sufficient space on it
and, since the program saves as file SCREEN, rename any existing SCREENs
you do not wish to lose. 

The program as supplied draws the whole of the Mandelbrot set over the
range -2.25 to 0.75 real and -1.5 to 1.5 imaginary but you can easily
modify the program to draw over other ranges.  The lo and hi end of the
Real and Imaginary parameters are set in lines 50 to 80.

In practice the square of the size limit of z, set by line 220, is better
being larger than 2.  At 2 the program works but the symmetry of the image
is less pleasant than if the square of the limit were 40.  Above 40 there
is little, if any, change.

The number of iterations to attempt before assuming that the size will
never exceed the limit is critical.  Too few and the complicated shapes at
the boundary of the set will not appear, too many and the program will
take a long time to run with no tangible improvement in the image.  Here I
can only advise you to experiment, bearing in mind these factors.  The
whole of the set, as drawn in MANSET, works over 32 iterations and this
variable is set in line 230.

The boundary of the Mandelbrot set is a very complex fractal shape.  As
you expand it new and more fascinating shapes are revealed.  Change the
values of Rlo Rhi Ilo and Ihi to display a small section along the
boundary.  You will need a larger value of iterations% to show the detail
and you will need a great deal of patience.  The whole set will take a
couple of hours to draw up but a blowup could take a day or more!  Please
note that the BBC Micro is not rated for continuous operation.  I run mine
with the lid off if I need to run it a long time but any prolonged program
is run at your own risk since the micro may crash.

To gain speed in drawing a blowup you ought to use a 6502 second processor
(or a 32016 running BBC Basic) and pressing ESCAPE will save the screen
should you need to use the machine for something else.  To restart after
escaping you need to pick up where the program left off.  After ESCAPEing
you should discover the value of H% (just PRINT H%) and on restarting
modify line 250 to replace the 0 with your value.  Also add a line 115:

            115 *LOAD SCREEN

to reload your screen image so far drawn.

Besides blowing up a section of the boundary you might like to try a
different screen mode to gain definition.  For MODE 1 the STEP size in
line 250 needs to be 4 and in line 440 replace MOD 7 with MOD 3.  A
monochrome image in MODE 0 can be quite fascinating and for this you
should change the STEP size in line 250 to 2 and in line 440 replace MOD 7
+1 with MOD 2.  Obviously line 100 must be modified and note that a MODE 1
image takes twice as long as a MODE 2 and a MODE 0 image takes 4 times as
long.

Other experimentation can be done by studying the behaviour of z=z^3+c or
other such non-linear formulae and by iterating different values of c in
the z plane instead of z in the c plane as in the Mandelbrot set.


FURTHER READING

The definitive book on Mandelbrot set graphics is 'Frontiers of Chaos'
published by MAPART at the University of Bremen, Germany.  It was
available with the exhibition of the same name that recently toured
Britain.  In it is illustrated the work of Heinz-Otto Peitgen and
Peter H Richter who have used sophisticated number crunching and graphics
systems to produce some extraordinary pictures.  Your BBC Micro can
produce similar results to a less sophisticated level.

Their book includes some information on the algorithms used to produce the
pictures as well as values for the parameters used.  I am endebted to
these hints.  To get you started on other experimentation here are a
couple of other ranges for c suggested by MAPART:

               Rlo  -0.75104   Rhi  -0.7408
               Ilo   0.10511   Ihi   0.11536
This, iterated 200 times, was the BLOWUP transmitted last time.

               Rlo  -0.713     Rhi   0.4082
               Ilo   0.49216   Ihi   0.71429
It is said that exploring the set is not unlike following a map.  The
beautiful scenery is to be found at such and such a map reference.

Other reading:
Chaos : Dick Tahta
[Mathematics Teaching No 113, December 1985]

Bringing Back Beauty from the Frontiers of Chaos - Keith Devlin
[Guardian 4.7.85]

Stretching The Frontiers of Chaos - Keith Devlin
[Guardian 31.10.85]

The Mandlebrot Set (Sic) - Jim McCartney
[Computing Age Volume 1 Number 4, January 1986]

Computer Recreations (Exploring the Mandelbrot Set) - A K Dewdney 
[Sciendific American Volume 253 number 2 August 1985]

Number Crunching - Howard Oakley
[Personal Computer World Volume 9 Number 1 January 1986]


Andy Finney
February 9th 1986
