Bifurcation and Chaos#
Let’s evaluate that formula on a regular grid and create a plot to see a pattern.
Show code cell source
%matplotlib widget
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
plt.rcParams['figure.dpi'] = 300
# prepare list of numbers to analyze
x_min, x_max = -2.1, .5
max_iterations = 50
resolution = 300
x = [x_min + (x_max - x_min) / (resolution - 1) * index for index in range(resolution)]
# updated calculate function to track all intermediate results
def calculate(x, max_iterations):
x0 = x
results= []
for index in range(max_iterations):
x = x**2 + x0
if x > 10:
break
results.append(x)
return results
# Run the calculations
y = [calculate(_x, max_iterations) for _x in x]
fig, axes = plt.subplots()
for _x, _y in zip(x, y):
__x = [_x for _ in _y]
axes.plot(__x, _y, "b.", markersize=1)
axes.set_ylim(-2.2, 2.2)
plt.tight_layout()
Quite impressive. A great mixture between order and chaos.
Benoit Mandelbrot went a step further and analyzed this formula for the complex plane
instead of the real numbers alone.
So let’s add this axis as well to our problem.