# Animated COBWEB diagram of the Logistic Map # written by: Joseph D. Skufca, US Naval Academy # Email: skufca@nadn.navy.mil # This program generates an animation to graphically show how a small # interval, under repeated application of the logistic map (4x(1-x)) # grows to cover the entire interval from 0 to 1, providing a graphical # understanding of sensitive dependence on initial conditions under a # chaotic map. # The logistic map - f(x)=a*x*(1-x) was originally developed as a basic # model of growth of a species when there is a limit to growth (as # opposed to exponential growth, like bacteria). f(x) predicts the # population at the next time increment if the present population is x. # This simple model has a parameter "a." If the parameter value is # chosen to be a=4, this map shows the classic behavior of a chaotic # system. This map is studied in nearly all initial courses in chaos # theory. The mathematics are very easy and can almost always be # solved in closed form. # As a chaotic map (unrelated to its use as a model), this map is well # studied. One of the interesting aspects is that the orbit (sequence # of values) generated by the map is sensitive dependent on the initial # value. Although each value is calculated deterministically from the # previous one, two orbits that start very close will eventually become # very far apart. # My animation shows what happens to initial values in the range from # 0.4 to 0.41. Over just eleven iterations of the map, the output # could be anywhere between 0 and 1. A classic approach to study of # maps is to use a cobweb diagram, where the next value is determined # graphically. My animation, although calculated in closed form, uses # a cobweb diagram to illustrate how the interval (0.4, 0.41) # eventually maps to the interval (0,1). Cobwebbing is an approach # that is well described in other texts and would be familiar to anyone # who has had a basic course in studying maps. # Keywords: logistic, animation, sensitive dependence, population # growth, cobwebbing # The initial interval can be changed, as well as controlling the # number of iterations animated. The basic function for this animation # uses the logistic function 4x(1-x). Other maps can be animated using # this program by changing the appropriate line that defines f(x). If # f(x) is altered, the program may fail due to the inability of the # "maximize" and "minimize" algorithms to find an answer. > restart: > with(plots): > with(plottools): > n:=11: # This specifies the number of iterations > b:=array(1..2*n+1): > a:=array(1..2*n+1): > c:=array(1..n+1): > x[1]:=.4:# This is the lower bound of the initial interval > xd[1]:=.41:# This is the upper bound of the initial interval > f:=x->4*x*(1-x):# This defines the map to use for iteration > xintl:=0:xintu:=1:# This defines the domain of the map > f1:=plot([f(x),x],x=xintl..xintu): > c[1]:=plot(f(x),x=x[1]..xd[1],filled=true,color=gray): > fplot:=display(f1,c[1]): > i:=0:for i from 1 by 1 to n do > g:=minimize(f(x),x=x[i]..xd[i],location):xlow:=g[1]:xlowco:=rhs(op(1,o > p(1,op(1,g[2])))):g:=maximize(f(x),x=x[i]..xd[i],location): > xhigh:=g[1]:xhighco:=rhs(op(1,op(1,op(1,g[2])))):x[i+1]:=xlow:xd[i+1]: > =xhigh:c[i+1]:=plot(f(x),x=x[i+1]..xd[i+1],filled=true,color=gray): > a[2*i-1]:=line([xlowco,xlow], > [xlow,xlow],color=blue):a[2*i]:=line([xhighco,xhigh], > [xhigh,xhigh],color=blue) od: > b[1]:=fplot: > i:=0:for i from 2 by 2 to 2*n do > b[i]:=display(f1,c[i/2],a[i],a[i-1]):b[i+1]:=display(f1,a[i],a[i-1],c[ > 1+i/2]) od: > anim:=seq(b[i],i=1..2*n+1): > display(anim,insequence=true);