################################################ # # First time t is discrete and has values t=0,1,2... # # Use the function mod(t,n) which when n=2 # # mod(t,2) = 0 if t even # = 1 if t odd # # Then, define a function g(x,y) # # g(x,y) = y if t odd # = f(x) if t even # g(x,y)=if(mod(t,2)<.5)then(f(x))else(y) # ################################################ # # Now define a 2-D map which returns the # points (x(t),y(t)) which make up the cobweb. # y(t+1)=g(x,y) x(t+1)=if(t==0)then(x)else(y) # ################################################ # # Here's where you define the function f(x) for # the 1-D map x --> f(x) and the initial conditions # for the 2-D map. Note that y must initially be # zero for this to work. # # Some good values of the parameter a are: # # a=0.5 0 stable fixed point # a=1.0 TC bifurcation of fixed points # a=2.0 different stable fixed point # a=3.00 PD bifurcations # a=3.04 stable period 2 orbit # a=3.45 period 2 orbit destabilizes # a=4.00 periodic orbits of all periods # f(x)=a*x*(1-x) par a=0.5 init y=0,x=.25 # ################################################ # # Here define some variables which we will use # to plot the lines y=x and y=f(x) on the same # graph for the cobweb # par xlo=0,xhi=1,nit=25 xx=xlo+(xhi-xlo)*t/nit aux map=f(xx) aux st=xx # # These are to show you what the mod(t,n) function does # aux m2=mod(t,2) aux m3=mod(t,3) aux m4=mod(t,4) # ################################################ # # Now we set some default menu parameters # # some convenient settings for the graphics @ xlo=0,ylo=0,xhi=1.001,yhi=1.001 @ xp=x,yp=y @ nplot=3 # add the plots y=x and y=f(x) @ xp2=st,yp2=st @ xp3=st,yp3=map # # When using xppaut for maps you need to tell it # that time is discrete and (optionally) the number # of iterates. # @ meth=discrete,total=25 # # # All xppaut code must end with "done" or "d" to # tell its compiler where the end of the code is. # done