Illustration of the logistic map

Illustration of the logistic map, xn+1=f(xn)=rxn(1xn)

At r1=3, a stable period 21=2 orbit is born. At r2=3.449 a stable period 22=4 orbit is born. As r continues to increase, the period doublings continue until r3.56995 after which chaotic dynamics begin to occur, interspersed with periodic windows.

The Feigeinbaum constant δ=4.6692 is the ratio of subsequent differences between the values of rn at which the period doubles, as n approaches infinity.

import numpy as np
import matplotlib.pyplot as plt
import pylab

def f(x, R):
    return R * x * (1 - x)

def run_simulation(R, x_0, num_steps):
    x_list = np.zeros(num_steps)
    x_list[0] = x_0   
    for t in range(num_steps-1):
        x_list[t+1] = f(x_list[t], R)       
    return x_list

def plot_two(x_list, y_list):
    plt.plot(x_list)
    plt.plot(y_list)
x_list = run_simulation(R=4, x_0=0.7, num_steps=50)
y_list = run_simulation(R=4, x_0=0.70001, num_steps=50)
plot_two(x_list, y_list)

png