Processing math: 100%
In [1]:
%pylab notebook
Populating the interactive namespace from numpy and matplotlib

2- A simple model

2.1 Motivation for the Logistic Equation

xt+1=F(xt) xt+1=axt(1xt)

In [2]:
def f(x,a):
    return a*x*(1-x)

2.2 Explorations of 1<a<3

Numerics for a=2

In [3]:
x=np.array([0.81131431,0.13443,0.26575])
listx=[]
listt=[]
for t in range(30):
    listx.append(x)
    listt.append(t)
    x=f(x,2)
#a=2,10.0/3,3.82843
plot(listt,listx,'-o');

Fixed points </red>

xn+1=f(xn)=xn for xn=x(1)f(x(1))=x(1)x(1)=11/a

2.3 Numerical Exploration for a=3.2

In [4]:
listx=[]
listt=[]
x=np.array([0.13,0.23,0.93])
for t in range(30):
    listx.append(x)
    listt.append(t)
    x=f(x,10./3)
#a=2,10.0/3,3.82843
plot(listt,listx,'-o');

Periodic orbit (period 2) analysis

</red>

x(2)=f(f(x(2))) x(2)±=12a((a+1)±a22a3)

Two periodic points of the period 2 orbit: x=f(x+) and x+=f(x)

In [5]:
def x2(a):
    return (a+1-np.sqrt(a*a-2*a-3))/(2*a)
In [6]:
f(x2(3.2),3.2)
Out[6]:
0.7994554904673701
In [7]:
f(f(x2(3.2),3.2),3.2)
Out[7]:
0.5130445095326298

2.4 Stability Analysis

A periodic orbit of period n of the map F is linearly stable if

|λ||ni=1F(xi)|<1,

where xi is the i-th point of the orbit and F(x)dFdx. If |λ|>1 the orbit is unstable.

Stability analysis </red>

Fixed point x(1): λ=2a|λ|<1 for 1<a<3 Periodic orbit of period 2, x(2): λ2=a2+2a+4|λ|<1 for 3<a<1+63.45 </font>

2.5 Dependence on a (parameter analysis)

In [8]:
aa=np.arange(1,4,.001)
a=np.arange(3,4,.001)
xlabel("a")
ylabel("x")
plot(aa,(1-1/aa),'--',color="blue")
plot(a,((1/(2*a))*(a+1+np.sqrt(a**2-2*a-3))),'--',color="red")
plot(a,((1/(2*a))*(a+1-np.sqrt(a**2-2*a-3))),'--',color="red")
Out[8]:
[<matplotlib.lines.Line2D at 0x7ff4bd34fac8>]

Numerical Experiment

In [9]:
# Empty lists to collect results
lista=[]
listx=[]
#Loop for parameter a in a given range
for a in np.arange(1.,4.0,0.001):
    x=np.arange(0.001,1,0.01) #Initial conditions, uniformly distributed
    for t in range(500): # Iterate the map many times
        x=f(x,a)
    lista.append(np.full(len(x),a)) #List of values of a, convenient to plot
    listx.append(x) #At the end, store output of x in listx
In [10]:
#Plotting the results of simulations above
plot(lista,listx,'.',color="black",markersize=.15);
In [11]:
#Plotting the results of simulations above
xlabel("a")
ylabel("x")
plot(lista,listx,'.',color="black",markersize=.1);

2.6 Gaphical method

In [14]:
a=4
#a=4.0
x=np.arange(0,1,.001)
xlabel("$x_n$")
ylabel("$x_{n+1}$")
plot(x,f(x,a))
#plot(x,f(f(x,a),a))
#plot(x,f(f(f(x,a),a),a))
plot(x,x,"--",color="black");
In [15]:
# Birth of the period 2 orbit: period-doubling bifurcation
x=np.arange(0,1,.001)
a=2.9
plot(x,f(f(x,a),a),color="blue")
a=3.2
plot(x,f(f(x,a),a),color="red")
plot(x,x,"--",color="black")
Out[15]:
[<matplotlib.lines.Line2D at 0x7ff4bec44668>]
In [16]:
# Birth of the period 3 orbit: saddle-node bifurcation
x=np.arange(0,1,.001)
a=3.82
plot(x,f(f(f(x,a),a),a),color="blue")
a=3.84
plot(x,f(f(f(x,a),a),a),color="red")
plot(x,x,"--",color="black")
Out[16]:
[<matplotlib.lines.Line2D at 0x7ff4bc8987f0>]