Iteration of Functions

Cobweb Plots

The following module produces a “Cobweb Plot”. (Code modified from https://community.wolfram.com/groups/-/m/t/153946)

cobwebPlot[f_,start_,n_,xrange:{xmin_,xmax_}]:=Module[{cob, coor,x,g1,g2},
cob=NestList[f,N[start],n];
coor = Partition[Riffle[cob,cob],2,1];
coor[[1,2]]=0;
g1=Graphics[{Purple,Opacity[0.2],Line[coor]}];
g2=Plot[{x,f[x]},{x,xmin,xmax},PlotStyle->{Blue,Black}];
Show[{g1,g2},Frame->True]
]

Usage is: cobwebPlot[ function, starting value, number of iterates, {xmin, xmax} ], where xmin and xmax specify the domain to be plotted.

Define the function to iterate:

r=3.9;
g[x_]:=r*x(1-x)

cobwebPlot[ g, 0.3, 1000, {0,1} ]

Make a Bifurcation Diagram

ClearAll[f]
f[r_][x_]:=r*x(1-x)

orbit[r_]:=Drop[ NestList[f[r], 0.1, 500], 100]

orbit[3.5]

column[r_]:={r,#}&/@orbit[r];
bifDiagram=Graphics[ {PointSize[0.001],Opacity[0.1], Point[Flatten[Table[column[r], {r,1,4,0.001}],1]]}, AspectRatio->1/2, Frame->True]

Woah! Let’s investigate this further next time!