{VERSION 2 3 "DEC ALPHA UNIX" "2.3" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 }{CSTYLE "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 } {PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Heading 1" 0 3 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 0 0 0 0 0 0 0 }1 0 0 0 6 6 0 0 0 0 0 0 -1 0 }{PSTYLE "Heading 2" 3 4 1 {CSTYLE "" -1 -1 "" 1 14 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 4 4 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 }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 }3 0 0 -1 8 8 0 0 0 0 0 0 -1 0 }} {SECT 0 {PARA 18 "" 0 "" {TEXT -1 20 "Numerical Techniques" }{TEXT -1 0 "" }}{PARA 19 "" 0 "" {TEXT -1 15 "Vadim Yakovlev " }}{PARA 19 "" 0 "" {TEXT -1 8 "MA 1023 " }}{PARA 19 "" 0 "" {TEXT -1 14 "February, 199 9" }}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 15 "Newton's method" }}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 31 "Source code for Newton's method" }} {EXCHG {PARA 0 "" 0 "" {TEXT -1 194 "This is the source code from the \+ lab for Newton's method. You will need to put the cursor somewhere (it doesn't matter where) in the body of the program and press \"Return\" before you can use it." }{TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 722 "Newton := proc (f, a, b, iter)\n local first, second, x, i, \+ d1;\n if not type (f, procedure) then\n ERROR (`the first argument must be a function name.`) fi;\n if nargs <> 4 then ERROR (`You need four argument,`) fi;\n if evalf (f(a)*f(b)) >= 0 then \n print (` f(a) nd f(b) do not have opposite signs.`);\n print (`a solution is NOT guaranteed.`);\n fi;\n\n first := evalf((a+b)/2, 15);\n print \+ (`Initial estimate`, evalf(first));\n d1 := diff(f(x), x);\n second \+ := first - evalf(f(first)/subs(x=first, d1), 15);\n for i from 2 to i ter\n do\n first := second;\n print (i-1, evalf(first)); \n second := first - evalf(f(first)/subs(x=first, d1), 15);\n \+ od;\n print (`Final estimate`, evalf(second));\nend;" }}}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 26 "Example of Newton's method" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "fun := x->x^3-3*x +1;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 65 "This plot command shows that there is a r oot between x=1 and x=2." }{TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "plot(fun(x),x=1..2);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 72 "T his command uses four steps of Newton's method to approximate the root ." }{TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "Newton(fun, 1, \+ 2, 4);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 14 "Simpson's rule" }}{SECT 1 {PARA 4 "" 0 " " {TEXT -1 30 "Source code for Simpson's rule" }}{EXCHG {PARA 0 "" 0 " " {TEXT -1 33 "This is the source code from the " }{TEXT -1 119 "lab f or Simpson's rule. You will need to put the cursor somewhere in the bo dy and press \"Return\" before you can use it." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 551 "Simpson := proc(f, a, b, n)\n local i, j, h, s, v; \n if not type (f, procedure) then\n ERROR (`the first argument mu st be a function name.`) fi;\n if nargs <> 4 then ERROR (`You need fo ur arguments.`) fi;\n if (n mod 2<>0) then ERROR (`# of subdivisions \+ must be even.`) fi;\n h := (b-a)/n;\n for i from 1 to (n-1) \n do \n v[i] := a + i*h;\n od;\n s := f(a) + f(b);\n for i from 1 by 2 to (n-1)\n do\n s := s + 4*f(v[i]);\n od;\n for j fr om 2 by 2 to (n-2)\n do \n s := s + 2*f(v[j]);\n od;\n s : = (h/3)*s;\n evalf(s,15);\nend;" }}}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 25 "Example of Simpson's rule" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "f := x-> exp(-x^2);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 91 "Th is command computes the Simpson's rule approximation with 4 subinterva ls of the integral " }{XPPEDIT 18 0 "int(exp(-x^2),x=0..2)" "-%$intG6$ -%$expG6#,$*$%\"xG\"\"#!\"\"/F*;\"\"!\"\"#" }{TEXT -1 2 ". " }{TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "Simpson (f, 0, 2, 4);" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" } }}}{MARK "3 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 }