{VERSION 4 0 "IBM INTEL NT" "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 } {CSTYLE "LaTeX" -1 32 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 256 "" 0 1 0 0 0 0 0 1 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 0 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "T imes" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 } {PSTYLE "Heading 1" -1 3 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 8 4 1 0 1 0 2 2 0 1 }{PSTYLE "Heading 2" -1 4 1 {CSTYLE "" -1 -1 "Times" 1 14 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 8 2 1 0 1 0 2 2 0 1 }{PSTYLE "Heading 3" -1 5 1 {CSTYLE "" -1 -1 "Ti mes" 1 12 0 0 0 1 1 1 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 } {PSTYLE "Heading 1" -1 256 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 8 4 1 0 1 0 2 2 0 1 }{PSTYLE "" 0 257 1 {CSTYLE "" -1 -1 "" 0 1 0 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 }{PSTYLE "" 0 258 1 {CSTYLE "" -1 -1 "" 0 1 0 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 3 "" 0 "" {TEXT -1 54 "Systems of First-order Dif ferential Equations: Example" }}}{EXCHG {PARA 4 "" 0 "" {TEXT -1 17 "B y Eugene Belogay" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 4 "" 0 "" {TEXT -1 18 "Initializing Maple" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 71 "It is a good idea to re-initialize t he Maple \"kernel\" at the beginning:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 47 "Now we load the Differential Equations \+ package:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "with( DEtools ):" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 4 "" 0 "" {TEXT -1 21 "Dr awing a Slope Field" }{TEXT 32 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 111 "\nAs an example, we consider the predator-prey non-linear firs t-order autonomous differential equation system:\n" }}{PARA 257 "" 0 "" {XPPEDIT 18 0 "diff(R(t),t) = 2*R-1.2*RF;" "6#/-%%diffG6$-%\"RG6#% \"tGF*,&*&\"\"#\"\"\"F(F.F.*&$\"#7!\"\"F.%#RFGF.F2" }{TEXT -1 2 " " } }{PARA 258 "" 0 "" {XPPEDIT 18 0 "diff(F(t),t) = -F+.9*RF;" "6#/-%%dif fG6$-%\"FG6#%\"tGF*,&F(!\"\"*&$\"\"*F,\"\"\"%#RFGF0F0" }{TEXT -1 2 " \+ " }}{PARA 0 "" 0 "" {TEXT -1 275 "\nwhere R(t) denotes the population \+ of rabbits (say, in thousands of rabbits, i.e., \"kilorabbits\"), and \+ F(t) denotes the population of foxes (say, in hundreds of foxes, i.e., \"hectofoxes\"). We assign each equation to a variable, so that we d on't have to write it every time: " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 43 "deR := diff(R(t),t) = 2*R(t)-1.2*R(t)*F(t);" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 42 "deF := diff(F(t),t) = -F(t)+0.9*R(t)*F(t) ;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 118 "The following command displays (be patient!) the direction field \+ of the system in the appropriate ranges. (Note that " }{TEXT 257 4 "a ll " }{TEXT -1 78 "ranges are required, including the t-range, even if the system is autonomous!)" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 63 "dfie ldplot( [deR,deF], [R(t),F(t)], t=0..2, R=-1..4, F=-1..4 );" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 174 "A s usual, one can change the appearance of the arrows. The following c ommand displays the same direction field, but changes the color to mag enta and the thickness to medium:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 93 "dfieldplot( [deR,deF], [R(t),F(t)], t=0..2, R=-1..4, \+ F=-1..4, arrows=medium, color=magenta );" }}}{EXCHG {PARA 4 "" 0 "" {TEXT -1 21 "\n...with less writing" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 240 "To save writing (and reduce th e probability of typos), it is more convenient to save (in addition to the differential equations themselves) the system as whole, the list \+ of unknown functions, the t-range, and several inititial conditions. \+ " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 59 "\nThe predator-prey system is the list of the two equations:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "sys := [deR, deF];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 109 "We also save the list of unknown functions and the various ranges, so we don't have to write them every time:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "vars := [R(t), F(t)];" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "trng := t=0..5;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "Rrng := \+ R=-1..4;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "Frng := F=-1..4;" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 47 "Finally, we can save the \"pretty \+ plot\" options:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "opts := \+ arrows=medium, color=magenta;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 97 " \nThe following line produces the same output as above, but is much ea sier to read and understand:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 46 "dfieldplot(sys, vars, trng, Rrng, Frng, opts);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 4 "" 0 "" {TEXT -1 17 "Plotting Soluti on" }{TEXT 32 17 "s: Phase Portrait" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 304 "The following command plots th e phase portrait (RF plot) of the solution that satisfies the initial \+ condition R(0)=1 and F(0)=1, on top of the direction field. Note that , unlike the direction field plot, Maple doesn't need ranges for R and F here -- if omitted, they can be determined from the solution." }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 52 "phaseportrait( sys, vars, trng, [[R (0)=2,F(0)=1]] );" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 474 "\nYou proba bly noticed that the gold oval above is very \"rough\" and has some co rners. Recall that Maple uses numerical methods to approximate the so lution. Each method requires a stepsize for t -- if it is omitted (as it was above), Maple uses a default stepsize, based on the t-range. T he reason for the roughness above was that the default stepsize was to o large. We can get a smoother picture (that takes more computing tim e) by forcing Maple to use a smaller stepsize:" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 66 "phaseportrait( sys, vars, trng, [[R(0)=2,F(0)= 1]], stepsize=0.1 );" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 77 "Now that \+ this smaller stepsize seem to work, we add it to the \"nice\" options: " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "opts := opts, stepsize= 0.1;" }}}{EXCHG {PARA 4 "" 0 "" {TEXT -1 24 "\nPlotting many solutions " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 325 "As you know, Maple can plot more than one solution on the same pl ot. The following commands plot three solutions corresponding to thre e initial conditions. Note that, for two-dimensional systems, each in itial condition (initial population vector) consists of two scalar equ ations (one for each species), placed in brackets:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "init1 := [R(0)=1, F(0)=1];" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "init2 := [R(0)=2, F(0)=1];" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "init3 := [R(0)=3, F(0)=1];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "ics := [ init1, init2, init3 ];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 44 "phaseportrait( sys, vars, trng, ics, opts );" }}}{EXCHG {PARA 5 "" 0 "" {TEXT -1 20 "\nMaking It Pretty..." }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 305 "One can change a lot of the featu res of the plot that Maple produces. The following command produces t he same plot as above, but adds an appropriate title, plots the field \+ in gray (instead of the default red), and draws the solution curves in red, magenta, and maroon (instead of the default gold color):" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 169 "opts := arrows=medium, color=gray, stepsize=0.05;\nphaseportrait( sys, vars, trng, ics, opts, title=\"Pr edator-Prey (Fox-Rabbit) System\", linecolor=[red,magenta,maroon] );" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 68 "To plot only the solution curve s (without the direction field), use " }{TEXT 0 11 "arrows=NONE" } {TEXT -1 1 ":" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 73 "phaseportrait( sys , vars, trng, ics, opts, arrows=NONE, linecolor=blue );" }{TEXT -1 0 " " }}}{EXCHG {PARA 4 "" 0 "" {TEXT -1 31 "\nPlotting Solutions Versus T ime" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 58 "\nIn this section, we will need to combine plots using the " }{TEXT 0 7 "display" }{TEXT -1 25 " command, so we load the " }{TEXT 0 5 "plots" }{TEXT -1 9 " package:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "with( plots ):" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 258 "The phase portraits above plot th e solution curves in the phase plane (the fox-rabbit plane), as foxes \+ versus rabbits. The phase portrait tells us how both populations evol ve, but doesn't provide any time information -- we don't know how fast things happen." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 63 "\nWe can creat e plots of each population versus time, using the " }{TEXT 0 5 "scene " }{MPLTEXT 1 0 0 "" }{TEXT -1 138 " option. We use brown for the fox es and green for the rabbits. When we plot each function, we don't ne ed the direction field, so we use " }{TEXT 0 11 "arrows=NONE" }{TEXT -1 73 ". We save the plots for later use, so don't forget the colon a t the end:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 94 "Fplot := DEpl ot(sys, vars, t=0..15, [init3], scene=[t,F], opts, arrows=NONE, lineco lor=brown):" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 94 "Rplot := DEplot(sys, vars, t=0..15, [init3], scene=[t,R], opts, arrows=NONE, linecolor=gre en):" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 54 "\nNow we can superimpose \+ both plots on the same figure:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 86 "display( \{Fplot,Rplot\}, title=\"Time evolution of rabbits (g reen) and foxes (brown)\" );" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 72 "For further information on DE plotting, execute the following help line:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "?DEplot;" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 " " }}}{EXCHG {PARA 0 "" 0 "" {TEXT 256 0 "" }}{PARA 0 "" 0 "" {TEXT -1 73 "Now do it yourself by changing stuff around and enjoy the power of Maple!" }}}{PARA 256 "" 0 "" {TEXT -1 0 "" }}}{MARK "2 2 0" 0 } {VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }