MATH 1906, Chaos in Dynamical Systems

3- Chaos in the Logistic Equation

Lecturer: Eduardo G. Altmann

Key concepts are marked in red .
More on Jupyter notebooks: www.jupyter.org

In [31]:
%pylab notebook
import warnings
warnings.filterwarnings('ignore')
Populating the interactive namespace from numpy and matplotlib

3- Logistic Equation with $a=4$

$$ x_{t+1} = F(x_t)$$ $$ x_{t+1} = a x_t (1-x_t)$$

3.1 Numerical Exploration

Numerics for $a=4$

In [2]:
def ff(x):
    return 4.0*x*(1-x)

Periodicity?

In [14]:
xp=np.pi/10
for t in range(100):
    x=ff(xp)
print(xp)
0.3141592653589793
In [17]:
x1=xp
x2=x1+0.0001
x=np.array([x1,x2])
In [18]:
listx=[]
listt=[]
for t in range(100):
    listx.append(x)
    listt.append(t)
    x=ff(x)
plot(listt,listx,'-o');

Sensitivity to initial conditions?

In [19]:
x1=0.34347036018297582682
x2=x1+0.000001
x=np.array([x1,x2])
listx1=[]
listx2=[]
listt=[]
for t in range(50):
    listx1.append(x[0])
    listx2.append(x[1])
    listt.append(t)
    x=ff(x)
plot(listt,listx1,'-o')
plot(listt,listx2,'-o')
x1s=np.array(listx1)
x2s=np.array(listx2)
In [21]:
pyplot.yscale('log')
xlabel("t")
ylabel("$|x(t)-x'(t)|$")
plot(listt,abs(x1s-x2s))
Out[21]:
[<matplotlib.lines.Line2D at 0x7f9d6dca1780>]

Growth of initial displacement

$$\Delta x(t) = \Delta x(0) e^{t \ln \lambda}$$

Statistics of trajectories

Multiple trajectories

In [33]:
x=np.arange(0,1,1/50000)
for t in range(1000):
    x=ff(x)
ylabel("$\rho(x)$")
xlabel("x")
plt.hist(x,normed=True,bins=100,color="red");

Single trajectory

In [34]:
x=0.3141592653589
listx=[]
listt=[]
for t in range(50000):
    listx.append(x)
    x=ff(x)
plt.hist(listx,normed=True,bins=100,color="blue");

Ergodicity: statistics over $t$ of a single trajectory equals the statistics over many trajectories at fixed $t$ (for large $t$)

$$ \lim_{T\rightarrow\infty} \frac{1}{T} \sum_{t=1}^T h(f^t(x_0) = \int_0^1 h(x) \rho(x) dx $$

Comparison with theoretical calculation

$$ \rho(x) = \frac{1}{\pi\sqrt{x(1-x)} }$$

In [38]:
x=np.arange(0,1,1/500000)
for t in range(100):
    x=ff(x)
plt.hist(x,normed=True,bins=100,color="red");
y=np.arange(0,1,1/500)
plt.plot(y,1/(np.pi*np.sqrt((y*(1-y)))),"--",linewidth=2,color="black");