{VERSION 4 0 "SUN SPARC SOLARIS" "4.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 Comment" 2 18 "" 0 1 0 0 0 0 0 0 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 "Heading 1" 0 3 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }1 0 0 0 8 4 0 0 0 0 0 0 -1 0 }{PSTYLE "" 3 256 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 3 257 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {PARA 256 "" 0 "" {TEXT -1 28 "Section 8.1 - Euler's Method" } }{PARA 257 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 78 "Here i s a procedure for using the Euler method. It takes as input a functio n " }{XPPEDIT 18 0 "f(t,y);" "6#-%\"fG6$%\"tG%\"yG" }{TEXT -1 0 "" } {TEXT -1 19 ", an initial value " }{XPPEDIT 18 0 "y[0];" "6#&%\"yG6#\" \"!" }{TEXT -1 0 "" }{TEXT -1 5 " for " }{XPPEDIT 18 0 "y;" "6#%\"yG" }{TEXT -1 0 "" }{TEXT -1 18 ", an initial time " }{XPPEDIT 18 0 "t[0]; " "6#&%\"tG6#\"\"!" }{TEXT -1 1 " " }{TEXT -1 4 "(so " }{XPPEDIT 18 0 "y(t[0]) = y[0];" "6#/-%\"yG6#&%\"tG6#\"\"!&F%6#F*" }{TEXT -1 0 "" } {TEXT -1 15 "), a step size " }{XPPEDIT 18 0 "h;" "6#%\"hG" }{TEXT -1 0 "" }{TEXT -1 20 ", a number of steps " }{XPPEDIT 18 0 "n;" "6#%\"nG " }{TEXT -1 0 "" }{TEXT -1 15 ", and a number " }{XPPEDIT 18 0 "m;" "6 #%\"mG" }{TEXT -1 0 "" }{TEXT -1 35 " so that results are printed ever y " }{TEXT -1 0 "" }{TEXT -1 93 " steps. This procedure is a bit diff erent from the one in Differential Equations with Maple." }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 " eule r_method := proc(f,y0,t0,h,n,m)" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 215 " t := evalf(t0); y := evalf(y0);\n for i from 1 to n\n do \n y := y +h*f(t,y); t := t+h; \+ if type(i/m,integer)='true' then print(t,y) fi;\n \+ od;\nend;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}{PARA 0 "> " 0 " " {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 49 "Let's try it on the function in Problem 2, p. 103" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "f := (t,y) -> 2*y-1; " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "euler_method(f,1,0,.1,4,1);\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 " euler_method(f,1,0,.05,8,2);\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "euler_method(f,1,0,.025,16,4);\n" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 131 "Here is the exac t solution. I gave the solution a new name so Maple wouldn't confuse i t with the result of the previous calculation" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 45 "dsolve(\{dif f(z(t),t)=2*z(t)-1,z(0)=1\},z(t));\n" }}}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "" 0 "" {TEXT -1 26 " I'll rename the solution " } {XPPEDIT 18 0 "z;" "6#%\"zG" }{TEXT -1 1 " " }{TEXT -1 12 "(instead of " }{XPPEDIT 18 0 "z(t);" "6#-%\"zG6#%\"tG" }{TEXT -1 0 "" }{TEXT -1 39 ")--this reduces problems evaluating it." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "z := rhs(%);" }}} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 111 " Here is the exact solution evaluated at several points. Notice that we have t o substitute the desired value of" }{XPPEDIT 18 0 "t;" "6#%\"tG" } {TEXT -1 1 " " }{TEXT -1 5 "into " }{XPPEDIT 18 0 "z;" "6#%\"zG" } {TEXT -1 0 "" }{TEXT -1 60 " before evaluating. Also, we have to use \+ evalf to evaluate " }{XPPEDIT 18 0 "z(t);" "6#-%\"zG6#%\"tG" }{TEXT -1 1 " " }{TEXT -1 28 "as a floating point number.\n" }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "evalf(subs (t=.1,z));\n " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "evalf(subs (t=.2,z)); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "evalf(subs(t =.3,z));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "evalf(subs(t=.4 ,z));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{MARK "2 26" 93 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }