{VERSION 2 3 "IBM INTEL NT" "2.3" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 1 10 255 0 0 1 2 1 0 0 1 0 0 0 0 }{CSTYLE "" -1 257 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 } {CSTYLE "" -1 259 "" 0 1 0 0 0 0 2 1 1 0 0 0 0 0 0 }{CSTYLE "" -1 260 "" 0 1 0 0 0 0 2 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 261 "" 1 10 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 262 "" 1 10 0 0 0 0 0 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 263 "" 1 12 0 0 0 0 0 0 0 0 0 0 0 0 0 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Helvetica" 1 10 0 0 0 0 1 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 "" 3 256 1 {CSTYLE "" -1 -1 "" 1 12 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 257 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 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 " " 0 "" {TEXT 257 13 "prob1-4-2.mws" }}}{EXCHG {PARA 257 "" 0 "" {TEXT 259 45 "Solution to Problem # 2 in Section 1.4 of BDH" }{TEXT 260 36 " \n(worksheet based upon template.mws)" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 1 {PARA 256 "" 0 "" {TEXT -1 15 "Getting st arted" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 140 "Every Maple worksheet sh ould begin by re-initializing the Maple \"kernel\" and loading the add itional packages that we are most likely to use." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "with( plots ):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "with( DEtools ):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 " " }}}}{SECT 0 {PARA 4 "" 0 "" {TEXT 263 8 "Solution" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 46 "The problem involves the following information" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 85 "MODEL := diff( y(t) , t ) \+ = t - y(t)^2 ; # define the differential equation model" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 63 "IC := y(0) = 1; \+ # specify the initial condition" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 1 {PARA 4 "" 0 "" {TEXT 261 20 "Preliminary Analysis" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 59 "We begin the analysis of this problem with the slope field." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 68 "VAR := \{ y(t) \}; # specify the varia bles in the model" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 92 "DOMAIN := t = 0 .. 1; # specify a reasonable interval for the inde pendent variable" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 90 "RANGE : = y = -0.1 .. 1 ; # specify a reasonable interval for the depen dent variable" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 66 "plotSLOPE := DEplot( MODEL, \+ VAR, DOMAIN, RANGE, arrows = MEDIUM ):" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "plotSLOPE;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 96 "When the solution curve through th e specified initial condition is added, the picture looks like" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 81 "DEplot( MODEL, VAR, DOMAIN, \+ RANGE, [ [IC] ], linecolor = BLUE, arrows = MEDIUM );" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 135 "Notice how the solution curve is always \+ tangentiala to the slope field. (This is a good way to check that your \"answer\" is reasonable.)" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 102 "Even though it is not ask ed for in this problem, let's see what Maple can do for an analytic so lution." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "SOLN := dsolve( \+ \{ MODEL, IC \}, VAR );" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 78 "UGH! N o wonder we haven't spent more time worrying about explicit solutions! !!" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 4 "" 0 "" {TEXT 262 39 "Numerical Solution using Euler's Method" }} {EXCHG {PARA 0 "" 0 "" {TEXT -1 76 " Now we get to the numerical solut ion. To begin, copy the definition of the " }{TEXT 0 5 "Euler" }{TEXT -1 27 " command from template.mws." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 79 "DO NOT CHANGE ANYTHING IN THE FOLLOWING INPUT REGION - YOU HAVE BEEN WARNED !!!" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "Euler := proc( \+ MODEL, IC, DOMAIN, N )" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 50 " local a , b, dt, dy, f, i, tt, yy, LISTpts, vars;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 54 " vars := (op(2,lhs(MODEL) ), op([1,0],lhs(MODEL) ) ) ;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 35 " f := unapply( rhs(MODEL), va rs );" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 49 " a := op(1,rhs(DOMAIN)); \+ b := op(2,rhs(DOMAIN));" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 16 " dt := \+ (b-a)/N;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 10 " tt := a;" }}{PARA 0 " > " 0 "" {MPLTEXT 1 0 16 " yy := rhs(IC);" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 24 " LISTpts := [ tt, yy ];" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 22 " for i from 1 to N do" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 33 " dy := evalf( f(tt,yy) ) * dt;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 18 " yy := yy + dy;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 18 " tt := tt + dt;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 35 " LISTp ts := LISTpts, [ tt, yy ];" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 28 " od; RETURN( [ LISTpts ] );" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "end:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 90 "Let's continue our preparations by checking that all nece ssary assignments have been made." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "MODEL;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 3 "IC ;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "VAR;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "DOMAIN;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 188 "The last ing redient is the number of steps to be used in approximating the solutio n on the above domain. In this case, dt = 0.25 so that 4 steps are \+ needed to span the interval 0 .. 1." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "Nsteps := 4;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 67 "The points, and correspo nding plot, computed by Euler's method are:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 43 "ptsE := Euler( MODEL, IC, DOMAIN, Nsteps );" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 52 "plotE := plot( ptsE, color = GREEN, thickness = 2 ):" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "plotE;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 96 "Note that this plot uses a different vertical scale tha n the earlier plots. We could modify the " }{TEXT 0 4 "plot" }{TEXT -1 140 " command, but a better idea is to overlay the approximate solu tion on the slope field and see how well the solution follows the slop e field." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "display( [ plot SLOPE, plotE ] );" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 167 "Observe tha t the approximate solution starts out following the slope field but st arts to cross the slope field towards the end of each segment of the p lotted solution." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "dt := (1-0)/Nsteps;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 90 "solnE:= dsolve( \{ MODEL, IC \}, VAR, numeric, meth od = classical[foreuler], stepsize = dt);" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "NUMpt s := 4;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 89 "odeplot( solnE, \+ [t, y(t)], rhs(DOMAIN), style = line, color = BLUE, numpoints = NUMpts );" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}}{MARK "0 0 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 }