{VERSION 2 3 "SUN SPARC SOLARIS" "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 "Hyperlink" -1 17 "" 0 1 0 128 128 1 0 0 1 0 0 0 0 0 0 }{CSTYLE "" -1 256 "" 1 12 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE " " -1 257 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 258 "" 1 12 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 259 "" 1 12 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 260 "" 1 12 0 0 0 0 0 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 261 "" 1 12 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 262 "" 1 12 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 }{CSTYLE "" -1 264 "" 1 12 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 265 "" 1 12 0 0 0 0 0 0 0 0 0 0 0 0 0 }{PSTYLE "N ormal" -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 "Heading 3 " 4 5 1 {CSTYLE "" -1 -1 "" 1 12 0 0 0 0 1 0 0 0 0 0 0 0 0 }0 0 0 -1 0 0 0 0 0 0 0 0 -1 0 }{PSTYLE "Bullet Item" 0 15 1 {CSTYLE "" -1 -1 " " 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 3 3 0 0 0 0 0 0 15 2 } {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 }} {SECT 0 {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 " " 0 "" {TEXT 257 12 "template.mws" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 469 "This worksheet is designed to give you a template for many of the things you will be doing with a differential equation. Delete unecces sary lines, and don't forget to execute the worksheet from the top onc e you have entered all the desired changes. You may find it useful to keep a completed Maple worksheet open in another window as a guide ( \"tile\" the windows so you can see both at once). In fact you can ev en copy and paste from one window to another if you wish." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 1 {PARA 256 "" 0 "" {TEXT -1 15 "Getting started" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 140 "E very Maple worksheet should begin by re-initializing the Maple \"kerne l\" and loading the additional 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 1 {PARA 4 "" 0 "" {TEXT 256 16 "Defining a model" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 178 "All differential equa tion models begin with a differential equation. If the problem is an i ntial value problem, an initial condition is also needed. Replace the \+ question marks ( " }{TEXT 0 1 "?" }{TEXT -1 67 " ) in the following in put regions to define the relevant ODE model." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 71 "MODEL := diff( ? , ? ) = ? ; # define the diff erential equation model" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 61 " IC := ? = ? ; # specify an initial condition" }}}} {SECT 1 {PARA 4 "" 0 "" {TEXT 258 38 "Direction Fields and Solution Cu rves (" }{HYPERLNK 17 "DEplot" 2 "DEplot" "" }{TEXT -1 1 ")" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 29 "Replace the question marks ( " }{TEXT 0 1 "?" }{TEXT -1 80 " ) in the following input regions to create the d irection field for your model." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 67 "VAR := \{ ? \}; # specify the variables in th e model" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 91 "DOMAIN := ? = ? \+ .. ? ; # specify a reasonable interval for the independent var iable" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 89 "RANGE := ? = ? .. \+ ? ; # specify a reasonable interval for the dependent variabl e" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 66 "plotSLOPE := DEplot( M ODEL, 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 88 "Next plot one or more solu tion curves corresponding to the specified initial conditions." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 74 "DEplot( MODEL, VAR, DOMAIN, \+ [ [IC] ], linecolor = BLUE, arrows = MEDIUM );" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 105 "DEplot( MODEL, VAR, DOMAIN, [ [IC1], [IC2], [ IC3] ], linecolor = [BLUE, GREEN, BLACK], arrows = MEDIUM );" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 24 "Look at the help under " }{HYPERLNK 17 "plot,options" 2 "plot, options" "" }{TEXT -1 50 " to see other ways you can customize your plots. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}} {SECT 1 {PARA 4 "" 0 "" {TEXT 259 20 "Analytic Solutions (" } {HYPERLNK 17 "dsolve" 2 "dsolve" "" }{TEXT -1 1 ")" }}{EXCHG {PARA 0 " " 0 "" {TEXT -1 385 "Occasionally it is possible to get an analytic (f ormula) solution. There's no harm in asking, but you may end up stari ng at nothing for a long time, or Maple may come back with no answer, \+ or an answer that is completely unintelligible. Here too, when we le arn specific methods, we will be able to ask Maple to use precisely th ose methods. The command is complete by replacing the " }{TEXT 0 1 " ?" }{TEXT -1 95 " by dependent variable ( independent variable), as \+ in the sugar example, something like S(t)." }}}{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 37 "SOLN := dsolve( \{ MODEL, IC \}, VA R );" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 4 "" 0 "" {TEXT 260 21 "Numerical Solutions (" }{HYPERLNK 17 "dsolve,n umeric" 2 "dsolve,numeric" "" }{TEXT -1 1 ")" }}{EXCHG {PARA 0 "" 0 " " {TEXT -1 244 " We can also use this command to use a specified compu tational procedure. Most of these that are numerical (there are plent y of \"symbolic\" methods as well) require you to tell Maple how large the change in the independent variable should be (\"" }{TEXT 0 8 "ste psize" }{TEXT -1 103 "\"). So far the only method we know is Euler's, known to Maple as the \"forward\" Euler method from its \"" } {HYPERLNK 17 "classical" 2 "dsolve,classical" "" }{TEXT -1 186 "\" col lection. The main thing to investigate here is how the accuracy of t he solution (and the time of computation) is affected by the stepsize . Let's recall what we are working with." }}}{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 "" }}}{SECT 1 {PARA 4 "" 0 "" {TEXT 261 13 "Method # \+ 1 - " }{TEXT 0 5 "Euler" }{TEXT 263 42 " (a custom-defined procedure f or our uses)" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 79 "DO NOT CHANGE ANYT HING 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, t t, 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), vars );" }}{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 " LISTpts := LISTpts, [ tt, yy ];" }}{PARA 0 " > " 0 "" {MPLTEXT 1 0 28 " od; RETURN( [ LISTpts ] );" }}{PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 4 "end:" }}{PARA 0 "" 0 "" {TEXT -1 79 "DO NOT CHA NGE ANYTHING IN THE PRECEDING INPUT REGION - YOU HAVE BEEN WARNED !!! " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 38 "Let's recall what we are working with." }}}{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 "" {TEXT -1 51 "The number of steps to be used in Euler's method is" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "Nsteps := ?;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 42 "The points generated 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 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 50 "These data points can be plotted using the command" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 52 "plotE := plot( ptsE, colo r = 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 101 "Another way to view the approximate solution is to \+ overlay the computed solution on the slope field.." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "display( [ plotSLOPE, plotE ] );" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 4 "" 0 " " {TEXT 262 12 "Method #2 - " }{TEXT 0 14 "dsolve,numeric" }{TEXT 264 7 " and " }{TEXT 0 7 "odeplot" }{TEXT 265 26 " (built-in Maple comma nds)" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 119 "There are two steps in us ing Maple to work with numerically computed solutions to an initial va lue problem. First, the " }{HYPERLNK 17 "dsolve" 2 "dsolve" "" }{TEXT -1 26 " command is used with the " }{HYPERLNK 17 "numeric" 2 "dsolve,n umeric" "" }{TEXT -1 6 " (and " }{HYPERLNK 17 "method" 2 "dsolve,class ical" "" }{TEXT -1 32 ") option to obtain the solution." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 143 "Note that this command requires specification of the stepsize \+ (not the number of steps). Fortunately, this conversion is not difficu lt to make." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "dt := ?" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 91 "solnE:= dsolve( \{ MODEL, IC \}, VAR, numeric, method = classical[foreuler], stepsize = dt );" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 113 "The second step is to decide how \+ to use this solution. A common choice is to create a plot of the solut ion using " }{HYPERLNK 17 "odeplot" 2 "plots,odeplot" "" }{TEXT -1 11 " (from the " }{HYPERLNK 17 "plots" 2 "plots" "" }{TEXT -1 126 " packa ge). The last ingredient needed for this command is the number of poin ts to use in the plot of the approximate solution." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "NUMpts := ?" }}}{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 "" }}}}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 6 "Notes:" }} {EXCHG {PARA 15 "" 0 "" {TEXT -1 129 "The odeplot is not likely to sho w what you need to answer the problems for this course unless you make the appropriate chose for " }{TEXT 0 6 "NUMpts" }{TEXT -1 1 "." }} {PARA 15 "" 0 "" {TEXT -1 19 "The solution using " }{TEXT 0 14 "dsolve ,numeric" }{TEXT -1 5 " and " }{TEXT 0 7 "odeplot" }{TEXT -1 149 " doe s not provide an explicit list of points computed by Euler's method. I f a problem requires this information, this approach is not the one to use!" }}}}{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 }