Introduction to the Mandelbrot Set

First, a boring example

A sequence of numbers can be defined by a map. For example, consider the simple map $$f: x \rightarrow x + 1.$$ If we start from $x_0=0$, this generates the sequence $$0, 1, 2, 3, 4, 5, 6,\ldots.$$ Note that the sequence is unbounded; it diverges to positive infinity.

Taking different values of the addened $+1$ for this example is not much more interesting. For example, the map $$f: x \rightarrow x - 1.$$ generates the unbounded sequence $$0, -1, -2, -3, -4, -5, -6,\ldots,$$ which diverges to negative infinity.

It is pretty easy to see that any function $f(x) = x + c$ will not be any more interesting. All sequences will diverge to either positive or negative infinity (depending on the sign of $c$), while the case $c=0$ is the identity map, and generates the (extremely!) boring sequence $$0, 0, 0, 0, 0, 0, 0,\ldots.$$

A much more interesting example

Simply squaring the argument in the function makes in non-linear, $$f: x \rightarrow x^2 + c,$$ and things get much more interesting. For example, with $c=1$, we have the map $$f: x \rightarrow x^2 + 1,$$ which generates the sequence $$0, 1, 2, 5, 26, \ldots,$$ which diverges.

Taking $c=-1$, the map is $f(x)=x^2-1$, which generates the sequence $$0, -1, 0, -1, 0, -1, \ldots,$$ which stays bounded. Now it is helpful to use python to evaluate these sequences.


In [3]:
def f(x, c):
    return x**2 + c

In [4]:
x = 0.0
for i in range(10):
    print(i, x)
    x = f(x, 1)


0 0.0
1 1.0
2 2.0
3 5.0
4 26.0
5 677.0
6 458330.0
7 210066388901.0
8 4.4127887745906175e+22
9 1.9472704769152963e+45

In [5]:
x = 0.0
for i in range(10):
    print(i, x)
    x = f(x, -1)


0 0.0
1 -1.0
2 0.0
3 -1.0
4 0.0
5 -1.0
6 0.0
7 -1.0
8 0.0
9 -1.0

In [6]:
x = 0.0
for i in range(10):
    print(i, x)
    x = f(x, 0.1)


0 0.0
1 0.1
2 0.11000000000000001
3 0.1121
4 0.11256641
5 0.1126711966602881
6 0.11269479855686132
7 0.11270011762177155
8 0.11270131651196115
9 0.11270158674352926

Interesting! To explore this more, lets make a function that generates the sequence itself. We'll supply two numbers: the value of the constant $c$ and the number of terms in the sequence.


In [7]:
def make_sequence(c, n):
    x = 0.0
    sequence = [x]
    for i in range(n):
        x = f(x, c)
        sequence.append(x)
    return sequence

In [8]:
make_sequence(1, 10)


Out[8]:
[0.0,
 1.0,
 2.0,
 5.0,
 26.0,
 677.0,
 458330.0,
 210066388901.0,
 4.4127887745906175e+22,
 1.9472704769152963e+45,
 3.7918623102659254e+90]

In [9]:
make_sequence(-1, 10)


Out[9]:
[0.0, -1.0, 0.0, -1.0, 0.0, -1.0, 0.0, -1.0, 0.0, -1.0, 0.0]

In [10]:
make_sequence(-2, 10)


Out[10]:
[0.0, -2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0]

In [11]:
make_sequence(-2.01, 10)


Out[11]:
[0.0,
 -2.01,
 2.030099999999999,
 2.1113060099999963,
 2.447613067862105,
 3.9808097299693452,
 13.836846106218612,
 189.44831016717717,
 35888.65222519896,
 1287995356.5312781,
 1.6589320384461343e+18]

In [12]:
make_sequence(0.25, 10)


Out[12]:
[0.0,
 0.25,
 0.3125,
 0.34765625,
 0.3708648681640625,
 0.38754075043834746,
 0.4001878332503175,
 0.4101503018815839,
 0.4182232701335544,
 0.42491070368120404,
 0.430549106102856]

From these simple numerical tests, it is possible that these sequences generated by $f: x \rightarrow x^2 + c$ remain bounded for $c \in [-2,0.5]$. In fact, that can be proved mathematically.

What if we extend this idea to complex numbers, by taking a complex number $c$? What is the set of complex numbers $c$ for which $f: z \rightarrow z^2 + c$ remains bounded? It turns out this is a surprisingly complex and beautiful two-dimensional shape that we call the Mandelbrot set.

From Wikimedia Commons (public domain image):


In [ ]: