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.$$
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)
In [5]:
x = 0.0
for i in range(10):
print(i, x)
x = f(x, -1)
In [6]:
x = 0.0
for i in range(10):
print(i, x)
x = f(x, 0.1)
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]:
In [9]:
make_sequence(-1, 10)
Out[9]:
In [10]:
make_sequence(-2, 10)
Out[10]:
In [11]:
make_sequence(-2.01, 10)
Out[11]:
In [12]:
make_sequence(0.25, 10)
Out[12]:
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 [ ]: