"File Newton" "AUXILIARY FUNCTIONS" EVAL_(y,a):=ITERATE(y,x,a,1) E_(z,i):=ELEMENT(z,i) V_LINE(y,p):=[p,t*EVAL_(y,p)] N_LINE(y,p,q):=[(1-t)*p+t*q,(1-t)*EVAL_(y,p)] T_LINE(y,p,q):=[V_LINE(y,p),N_LINE(y,p,q)] A_LINE(y,z,k):=VECTOR(T_LINE(y,E_(z,i),E_(z,i+1)),i,1,k) NEW(n,x,w):=[n+1,EVAL_(w,x)] N_(y,a,n):=ITERATES(x-y/DIF(y,x),x,a,n) NS_(y,a,n):=ITERATE(x-y/DIF(y,x),x,a,n) "########################################################" "USER FUNCTIONS" NEWTON(y,a,n):=ITERATES(NEW(E_(z,1),E_(z,2),x-y/DIF(y,x)),z,[0,a],n) PICTURE(y,a,n):=[y,A_LINE(y,N_(y,a,n),n-1)] START(y,n,a,b,s):=VECTOR([k,NS_(y,k,n)],k,a,b,s) "######################################" "INSTRUCTIONS" "NEWTON(Y,A,N) produces n iterations of Newton's method" ".....applied to y=f(x) starting at x=a." "PICTURE(Y,A,N) produces a picture of n iterations of " ".....Newton's method applied to y=f(x) starting at x=a." ".....THE PLOT IS PARAMETRIC. " "PARAMETER DOMAIN MUST BE SET TO MIN:0 MAX:1" ".....Use to accept parameter domain." "START(Y,N,A,B,S) returns the ordered pairs [k,z] where z" ".....is the result of applying N iterations of Newoton's method" ".....to Y starting at k. k ranges from A to B in steps of S." "###################" "Example 1" "approX the following to see 10 steps of Newton's method" "... starting at a=1.1 applied to y=cos x + sin x" NEWTON(SIN(x)+COS(x),1.1,10) "Example 2" "approX the following and the Plot (see graphics settings above)" "... to see a picture of Example 1" PICTURE(SIN(x)+COS(x),1.1,10)