maple_day2.mws

455 DAY 2 MAPLE EXERCISE

> restart:
seq(r^t,t=0..10);

1, r, r^2, r^3, r^4, r^5, r^6, r^7, r^8, r^9, r^10

> r:=1.1;
seq(r^t,t=0..10);

r := 1.1

1., 1.1, 1.21, 1.331, 1.4641, 1.61051, 1.771561, 1.9487171, 2.14358881, 2.357947691, 2.593742460

> r:=1.1;
seq([t,r^t],t=0..10);

r := 1.1

[0, 1.], [1, 1.1], [2, 1.21], [3, 1.331], [4, 1.4641], [5, 1.61051], [6, 1.771561], [7, 1.9487171], [8, 2.14358881], [9, 2.357947691], [10, 2.593742460]

> r:=1.1;
pts:=[seq([t,r^t],t=0..30)];

plot(pts,style=point,labels=[time,N]);

r := 1.1

pts := [[0, 1.], [1, 1.1], [2, 1.21], [3, 1.331], [4, 1.4641], [5, 1.61051], [6, 1.771561], [7, 1.9487171], [8, 2.14358881], [9, 2.357947691], [10, 2.593742460], [11, 2.853116706], [12, 3.138428377], ...pts := [[0, 1.], [1, 1.1], [2, 1.21], [3, 1.331], [4, 1.4641], [5, 1.61051], [6, 1.771561], [7, 1.9487171], [8, 2.14358881], [9, 2.357947691], [10, 2.593742460], [11, 2.853116706], [12, 3.138428377], ...pts := [[0, 1.], [1, 1.1], [2, 1.21], [3, 1.331], [4, 1.4641], [5, 1.61051], [6, 1.771561], [7, 1.9487171], [8, 2.14358881], [9, 2.357947691], [10, 2.593742460], [11, 2.853116706], [12, 3.138428377], ...pts := [[0, 1.], [1, 1.1], [2, 1.21], [3, 1.331], [4, 1.4641], [5, 1.61051], [6, 1.771561], [7, 1.9487171], [8, 2.14358881], [9, 2.357947691], [10, 2.593742460], [11, 2.853116706], [12, 3.138428377], ...

[Plot]

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]

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]

>