# -*- coding: utf-8 -*- import matplotlib #matplotlib.use('TkAgg') from pylab import plot, show, text, ion, ioff, draw, xlabel, ylabel,xlim,ylim import numpy as np from time import sleep def fun(x,r): return r*x*(1-x) t = 1 iter = 20 u = np.zeros(iter) u[0] = 0.29 r = 3.1#2.5 u_s = np.arange(0,1,0.01) ion() plot(u_s, fun(u_s,r)) plot(u_s, fun(fun(u_s,r),r)) plot(u_s, fun(fun(fun(u_s,r),r),r)) xlabel('N_t') ylabel('N_{t+1}') text(0.8,0.4, 'N_{t+1}=f(N_t)') plot([0,1],[0,1]) u[1] = fun(u[0],r) plot([u[0],u[0]],[0,u[1]],'r') plot([u[0],u[1]],[u[1],u[1]],'r') for t in range(iter-1): u[t+1]=fun(u[t],r) plot([u[t],u[t]],[u[t],u[t+1]],'r') plot([u[t],u[t+1]],[u[t+1],u[t+1]],'r') u[t]=u[t+1] draw ioff() xlim([0,1]) ylim([0,1]) show()