What is the Mandelbrot Set, and How is it Drawn?

Fractals

In the images we are generating, the boundary between the Mandelbrot set (the black part) and the colorful part is an example of a "fractal".  What's a fractal?  Here is a partial explanation:

Most geometrical shapes that you run across are not fractals.  Non-fractals have the property that the closer you zoom in on them, the smoother (or straighter) the edges become.  For example, imagine a very twisty road, seen from high above, then imagine zooming in a little, then a little more, then a little more, etc.  The closer you zoom in, the straighter the road segment looks.

Unlike a twisty road or most other geometrical shapes that we are accustomed to, fractals have the interesting property that as you zoom in further and further, you discover more and more detail!  And this process is unbounded.  No matter how many times you zoom in, you will continue to see increasing detail.  A fractal is a shape with "infinite complexity". 

(The preceding was not really a proper definition of the term "fractal" -- for more information, please see this link about fractals.)

 

Complex Numbers

In order to understand how the Mandelbrot Set is constructed, you must have a basic knowledge of Complex Numbers.  Before reading any further on this page, please read this introduction to complex numbers and performing arithmetic with them.
 

The Mandelbrot Recurrence

Let z0 be any complex number.  We will define a sequence of complex numbers  z1, z2, z3, z4, etc. as follows:

z1 = z02 + z0           

z2 = z12 + z0

z3 = z22 + z0

z4 = z32 + z0

...

In general, for any positive integer n :

zn+1 = zn2 + z0

 

If you start with some complex number, z0, and go through and compute the sequence of values as described above, one of two things will happen.  For some starting values, the values in the sequence will get larger and larger and larger -- in this case, we say that the sequence "diverges".  For other starting values, the values in the sequence will always stay pretty small.  The Mandelbrot Set is the set of all starting values that do not yield diverging sequences.

 

The Complex Numbers can be Represented with the Cartesian Plane

There is an easy way to associate the cartesian coordinate system ("the x-y plane") with the set of Complex numbers.  Each point on the plane can be associated with a particular complex number.  For example, you can imagine that (6, 2), which is the point on the plane with x-coordinate 6 and y-coordinate 2, represents the complex number 6 + 2i.  The point (-3, -7) on the cartesian plane represents the complex number -3 -7i.   In this way, there is a one-to-one correspondence between the points on the plane and the set of Complex Numbers.

 

Drawing the Mandelbrot Set

Drawing the Mandelbrot Set amounts to assigning a color to each point on the Cartesian plane.  Each point in the plane is tested, and colored one of two ways.  The points that correspond to complex numbers that are in the Mandelbrot Set will be colored black; those not in the set will be colored with something other than black (as described below).  Actually, the Mandelbrot Set only takes up a small piece of the plane:  The entire thing fits into the rectangular region with an upper-left corner positioned at (-2, 1) and a lower-right corner positioned at (1, -1). 

One common technique for choosing colors is the following:

First of all, pick out your favorite 256 non-black colors, and give them numbers.  (Color #0 is pink, color #1 is green, color #2 is yellow, ... whatever.)  [By the way, it doesn't have to be 256, that was an arbitrary choice.]

Now set a "boundary for divergence" (typically the value is 2.0).

To figure out what color to give a particular point (a, b) in the Cartesian plane, begin by setting  z0 = a + bi.  Then start computing the terms in the sequence described above:  z1, z2, z3, z4...  As each term is computed, check to see whether or not the norm of the term is larger than 2.0.  There are two possible cases; below are examples illustrating each of the two possibilities:

  1. Consider the point ( -0.4, -0.5).  If we let z0 = -0.4 - 0.5i, and then compute the values of z1, z2, z3, and so on, we would find that after computing 256 terms in the sequence, all of the values in the sequence up to and including the last one, z255, have norms that are less than 2.0.  So we assume that the point ( -0.4, -0.5) is in the Mandelbrot set and we color it black.
  2. Consider the point ( -0.4, -0.6).  If you let z0 = -0.4 - 0.6i , you will find that the terms from z1 up through z24 all have norms that are less than 2.0.  But z25 has a norm that is just slightly bigger than 2.0.  We will then color the point (-0.4 - 0.6) with "color #25", whatever that is, since the 25th term was the first one to get "too big".

 

Web Accessibility