But better die than live mechanically
a life that is a repetition of repetitions.
— D. H. Lawrence, Women in Love
The Mandelbrot set is one of the most fascinating objects in mathematics. It is based on a computational process that repeatedly applies the mapping \(z \mapsto z^2+c\), where \(z\) and \(c\) are complex numbers and
the starting value is \(z_0=0\). This process gives us the following infinite sequence \((z_k)\) of complex numbers:
\(\seteqnumber{0}{2.}{0}\)
\begin{align*}
z_0 &= 0\\ z_1 &= z_0^2 + c\\ z_2 &= z_1^2 + c\\ \dots &= \dots
\end{align*}
The behavior of this sequence depends on the parameter \(c\). For some values, the sequence diverges, which means that the numbers \(z_k\) gradually move away from the origin. But for other values of \(c\), the sequence is bounded: all numbers \(z_k\) stay in a fixed circle around
the origin. If we now examine all possible values of \(c\) and mark those for which the sequence \((z_k)\) is bounded, we obtain the pear-shaped object at the center of Fig. 2.1. This is the Mandelbrot set.
Figure 2.1 The Mandelbrot set. At first glance, the Mandelbrot set in the middle appears to be a solid black object with a few bumps on its surface. But if you magnify any part of the boundary and colorize the result, intricate geometric
patterns appear everywhere you look.
The real beauty of this set emerges if we magnify any region close to the boundary of this black shape and add a little color; four such regions are shown in the figure. No matter where you look or how far you zoom into the boundary, new variations of spirals, tendrils, and ornaments keep appearing. In
this chapter we will discuss how to compute these images ourselves.
Let’s start with a few preliminaries before we turn to the problem of computing and visualizing the Mandelbrot set. The mapping \(z\mapsto z^2+c\), and therefore the Mandelbrot set itself, is defined in terms of complex numbers. You can think of a complex number as a pair of real numbers that is written in the form \(z=x + \I y\), where \(x\) is called the real part of \(z\) and \(y\) its imaginary part. The symbol \(\I \) is called the imaginary unit. There is a one-to-one correspondence between points \((x,y)\) in the plane and complex numbers \(x+\I {}y\). Complex numbers are therefore often said to live in the complex plane, and this geometric interpretation helps us visualize many of their properties. But compared to geometric points, complex numbers have a much richer algebraic structure: We can add, subtract, multiply, and divide complex numbers, they follow the same laws of
algebra as the real numbers, and it is even possible to generalize common functions such as powers, square roots, \(\sin \), and \(\exp \) to complex arguments.
To compute the Mandelbrot set, we will only need a few elementary arithmetic operations. To add and subtract complex numbers, you simply add or subtract their real and imaginary parts separately. For two complex numbers \(z = x+\I y\) and \(w = u+\I v\) we have:
\(\seteqnumber{0}{2.}{0}\)
\begin{align}
z + w &= (x + u) + \I (y + v)\\ z - w &= (x - u) + \I (y - v)
\end{align}
The rules for multiplication and division are slightly more complicated and less obvious. The product of two complex numbers is defined as
\(\seteqnumber{0}{2.}{2}\)
\begin{equation}
z w = (x u - y v) + \I (x v + y u)
\end{equation}
and their quotient as
\(\seteqnumber{0}{2.}{3}\)
\begin{equation}
z / w = \frac {x u + y v}{u^2 + v^2} + \I \frac {y u - x v}{u^2 + v^2}.
\end{equation}
These definitions ensure that most of the familiar laws from real arithmetic carry over to complex numbers and that expressions involving complex numbers can be manipulated as normal. For instance, complex addition and multiplication are commutative and associative, the distributive law \((a+b)c =
ac + bc\) holds, and we have \(a/b = a\cdot 1/b\).
The most famous property of complex numbers is the fact that the square of the imaginary unit is \(-1\), which follows directly from the definition of multiplication:
Thanks to this identity, the square root function can be extended to negative numbers when working with complex numbers. For instance, we have \(\sqrt {-1}=\I \) and \(\sqrt {-4}=2\sqrt {-1}=2\I \). The absolute value (or modulus) of a complex number \(z=x+\I y\) is
defined as its distance from the origin: \(|z|=\sqrt {x^2 + y^2}\).
The Mandelbrot Iteration
The Mandelbrot set is based on the following infinite sequence of complex numbers \(z_k\) that starts at the origin:
The parameter \(c\) is an arbitrary complex number, so these equations define an endless number of infinite sequences. We also write \(z_k(c)\) to emphasize the dependence of the sequence on the parameter \(c\).
Example2.1. Let’s take a look at a few examples to see how these sequences behave. The simplest case is \(c=0\), which gives us \(z_k=0\) for
every \(k\); the resulting sequence consists of an infinite number of zeros \(0,0,0,\dots \). For \(c=1\) we obtain the sequence \(0, 1, 2, 5, 26, 677, \dots \) in which each number is \(1\) plus the square of the previous number; this sequence grows without bound. Finally, for the
complex unit \(c=\I \), we obtain a sequence that starts with the numbers \(0\), \(\I \), \(-1 + \I \), \(-\I \), \(-1+\I \) and then continue to alternate between the last two numbers.
As mentioned in the introduction, the Mandelbrot set consists of those numbers \(c\) for which the sequence \(z_k(c)\) stays bounded, that is, for which all numbers in the sequence \(z_k\) remain inside some finite region around the origin. We just saw that the sequences for \(c=0\) and \(c=\I \) are bounded, so these two numbers are part of the Mandelbrot set,
but the number \(c=1\) is not in the set because its sequence diverges.
We can now draw a black-and-white image of the Mandelbrot set by choosing a region of the complex plane, dividing it into width times height square “pixels” and setting each one to either black or white depending on the escape time of the complex number at its center
(Algorithm 2.1).
Algorithm 2.1
Draw a black-and-white image of the Mandelbrot set.
But how do we determine whether, for a given value of \(c\), the sequence \(z_k(c)\) is bounded or unbounded? The goal is to develop a criterion that is based on computing and analyzing a finite number of terms \(z_0, z_1, \dots , z_n\) and that gives us the correct answer with a reasonable
level of accuracy.
Fortunately, the Mandelbrot iteration has an important property that makes it easy to identify the majority of unbounded sequences. The key insight is that the sequence \(z_k(c)\) is guaranteed to diverge if there is just one \(j\) for which \(|z_j(c)|>2\).
Conversely, every bounded sequence must satisfy \(|z_k(c)|<2\) for all \(k\), that is, the sequence in its entirety is confined to a circle of radius 2. The number 2 is also called the escape radius of the Mandelbrot iteration because the sequence diverges or “escapes” once it crosses this threshold. For the mathematically inclined, a proof of this result is provided in Box 2.1. Let us define the escape time of a number \(c\) as the smallest index \(j\) for which \(z_j(c)\) lies outside the escape radius. If the sequence never leaves the escape radius, the escape time is infinite.
Box 2.1: Escape Radius of the Mandelbrot IterationHere is the proof that the Mandelbrot sequence \(z_k(c)\) diverges once it crosses the escape radius 2. We first show that under certain
conditions every step of the Mandelbrot iteration moves us further away from the origin, and we then prove that these conditions are always met.
First, assume that the \(j\)th element of the sequence \(w=z_j(c)\) satisfies both \(|w|>2\) and \(|w|>|c|\). If this is the case, every additional step of the Mandelbrot iteration takes us even further away from the origin because the absolute
value \(|w|\) is less than the absolute value of the next element in the sequence \(|w^2+c|\):
We now show that every sequence that crosses the escape radius must have an element \(w\) that satisfies both \(|w|>2\) and \(|w|>c\). We distinguish two cases. If \(|c|\le 2\), the first \(z_m\) that lies outside the escape radius obviously satisfies
\(|z_m|>2\ge |c|\), so we are already done. Otherwise, if \(|c|>2\), we consider the first three elements of the sequence:
Therefore, regardless of the value of \(c\), the Mandelbrot iteration diverges once it crosses the escape radius.
The escape radius is illustrated in Fig. 2.2, which shows the Mandelbrot set embedded inside a circle of radius 2. The three paths shown in the image illustrate the behavior of sequences \(z_k(c)\)
for different parameters \(c\). Two of the paths remain inside the escape radius indefinitely, so their escape time is infinite and the respective starting points belong to the Mandelbrot set. The third path, on the other hand, leaves the circle after five steps and then escapes to infinity. The escape time
of the starting point \(c=-0.9+0.5\I \) is therefore \(5\) and the number does not belong to the Mandelbrot set.
Figure 2.2 Trajectories of the Mandelbrot iteration. The Mandelbrot iteration produces a sequence of complex numbers that either stays inside the escape radius shown in gray or leaves it after a finite number of steps.
To compute the escape time of a number \(c\), we first compute successive values \(z_0, z_1, \dots \) of the Mandelbrot iteration. If we reach a number with \(|z_j|>2\) we stop immediately and return \(j\) as the escape time. Otherwise, we continue until
we reach a certain iteration limitMaxIter. Every sequence that is still inside the escape radius after MaxIter steps is considered bounded. The larger we choose the iteration limit, the more
accurate our computation becomes. A small iteration limit of \(100\) is sufficient for drawing low-resolution images of the Mandelbrot set, but larger values are necessary to resolve fine details at higher magnifications.
The escape time is also the key to creating images of the Mandelbrot set that are far more rich and detailed than the simple black-and-white images we used so far. Figure 2.3 shows the result of mapping
different escape times to different colors. Numbers outside the escape radius (escape time 0) are shown as light blue pixels, and as we get closer to the boundary of the Mandelbrot set, the escape time increases and slowly shifts from blue to red and yellow (escape time 80). Numbers with an
infinite escape time are still shown as black pixels. The algorithm for drawing the Mandelbrot set in color is summarized in Algorithm 2.2.
Figure 2.3 The Mandelbrot set can be colorized by assign each escape time a different color. The color mapping used for this image is shown at the bottom.
Algorithm 2.2
Draw a colored image of the Mandelbrot set.
Exercises
Exercise 2.1.The best way to appreciate the beauty and complexity of the Mandelbrot set is to explore it interactively. Use one of the many free fractal viewers available on the
Internet to find your favorite spots in the Mandelbrot set. Here are the coordinates of a few interesting regions to get you started: the seahorse valley around \(-0.75+0.1\I \); the elephant valley around \(0.3 + 0\I \); and the northwest bulb
around \(-0.5434 + 0.6132\I \).