The problem

next up previous
Next: Exploiting parallelism within Up: Computing the Mandelbrot set Previous: Computing the Mandelbrot set

The problem

The Mandelbrot set is the set of points in the complex plane which are quasi-stable when iterated in a function. The most commonly used function is

where the complex values and are the points being tested in the complex plane. In practice, for each point of the complex plane we compute until either the sum of the real and imaginary parts of exceeds four, or the number of iterations exceeds some fixed maximum resolution limit.
  The stability of a single point can be computed by the following C fragment

int pixel (float zr, float zi, int resolution)
  float cr = zr; 
  float ci = zi; 
  float zrs = 0; 
  float zis = 0;
  int colour,i;

  for (i=0; i<resolution; i++)
    if (!(zrs+ zis > 4.0))
            zrs =zr *zr;
            zis =zi *zi;
            zi =2.0*zr*zi+ci;
            zr =zrs-zis+cr;
            colour =i;
  return colour;
This fragment takes a couple of floating point values (zr,zi) representing a point in the complex plane and an integer value (resolution) which states the maximum number of iterations allowed. The two float variables ci and cr hold the initial value of corresponding to the point in the complex plane being tested. At the -th iteration the pair (zr,zi) holds the real and imaginary part of . The function returns a value colour holding either the first value of for which the magnitude 4.0 has been exceeded or resolution-1 if the threshold hasn't been exceeded. The two float variables zrs and zis hold the squares of zr and zi respectively, to avoid to compute them more than one time.

The P3l group ( )
Fri Sep 8 17:29:42 METDST 1995