import numpy as np import matplotlib.pyplot as plt print "Mapeo Logistico" def mlog(x,r): return r*x*(1-x) r0 = 3.3; x0= 0.2 Nsteps = 50 xevolution = [] xcob= [] xnewcob= [] xevolution.append(x0) xcob.append(x0) xnewcob.append(0) for i in range(Nsteps): xn = xevolution[-1] xnp1 = mlog(xn,r0) xevolution.append(xnp1) xnewcob.append(xn) xnewcob.append(xnp1) xcob.append(xnp1) xcob.append(xnp1) print i,xnp1 plt.ion() plt.figure() plt.title("r="+str(r0)) plt.xlabel(r"$t$") plt.ylabel(r"$x_n$") plt.plot(xevolution,'ro-') plt.savefig('timeseries'+str(r0)+'.png',dpi=100) plt.show() plt.figure() plt.title("r="+str(r0)) plt.xlabel(r"$x_n$") plt.ylabel(r"$x_{n+1}$") eje = np.linspace(0,1,100) curva = [mlog(x,r0) for x in eje] plt.plot(eje,curva,"k-") plt.plot(eje,eje,"k-") plt.plot(xnewcob[1:],xcob[1:],'ro-') plt.savefig('cobweb'+str(r0)+'.png',dpi=100) plt.show()