Complex Analysis

The Mandelbrot Set


Essentially, the Mandelbrot set is generated by iterating a simple function on the points of the complex plane. The points that produce a cycle (the same value over and over again) fall in the set, whereas the points that diverge (give ever-growing values) lie outside it. When plotted on a computer screen in many colors (different colors for different rates of divergence), the points outside the set can produce pictures of great beauty. The boundary of set is a fractal curve of infinite complexity, any portion of which can be blown up to reveal ever more more outstanding detail, including miniature replicas of the whole set itself.

The Mandelbrot set is certainly the most popular fractal, and perhaps the most popular object of contemporary mathematics of all. Since Benoît B. Mandelbrot (1924-2010) discovered it in 1979-1980, while he was investigating the mapping $z \rightarrow z ^2+c$, it has been duplicated by tens of thousands of amateur scientists around the world (including myself).


Constructing the Mandelbrot Set

Here is how the Mandelbrot set is constructed. Take a starting point $z_0$ in the complex plane. Then we use the quadratic recurrence equation $$z_{n+1}=z_{n}^2+z_0$$ to obtain a sequence of complex numbers $z_n$ with $n=0, 1, 2, \ldots$. The points $z_n$ are said to form the orbit of $z_0$, and the Mandelbrot set, denoted by $M$, is defined as follows:

If the orbit $z_n$ fails to go to infinity, we say that $z_0$ is contained within the set $M$. If the orbit $z_n$ does go to infinity, we say that the point $z_0$ is outside $M$.

Take, for example, $z_0=1$. Then we have \[ \begin{array}{rcl} %\hline %\text{ } & z_{n+1}=z_{n}^2+z_0 \\ %\hline z_0 &=& 1 \\ %\hline z_1 &=& 1^2 + 1 = 2 \\ %\hline z_2 &=& 2^2 + 1 = 5\\ %\hline z_3 &=& 5^2 + 1 = 26 \\ %\hline z_4 &=& 26^2 + 1 = 677 \\ %\hline &\vdots& \end{array} \] As you can see, $z_n$ just keeps getting bigger and bigger. Thus $z_0=1$ is not in the Mandelbrot set. But if we choose different values for $z_0$ this won't always be the case. Consider now the value $z_0=i$. In this case, we obtain: \[ \begin{array}{rcl} %\hline % \text{ } &=& z_{n+1}=z_{n}^2+z_0 \\ %\hline z_0 &=& i \\ %\hline z_1 &=& i^2 + i = -1 + i \\ %\hline z_2 &=& (-1+i)^2 + i = -2i+i = -i\\ %\hline z_3 &=& (-i)^2 + i = -1+i \\ %\hline z_4 &=& (-1+i)^2 + i = -i \\ %\hline &\vdots& \end{array} \] It is clear that in this case further iterations will just repeat the values $−1+i$ and $−i$. All of these complex numbers lie within distance 3 of the origin. So they stay in a bounded subset of the plane; they do not run out to infinity. So the number $z_0=i$ is in the Mandelbrot set.

It is great fun to calculate elements of the Mandelbrot set and to plot them. The resulting set is endlessly complicated. And for this purpose we can use the power of the computer. In the applet below a point $z_0$ is defined on the complex plane. Since the computer can not handle infinity, it will be enough to calculate 500 iterations and use the number $10^8$ (instead of infinity) to generate the Mandelbrot set:

If the orbit $z_n$ is outside a disk of radius $10^8$, then $z_0$ is not in the Mandelbrot Set and its color will be WHITE. If the orbit $z_n$ inside that disk, then $z_0$ is in the Mandelbrot Set and its color will be BLACK.

Now explore the iteration orbits in the applet. Observe its behaviour while dragging the point. Activate the Trace box to sketch the Mandelbrot set or drag the slider.

Sorry, the applet is not supported for small screens. Rotate your device to landscape. Or resize your window so it's more wide than tall.



Colorful Mandelbrot Set

In the previous applet the Mandelbrot set is sketched using only one single point. However, it is possible to plot it considering a particular region of pixels on the screen. The simplest algorithm for generating a representation of the Mandelbrot set is known as the escape time algorithm. A repeating calculation is performed for each $x$, $y$ point in the plot area and based on the behavior of that calculation, a color is chosen for that pixel.

In the following applet, the HSV color scheme is used and depends on the distance from point $z_0$ (in exterior or interior) to nearest point on the boundary of the Mandelbrot set. In other words, provided that the maximal number of iterations is sufficiently high, we can obtain a picture of the Mandelbrot set with the following properties:

  1. Every pixel that contains a point of the Mandelbrot set is colored black.
  2. Every pixel that does not cotain a point of the Mandelbrot set is colored using hue values depending on how close that point is to the Mandelbrot set.

Now explore the Mandelbrot set. Zoom in or out in different regions. Change the number of iterations and observe what happens to the plot. You can also plot the orbit.

Pssst! If you are using a tablet, try this applet in your desktop for better interaction.

+: Zoom In
-: Zoom Out
R=Reset view
O=Orbit
I=Information & Frame

Sorry, the applet is not supported for small screens. Rotate your device to landscape. Or resize your window so it's more wide than tall.



Further reading

Although the Mandelbrot set is defined by a very simple rule, it possesses interesting and complex properties that can be seen graphically if we pay close attention to the computer-genereted pictures. For example, a geometric question we can ask: Is it connected? That is, is it just of one piece? This turns out to be true, and was proved by Adrien Douady and John H. Hubbard in the 80's.

The Mandelbrot set has been widely studied and I do not intend to cover all its fascinating properties here. However, if you want to learn more details I recommend you to consult B. B. Mandelbrot's works:

The applets were made with GeoGebra and p5.js. The source code is available in the following links:

If you want to learn how to program it yourself, I recommend you this tutorial

Finally, if you are adept at programming, then you can easily translate the pseudocode below into C++, Python, JavaScript, or any other language. For each pixel on the screen perform this operation:

{
  x0 = x co-ordinate of pixel
  y0 = y co-ordinate of pixel
  
  x = 0
  y = 0
  
  iteration = 0
  max_iteration = 1000
  
  while ( x*x + y*y <= (2*2) AND iteration < max_iteration )
  {
    xtemp = x*x - y*y + x0
    y = 2*x*y + y0
    
    x = xtemp
    
    iteration = iteration + 1
  }
  
  if ( iteration == max_iteration )
  then
    color = black
  plot(x0,y0,color)
  else
    color = iteration
  
  plot(x0,y0,color)
}

NEXT: The Julia Set