455 DAY 2 MAPLE EXERCISE
| > | restart:
seq(r^t,t=0..10); |
| > | r:=1.1;
seq(r^t,t=0..10); |
| > | r:=1.1;
seq([t,r^t],t=0..10); |
| > | r:=1.1;
pts:=[seq([t,r^t],t=0..30)]; plot(pts,style=point,labels=[time,N]); |
![]()
![]()
![]()
![[Plot]](images/maple_day2_11.gif)
Define a procedure that creates a cobweb diagram for the map f(r,x), where
r is a parameter,
x0 is the starting value,
rang is the plotting range, and
n is the number of iterates to be done:
| > | restart:
cobweb:=proc(f,r,x0,rang,n) x:=x0; count:=0; pt[count]:=[x,0]; count:=count+1; for i from 1 to n do xnew:=f(r,x); pt[count]:=[x,xnew]; count:=count+1; pt[count]:=[xnew,xnew]; count:=count+1; x:=xnew; end do; unassign('i'): p1:=plot([seq(pt[i],i=0..count-1)],color=magenta): p2:=plot(z,z=rang,color=orange): p3:=plot(f(r,z),z=rang,color=blue,thickness=2): my_title:=convert(r,string); return plots[display](p1,p3,p2,view=[rang,rang],title=my_title); end proc: |
Warning, `x` is implicitly declared local to procedure `cobweb`
Warning, `count` is implicitly declared local to procedure `cobweb`
Warning, `pt` is implicitly declared local to procedure `cobweb`
Warning, `i` is implicitly declared local to procedure `cobweb`
Warning, `xnew` is implicitly declared local to procedure `cobweb`
Warning, `p1` is implicitly declared local to procedure `cobweb`
Warning, `p2` is implicitly declared local to procedure `cobweb`
Warning, `p3` is implicitly declared local to procedure `cobweb`
Warning, `my_title` is implicitly declared local to procedure `cobweb`
Use the cobweb procedure for the logistic map and r=3.2:
| > | f:=(r,x)->r*x*(1-x);
cobweb(f,3.2,0.1,0..1,20); |
![[Plot]](images/maple_day2_13.gif)
Make an animation for the logistic map in which r increases from 1 to 4:
| > | r_values:=[seq(1.0+i/40,i=1..120)]:
plots[display](seq(cobweb(f,r_values[i],0.1,0..1,40),i=1..120),insequence=true); |
![[Plot]](images/maple_day2_14.gif)
| > |