{VERSION 3 0 "IBM INTEL NT" "3.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 }{CSTYLE "" -1 256 "" 0 1 0 0 0 0 0 1 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 "" 0 256 1 {CSTYLE "" -1 -1 "" 0 1 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 }} {SECT 0 {EXCHG {PARA 256 "" 0 "" {TEXT 256 20 "The Mid-Point Method" } }{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "with(plots ):" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 32 "Define the initial value problem" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "f:=(t,x)->-2*t*x(t)^2; x0:=1;\015" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "IVP:=\{diff(x (t),t)=f(t,x),x(0)=x0\};\015" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "FCN:=\{x(t)\};\015" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 25 "Obtain the exact solution" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "Exact: =rhs(dsolve(IVP,FCN));\015" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 75 "Use the classical 4th order Runge-Kutta m ethod to obtain the starting value" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 70 "sv:=h->dsolve(IVP,FCN,type= numeric,method=classical[rk4],stepsize=h);\015" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 29 "SV:=(t,h)->rhs(sv(h)(t)[2]);\015" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 43 "Define a \+ procedure for the mid-point method" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 143 "midpt:=proc(n,h) option re member;\nif n=1 then SV(h,h) elif n=2 then x0+2*h*f(h,SV(h,h)) \nelse \+ midpt(n-2,h)+2*h*f((n-1)*h,midpt(n-1,h))fi;\nend;\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 49 "Define a proced ure to plot the mid-point solution" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 128 "plotmidpt:=proc(N,h)\nloca l l,i;\n l:=[];\n for i from 1 to N do\n l:=[op(l),i*h,midpt(i,h)];\n \+ od;\n pointplot(l,connect=true);\n end;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 38 "Plot the exact and numeri cal solutions" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "p1:=plotmidpt(50,0.1):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "p2:=plot(Exact,t=0..5):\015" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 19 "display(\{p1,p2\}); \015" }}}}{MARK "20" 0 } {VIEWOPTS 1 1 0 1 1 1803 }