#M9.txt: Maple Code for "Dynamical models in Biology" (Math 336) taught by Dr. Z., Lecture 9 Help9:=proc(): print(` Orb(f,x,x0,K1,K2), Orb2D(f,x,x0,K) , FP(f,x) , SFP(f,x) , Comp(f,x) `):end: #Orb(f,x,x0,K1,K2): Inputs an expression f in x (desccribing) a function of x, an initial point, x0, and a positive integer K, outputs #the values of x[n] from n=K1 to n=K2. Try: where x[n]=f(x[n-1]), . Try: #Orb(2*x*(1-x),x,0.4,1000,2000); Orb:=proc(f,x,x0,K1,K2) local x1,i,L: x1:=x0: for i from 1 to K1 do x1:=subs(x=x1,f): #we don't record the first values of K1, since we are interested in the long-time behavior of the orbit od: L:=[x1]: for i from K1 to K2 do x1:=subs(x=x1,f): #we compute the next member of the orbit L:=[op(L),x1]: #we append it to the list od: L: #that's the output end: #Orb2D(f,x,x0,K): 2D version of Orb(f,x,x0,0,K), just for illustration Orb2D:=proc(f,x,x0,K) local L,L1,i: L:=Orb(f,x,x0,0,K): L1:=[[L[1],0],[L[1],L[2]], [L[2],L[2]] ] : for i from 3 to nops(L) do L1:=[op(L1),[L[i-1],L[i]],[L[i],L[i]]]: od: L1: end: #FP(f,x): The list of fixed points of the map x->f where f is an expression in x. Try: #FP(2*x*(1-x),x); FP:=proc(f,x) evalf([solve(f=x)]): end: #SFP(f,x): The list of stable fixed points of the map x->f where f is an expression in x. Try: #SFP(2*x*(1-x),x); SFP:=proc(f,x) local L,i,f1,pt,Ls: L:=FP(f,x): #The list of fixed points (including complex ones) Ls:=[]: #Ls is the list of stable fixed points, that starts out as the empty list f1:=diff(f,x): #The derivative of the function f w.r.t. x for i from 1 to nops(L) do pt:=L[i]: if abs(subs(x=pt,f1))<1 then Ls:=[op(Ls),pt]: # if pt, is stable we add it to the list of stable points fi: od: Ls: #The last line is the output end: #Comp(f,x): f(f(x)) Comp:=proc(f,x): normal(subs(x=f,f)):end: