In [1]:
%run Steppers.ipynb #Import stepper functions (Euler, RK4, etc)
%run ODEs.ipynb     #Import ODEs (Pendulum etc)
import matplotlib as mpl
mpl.rc("savefig", dpi=500) #Set inline dpi for notebook images
import matplotlib.pyplot as plt

In [2]:
def LogisticMap(x0, n, r):
    x=np.zeros(n)
    x[0]=x0
    for i in range(1,n):
        x[i]=r*x[i-1]*(1-x[i-1])
    return(x)

In [3]:
fig = plt.figure()


n = 100
x0= 0.5
r = 3

x = LogisticMap(x0=x0, n=n, r=r)

ns = range(n)
plt.plot(ns,x,label="$x_0= ${x0:.0f}$r= ${r:.0f}".format(x0=x0, r=r))
plt.show()



In [4]:
transient=300
duration=200
n = transient + duration

x0= 0.5
rs = np.linspace(0,4,50000)

#Preallocate arrays because appending is slow
xPlot=np.empty(len(rs)*duration)
yPlot=np.empty(len(rs)*duration)

for i,r in enumerate(rs):
    x = LogisticMap(x0=x0, n=n, r=r)
    xPlot[i*duration:(i+1)*duration]=r
    yPlot[i*duration:(i+1)*duration]=x[transient:]

In [5]:
fig = plt.figure()
fig.set_size_inches(15,15)
plt.plot(xPlot, yPlot,"o", markersize=0.05, alpha=0.1)
plt.savefig("Figures/LogisticBifurcation.png", format="png", dpi=500)
plt.show()



In [6]:
transient=300
duration=200
n = transient + duration

x0= 0.5
rs = np.linspace(2.8,4,50000)

#Preallocate arrays because appending is slow
xPlot=np.empty(len(rs)*duration)
yPlot=np.empty(len(rs)*duration)

for i,r in enumerate(rs):
    x = LogisticMap(x0=x0, n=n, r=r)
    xPlot[i*duration:(i+1)*duration]=r
    yPlot[i*duration:(i+1)*duration]=x[transient:]

In [7]:
fig = plt.figure()
fig.set_size_inches(15,15)
plt.plot(xPlot, yPlot,"o", markersize=0.05, alpha=0.1)
plt.savefig("Figures/LogisticBifurcationZoom.png", format="png", dpi=500)
plt.show()



In [ ]: