Fixed Point Iteration A example of a proc to generate a sequence of iterates > restart;iterates:= proc(g,p0,nmax) > seq((g@@i)(p0), i=0..nmax) > end; iterates := proc(g, p0, nmax) seq((g@@i)(p0), i = 0 .. nmax) end proc > iterates(x->x^2,a,5); 2 4 8 16 32 a, a , a , a , a , a > h := x -> x*(1-x); > > h := x -> x (1 - x) A proc to generate a cobweb graph of an iteration we need a sequence like [ 0,1], [1,1], [1,2],[ 2,2], [2,3], [3,3], [3,4],.....] hence we use trunc. > cob:= proc(g,t1,lastn) > pp:= [[t1,0],[t1,g(t1)],seq([(g@@trunc((i+1)/2))(t1),(g@@trunc((i+2)/2))(t1)],i=1..lastn)]; > ; plot1:= plot(pp,x=0..1,style=LINE): > plot2:= plot({x,g(x)},x=0..1): > plots[display]({plot1,plot2}); > end; Warning, `pp` is implicitly declared local to procedure `cob` Warning, `plot1` is implicitly declared local to procedure `cob` Warning, `plot2` is implicitly declared local to procedure `cob` cob := proc(g, t1, lastn) local pp, plot1, plot2; pp := [[t1, 0], [t1, g(t1)], seq([ (g@@(trunc(1/2*i + 1/2)))(t1), (g@@(trunc(1/2*i + 1)))(t1)], i = 1 .. lastn)]; plot1 := plot(pp, x = 0 .. 1, style = LINE); plot2 := plot({x, g(x)}, x = 0 .. 1); plots[display]({plot1, plot2}) end proc > cob(h,.7,20); > h1 := D(h); h1 := x -> 1 - 2 x Newton's method using the iterates proc > f := x -> x - h(x)/h1(x); h(x) f := x -> x - ----- h1(x) > iterates(f,.7,10); .7, 1.225000000, 1.034913793, 1.001139411, 1.000001295, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000 > plot(h(x),x=0..2); > hh:= x ->x+3/5*(x*(1-x)); hh := x -> x + 3/5 x (1 - x) > cob(hh,0.1,20);
You may open the Maple application and load the file www.math.uic.edu/~bergerl/M471/fixedpt.mws as a worksheet into your Maple application.
OR you may run the program fixpt.txt over telnet from home. Do this by opening a telnet session to your account, copying the file fixpt.txt to your home directory, and then using the command
maple
You will have to quit the maple session with the command quit; since that statement does not appear in the file fixpt.txt.
You may use the pico editor to examine and change fixpt.txt.