> with(plots):

> lmd:=3.9/4:N:=30: # Choose the parameter value and the number of iterates.

> f:=(lmd,x)->4*lmd*x*(1-x): #Define the Logistic family.

> p1:=plot({[1,0],[1,1]},x=0..1,y=0..1):p2:=plot(x,x=0..1,y=0..1):p3:=plot(1,x=0..1,y=0..1): # Plot the box 0<=x<=1,0<=y<=1 and the diagonal y=x.

> iterate1:=plot(f(lmd,x),x=0..1,y=0..1,color=black): # Plot the graph f.

> x0:=evalf(rand()/10^12):x1:=f(lmd,x0):P:=[[x0,0],[x0,x1]]: #Randomly initialize a point and its 1st iterate.

> for n from 1 to N-1 do x0:=x1:x1:=f(lmd,x0):P:=[op(P),[x0,x0],[x0,x1]]:od: #Generate the points of cobweb plot.

> cobweb:=plot(P,color=blue):

> display({p1,p2,p3,iterate1,cobweb}); # The Cobweb plot.

>