{VERSION 5 0 "IBM INTEL NT" "5.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 1 }{CSTYLE "2D Output" 2 20 "" 0 1 0 0 255 1 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 256 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 257 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 258 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 259 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 260 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 261 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 262 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 263 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 264 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 265 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 266 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 267 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 268 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 269 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 270 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 271 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 272 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Text Output" -1 2 1 {CSTYLE "" -1 -1 "Courier " 1 10 0 0 255 1 0 0 0 0 0 1 3 0 0 1 }1 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 2 6 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 2 0 0 1 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Warning" 2 7 1 {CSTYLE "" -1 -1 "" 0 1 0 0 255 1 0 0 0 0 0 0 1 0 0 1 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Maple Output" 0 11 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }3 3 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 11 12 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }1 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Maple Plot" 0 13 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 } {PSTYLE "Title" 0 18 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 1 0 0 0 0 0 0 1 }3 0 0 -1 12 12 0 0 0 0 0 0 19 0 }{PSTYLE "Author" 0 19 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }3 0 0 -1 8 8 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 18 "" 0 "" {TEXT -1 39 "A Procedure for Newton's \+ Method in R^n " }}}{EXCHG {PARA 19 "" 0 "" {TEXT 259 11 "Version 0.8" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 261 15 "This worksheet:" }}{PARA 0 "" 0 "" {TEXT 266 171 " 1. contains a proceudre to do n iterati ons of Newtons method for solving f=0 where \n \+ f:R^n->R^n is given as a liast of expressions" }}{PARA 0 "" 0 " " {TEXT 267 67 " 2. optionally show the function values at ea ch iteration." }}{PARA 0 "" 0 "" {TEXT 268 96 " 3. optionally show an estimate |f| |D2f| |Df^(-1)|^2 used in checking the convergen ce " }}{PARA 0 "" 0 "" {TEXT 270 97 " of Newton's method \+ near this point, where the norms are sums of squares of entries." }} {PARA 0 "" 0 "" {TEXT 271 96 " If the quantity (replacing the second derivative term by a second derivative norm " }}{PARA 0 " " 0 "" {TEXT 272 91 " bound in a suitable ball) is smalle r than 1/2 then convergence is guaranteed." }}{PARA 0 "" 0 "" {TEXT 269 120 " 4. will be available at the URL http://www.mathlab. cornell.edu/local_maple/newton_conv_est.mws when completed." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 13 "with(linalg):" }}{PARA 7 "" 1 "" {TEXT -1 80 "Warning, the protected names norm and trace have been redefined an d unprotected\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "with(plo ts):" }}{PARA 7 "" 1 "" {TEXT -1 50 "Warning, the name changecoords ha s been redefined\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 258 90 "Change thi s value if you'd like a different floating point accuracy. More digits are fine." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "Digits:=10;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%'DigitsG\"#5" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 262 145 "This error tolerance is used to decide if a matrix is t oo close to 0 (as measured by its det) to be considered invertible. Re duce it if you like." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "tol := 10.0 ^(-8);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%$tolG$\"+++++5!#<" }}} {EXCHG {PARA 0 "" 0 "" {TEXT 256 86 "Change this to false and re-execu te the line if you don't want to see function values." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "show_f_val := true;\n" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%+show_f_valG%%trueG" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 257 165 "Change this between true and false and re-execute the line d epending on whether you want to see the test for f convergence for th e Newton's method near this point." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "show_conv_estimate := true;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%3 show_conv_estimateG%%trueG" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 263 63 "Ty pical Usage: newton([x^2-y^2-16, 2*x*y-30], [x,y], [4,4],10);" }} {PARA 0 "" 0 "" {TEXT 264 54 " to do 10 iterations of Newton's meth od for solving" }}{PARA 0 "" 0 "" {TEXT -1 9 " " }{TEXT 265 185 "x^2-y^2-16 = 0\n 2*x*y-30 = 0\n using the variables [ x,y] and starting with the point [4,4].\n The sequence of iterations a re maintained as p[0], p[1], ... in a global table p." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 2512 "newton := proc(f,vars,p0,n)\n global p,d,to l, show_f_val, show_radius_estimate;\n local i, j, m, u, f_val, Df, Df_val, Df_detval, Df_invval,var_subs_set, err_found,q,q_pre, rad_est , H2f, H2f_val, D2f_norm;\n p:= 'p';\n p[0] := eval(p0): \n q := map(evalf,p0);\n m:= nops(vars);\n Df := jacobian(f,vars);\n \+ var_subs_set := \{seq(vars[j]=q[j],j=1..m)\};\n f_val := map(eva lf,map2(subs,var_subs_set,f)); \n Df_val := map(evalf,map2(subs,var _subs_set,Df));\n Df_detval := det(Df_val);\n err_found := evalb (abs(Df_detval) < tol);\n printf(`Iteration starts with %a.\\n`,con vert(q,list));\n if (show_f_val) then \n printf(`\\t\\t The function value here is %a.\\n`, f_val);\n fi:\n if (show_con v_estimate) then\n H2f:=[seq(hessian(f[i],vars),i=1..m)]; \n H2f_val:= map2(subs,var_subs_set,H2f):\n Df _invval := inverse(Df_val);\n D2f_norm := sqrt(add(trace(e valm(H2f_val[i] &* transpose(H2f_val[i]))),i=1..m)):\n rad _est:= D2f_norm* sqrt(trace(evalm(f_val&*transpose(f_val) )))*(trace(evalm(Df_invval&*transpose(Df_invval))))^2;\n p rintf(`\\t\\tThe convergence estimate here is %a.\\n`, evalf(rad_est)) ;\n fi:\n printf(`\\n`);\n q_pre := eval(q); \n for i from 1 to n while (not err_found) do\n q := map(evalf,evalm(q_pre - Df_val^(-1) &* f_val)); \n u := evalm(q - q_pre); \n \+ d := sqrt(1.0*dotprod(u,u));\n printf(`Iteration %d give s %a, a distance %g from the previous.\\n`,i,convert(q,list),d);\n \+ var_subs_set := \{seq(vars[j]=q[j],j=1..m)\};\n f_val : = map(evalf,map2(subs,var_subs_set,f));\n if (show_f_val) the n \n printf(`\\t\\tThe function value here is %a.\\n`, f_v al);\n fi:\n Df_val := map(evalf,map2(subs,var_subs_ set,Df));\n Df_detval := det(Df_val);\n if (show_con v_estimate) then\n H2f_val:= map2(subs,var_subs_set,H2f) :\n Df_invval := inverse(Df_val);\n D2f_no rm := add(trace(evalm(H2f_val[j] &* transpose(H2f_val[j]))),j=1..m):\n rad_est:= D2f_norm* sqrt( trace(evalm(f_val&*transpose(f_val))))*(trace(evalm(Df_invval&*transpo se(Df_invval))))^2;\n printf(`\\t\\tThe convergence esti mate here is %a.\\n`, rad_est);\n fi:\n err_found := evalb(abs(Df_detval) < tol);\n q_pre := eval(q);\n \+ p[i] := convert(eval(q_pre),list);\n printf(`\\n`);\n od: \n eval(q);\nend:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 260 45 "Enter yo ur function as a list of expressions." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "f := [x^2-y^2-16,2*x*y-30];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#> %\"fG7$,(*$)%\"xG\"\"#\"\"\"F+*$)%\"yGF*F+!\"\"\"#;F/,&*&F)F+F.F+F*\"# IF/" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "newton(f,[x,y],[4,4] ,10);" }}{PARA 6 "" 1 "" {TEXT -1 31 "Iteration starts with [4., 4.]. " }}{PARA 6 "" 1 "" {TEXT -1 40 "\011\011The function value here is [- 16., 2.]." }}{PARA 6 "" 1 "" {TEXT -1 50 "\011\011The convergence esti mate here is .1574659717e-1." }}{PARA 6 "" 1 "" {TEXT -1 0 "" }}{PARA 6 "" 1 "" {TEXT -1 84 "Iteration 1 gives [4.875000000, 2.875000000], a distance 1.425219 from the previous." }}{PARA 6 "" 1 "" {TEXT -1 55 " \011\011The function value here is [-.50000000, -1.96875000]." }} {PARA 6 "" 1 "" {TEXT -1 50 "\011\011The convergence estimate here is \+ .7919095779e-2." }}{PARA 6 "" 1 "" {TEXT -1 0 "" }}{PARA 6 "" 1 "" {TEXT -1 83 "Iteration 2 gives [5.001402439, 3.002378049], a distance \+ .179451 from the previous." }}{PARA 6 "" 1 "" {TEXT -1 55 "\011\011The function value here is [-.24759e-3, .3220180e-1]." }}{PARA 6 "" 1 "" {TEXT -1 50 "\011\011The convergence estimate here is .1112429410e-3. " }}{PARA 6 "" 1 "" {TEXT -1 0 "" }}{PARA 6 "" 1 "" {TEXT -1 83 "Itera tion 3 gives [5.000000023, 3.000000653], a distance .002760 from the p revious." }}{PARA 6 "" 1 "" {TEXT -1 49 "\011\011The function value he re is [-.369e-5, .666e-5]." }}{PARA 6 "" 1 "" {TEXT -1 50 "\011\011The convergence estimate here is .2634571979e-7." }}{PARA 6 "" 1 "" {TEXT -1 0 "" }}{PARA 6 "" 1 "" {TEXT -1 88 "Iteration 4 gives [5.0000 00000, 3.000000001], a distance 6.524055e-07 from the previous." }} {PARA 6 "" 1 "" {TEXT -1 42 "\011\011The function value here is [-.1e- 7, 0.]." }}{PARA 6 "" 1 "" {TEXT -1 51 "\011\011The convergence estima te here is .3460207611e-10." }}{PARA 6 "" 1 "" {TEXT -1 0 "" }}{PARA 6 "" 1 "" {TEXT -1 88 "Iteration 5 gives [5.000000001, 3.000000001], a distance 1.000000e-09 from the previous." }}{PARA 6 "" 1 "" {TEXT -1 41 "\011\011The function value here is [0., .2e-7]." }}{PARA 6 "" 1 " " {TEXT -1 51 "\011\011The convergence estimate here is .6920415222e-1 0." }}{PARA 6 "" 1 "" {TEXT -1 0 "" }}{PARA 6 "" 1 "" {TEXT -1 88 "Ite ration 6 gives [5.000000000, 3.000000000], a distance 1.414214e-09 fro m the previous." }}{PARA 6 "" 1 "" {TEXT -1 38 "\011\011The function v alue here is [0., 0.]." }}{PARA 6 "" 1 "" {TEXT -1 38 "\011\011The con vergence estimate here is 0.." }}{PARA 6 "" 1 "" {TEXT -1 0 "" }} {PARA 6 "" 1 "" {TEXT -1 84 "Iteration 7 gives [5.000000000, 3.0000000 00], a distance 0 from the previous." }}{PARA 6 "" 1 "" {TEXT -1 38 "\011\011The function value here is [0., 0.]." }}{PARA 6 "" 1 " " {TEXT -1 38 "\011\011The convergence estimate here is 0.." }}{PARA 6 "" 1 "" {TEXT -1 0 "" }}{PARA 6 "" 1 "" {TEXT -1 84 "Iteration 8 giv es [5.000000000, 3.000000000], a distance 0 from the previous. " }}{PARA 6 "" 1 "" {TEXT -1 38 "\011\011The function value here is [0 ., 0.]." }}{PARA 6 "" 1 "" {TEXT -1 38 "\011\011The convergence estima te here is 0.." }}{PARA 6 "" 1 "" {TEXT -1 0 "" }}{PARA 6 "" 1 "" {TEXT -1 84 "Iteration 9 gives [5.000000000, 3.000000000], a distance \+ 0 from the previous." }}{PARA 6 "" 1 "" {TEXT -1 38 "\011\011Th e function value here is [0., 0.]." }}{PARA 6 "" 1 "" {TEXT -1 38 " \011\011The convergence estimate here is 0.." }}{PARA 6 "" 1 "" {TEXT -1 0 "" }}{PARA 6 "" 1 "" {TEXT -1 85 "Iteration 10 gives [5.000000000 , 3.000000000], a distance 0 from the previous." }}{PARA 6 "" 1 "" {TEXT -1 38 "\011\011The function value here is [0., 0.]." }} {PARA 6 "" 1 "" {TEXT -1 38 "\011\011The convergence estimate here is \+ 0.." }}{PARA 6 "" 1 "" {TEXT -1 0 "" }}{PARA 11 "" 1 "" {XPPMATH 20 "6 #-%'vectorG6#7$$\"+++++]!\"*$\"+++++IF)" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "p[3];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7$$\"+B+++]! \"*$\"+`1++IF&" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "pts := [s eq(p[i],i=0..10)];" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#>%$ptsG7-7$\"\"% F'7$$\"++++v[!\"*$\"++++vGF+7$$\"+RCS,]F+$\"+\\!yB+$F+7$$\"+B+++]F+$\" +`1++IF+7$$\"+++++]F+$\"+,+++IF+7$$\"+,+++]F+F;7$F9$\"+++++IF+F@F@F@F@ " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 44 "plot(pts,`sequence of p oints in the plane`);" }}{PARA 13 "" 1 "" {GLPLOT2D 400 300 300 {PLOTDATA 2 "6%-%'CURVESG6$7-7$$\"\"%\"\"!F(7$$\"3+++++++v[!#<$\"3++++ +++vGF.7$$\"3f******QCS,]F.$\"3$)******[!yB+$F.7$$\"38+++B+++]F.$\"3&) *****Hl+++$F.7$$\"\"&F*$\"33+++,+++IF.7$$\"33+++,+++]F.F>7$F<$\"\"$F*F CFCFCFC-%'COLOURG6&%$RGBG$\"#5!\"\"$F*F*FM-%+AXESLABELSG6$Q@sequence~o f~points~in~the~plane6\"Q!FR-%%VIEWG6$%(DEFAULTGFW" 1 2 0 1 10 0 2 9 1 4 2 1.000000 45.000000 45.000000 0 0 "Curve 1" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 " " }}}}{MARK "2 7 0" 61 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 } {PAGENUMBERS 0 1 2 33 1 1 }