"File: BISECT.MTH" "AUXILIARY FUNCTIONS" EVAL_(y,a):=ITERATE(y,x,a,1) E_(z,i):=ELEMENT(z,i) MID_(z):=z . [1/2,1/2] NEW_(y,z):=IF(EVAL_(y,E_(z,1))*EVAL_(y,MID_(z))<=0,[E_(z,1),MID_(z)],[MID_(z),~ E_(z,2)]) SEG_(y,a,b):=[(1-t)*[a,0]+t*[a,EVAL_(y,a)],(1-t)*[b,0]+t*[b,EVAL_(y,b)],[(1-t)~ *a+t*b,0],[(b-a)*t+a,EVAL_(y,(b-a)*t+a)]] SEG_V(y,z):=SEG_(y,E_(z,1),E_(z,2)) "###########################################" "USER FUNCTIONS" BISECT(y,a,b,n):=ITERATES(NEW_(y,z),z,[a,b],n) PICTURE(y,a,b,n):=[y,VECTOR(SEG_V(y,E_(BISECT(y,a,b,n),i)),i,n)] "###################################################" "INSTRUCTIONS" "BISECT(Y,A,B,N) executes n iterations of the bisection method" " for y=f(x) beginning on the interval [a,b]." "" "PICTURE(Y,A,B,N) produces a picture of n iterations" " of the bisection method for y=f(x) beginning on the interval [a,b]." " The plot is parametric." " THE PARAMETER DOMAIN MUST BE SET TO MIN:0 MAX:1" " Use to accept parameter domain." "############################################" "EXAMPLE 1" "approX the following expression to see the result ot 10" " iterations of the bisection method applied to cos(x)" " on the interval [0,4]" BISECT(COS(x),0,4,10) "" "EXAMPLE 2" "approX and Plot (following the instructions above) the following" " to see a picture of the bisection method for EXAMPLE 1" PICTURE(COS(x),0,4,10) "############################################:"