{VERSION 5 0 "SUN SPARC SOLARIS" "5.0" }
{USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 1 10 255 0 0 1 2 1 0
0 1 0 0 0 0 1 }{CSTYLE "" -1 256 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }
{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Helvetica" 1 10 0 0 0 0 1 2
2 0 0 0 0 0 0 1 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Text Output
" -1 2 1 {CSTYLE "" -1 -1 "Courier" 1 10 0 0 255 1 0 0 0 0 0 1 3 0 3
0 }1 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Warning" 2 7 1 {CSTYLE "
" -1 -1 "" 0 1 0 0 255 1 0 0 0 0 0 0 1 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0
0 0 -1 0 }{PSTYLE "R3 Font 0" -1 256 1 {CSTYLE "" -1 -1 "Helvetica" 1
12 0 0 0 0 2 1 2 0 0 0 0 0 0 1 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }
{PSTYLE "R3 Font 2" -1 257 1 {CSTYLE "" -1 -1 "Helvetica" 1 10 0 0 0
0 2 2 2 0 0 0 0 0 0 1 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Fo
nt 3" -1 258 1 {CSTYLE "" -1 -1 "Courier" 1 12 0 0 0 0 2 2 2 0 0 0 0
0 0 1 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 4" -1 259 1
{CSTYLE "" -1 -1 "Courier" 1 12 0 0 0 0 2 2 2 0 0 0 0 0 0 1 }0 0 0 -1
-1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 5" -1 260 1 {CSTYLE "" -1 -1
"Helvetica" 1 12 0 0 0 0 2 1 2 0 0 0 0 0 0 1 }0 0 0 -1 -1 -1 0 0 0 0
0 0 -1 0 }{PSTYLE "R3 Font 6" -1 261 1 {CSTYLE "" -1 -1 "Helvetica" 1
12 0 0 0 0 2 1 2 0 0 0 0 0 0 1 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }
{PSTYLE "R3 Font 7" -1 262 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 0 2
2 2 0 0 0 0 0 0 1 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 8
" -1 263 1 {CSTYLE "" -1 -1 "Helvetica" 1 12 0 0 0 0 2 1 2 0 0 0 0 0
0 1 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 9" -1 264 1
{CSTYLE "" -1 -1 "Times" 1 12 0 0 0 0 2 2 2 0 0 0 0 0 0 1 }0 0 0 -1
-1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 10" -1 265 1 {CSTYLE "" -1
-1 "Helvetica" 1 12 0 0 0 0 2 1 2 0 0 0 0 0 0 1 }0 0 0 -1 -1 -1 0 0 0
0 0 0 -1 0 }{PSTYLE "R3 Font 11" -1 266 1 {CSTYLE "" -1 -1 "Helvetica
" 1 12 0 0 0 0 2 1 2 0 0 0 0 0 0 1 }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 256 10 "growth.mws" }{TEXT -1 85 " A \"Basic\" implemen
tation of Euler's method, and then the real Maple way to do it. " }}
{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 254 "We look \+
at two simple models of population growth for a bunch of (pseudo-)rabb
its. To distinguish them, we use R and S to denote the respective rab
bit populations. Both begin with size 10, and both have intrinsic (pe
r capita) rate of increase r = 0.1. " }}}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 8 "restart:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 74
"tinitial:= 0; tfinal:= 60 ; # set up initial and final times (in mo
nths)" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 51 "t:= tinitial; # st
art the clock at the initial time" }}}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 43 "R:= 10 ; S:= 10 ; # set the initial values" }}}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "r:= 0.1; K:= 100; # parame
ter values" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 66 "numberofsteps
:= 120 ; deltat:= (tfinal-tinitial) / numberofsteps;" }}}{EXCHG
{PARA 0 "> " 0 "" {MPLTEXT 1 0 88 "Rpoints:= [tinitial, R ]; Spoints:
= [tinitial, S ];# set the initial point on the graph" }}}{EXCHG
{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 474 "The rate
equation for S is called a logistic equation. We use Euler's method \+
of stepwise approximation, taking the current value of S to compute th
e current rate S' = rS(K-S)/K, and from this the change in S, which we
call DeltaS, and an updated value of S (which leads to an updated val
ue of S' and the cycle continues). You can use a different rate equat
ion, of course, for instance taking constant per capita growth (as we \+
have done for R), or other more exotic models." }}{PARA 0 "> " 0 ""
{MPLTEXT 1 0 73 "for k from 1 by 1 to numberofsteps do # set up the c
ounter for the cycle" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 65 " Rprime:= \+
r * R : # exponential growth -- get the current rate" }}{PARA 0 "> \+
" 0 "" {MPLTEXT 1 0 78 " Sprime:= r * S * ( K - S ) / K : # logisti
c growth -- get the current rate" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 87
" deltaR:= Rprime*deltat: R:= R + deltaR: # calculate change in R and
update value of R" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 58 " deltaS:= Sp
rime*deltat: S:= S + deltaS: # same for S" }}{PARA 0 "> " 0 ""
{MPLTEXT 1 0 44 " t:= t + deltat: # advance t by one step" }}
{PARA 0 "" 0 "" {TEXT -1 228 "\nThe following command adds the point o
n the graph that has just been calculated to the roster of points that
are there already. If you're not interested in the graph, you can \"
comment out\" this command by placing a # in front." }}{PARA 0 "> " 0
"" {MPLTEXT 1 0 66 "Rpoints:= Rpoints , [ t , R ] : Spoints:= Spoints
, [ t , S ] : " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 87 "od: #commands b
etween do and od are executed repeatedly until the counter ends the lo
op" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 49 "\nLet's print out the final
values of t, R, and S." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "t:= t; \+
R:= R; S:= S; " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 433 "\nMake a not
e of the result of this SIMULATION; that is, note all the parameter va
lues used (final time, number of steps, rate equation coefficients) an
d the final population values. We are now going to change these values
one at a time, and observe the results of the modified SIMULATIONS. \+
What you are doing in effect is experimentation on the computer, and y
ou need to keep track of what you are doing just as you would in a lab
. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 109 "We
can also plot R and S as functions of t. Again, comment this out if
you aren't interested in the graph. " }}{PARA 0 "> " 0 "" {MPLTEXT 1
0 81 "plot([ Rpoints ], style = LINE, title = `Rabbit population: expo
nential growth`);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 79 "plot([ Spoints ], style = LI
NE, title = `Rabbit population: logistic growth` );" }}}{EXCHG {PARA
0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 909 "
\nNow select the menu item Edit, and Remove Output. Then go back to \+
the beginning, change the number of steps, and then run through the wh
ole thing again until you are satisfied that you have a sufficiently a
ccurate final values of R and S. Next try changing the final time (mo
dify the number of steps to keep the stepsize the same as before). Wh
at do you observe? Select a final time and stepsize that you are happ
y with (say t = 72 and numberofsteps = 288) and predict what effect ch
anging the inital values of R and S will have. Test your prediction. R
eset the inital values back to 10 and predict what effect changing r w
ill have. Test your prediction. Reset r to 0.1 and predict what effect
changing K will have. Test your prediction. Remember every time you m
ake a change you need to reset all the other changes you have made (so
that comparisons can be made) and execute the worksheet from the top!
" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 1131 "\nOnce you understand Euler
's method, and what this program is all about, you may want to graduat
e to using Maple's buit-in commands for solving differential equations
. There are a great many of them (change the : to a ; in the with(DEt
ools) command and you will see the list, or investigate the Help brows
er), but for now let's just see how we can plot of S as a function of \+
t. All the information has to be specified, in the correct order: the
rate equation (or equations), the variables (showing how the dependen
t variable(s) depend on the independent variable), the domain over whi
ch the independent variable (in this case t for time) runs, the initia
l condition (or conditions), the stepsize, and the way we want the sol
ution plotted (the scene). Arrows are optional and come in a variety \+
of styles; they indicate a sampling of the locally linear pieces of th
e graph that satisfies the rate equation at selected points. I usuall
y find it handy to give some of these pieces of information names and \+
lines of their own: this makes things a lot easier to modify later on \+
without messing too much with the DEplot line itself. \n" }}{PARA 0 ">
" 0 "" {MPLTEXT 1 0 42 "restart; gc(): with(DEtools): with(plots):" }
}{PARA 7 "" 1 "" {TEXT -1 50 "Warning, the name changecoords has been \+
redefined\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "rate_eqR:= [
diff( R(t) , t ) = 0.1 * R(t) ];" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0
39 "vars:= [R(t)] ; # what depends on what?" }}{PARA 0 "> " 0 ""
{MPLTEXT 1 0 80 "domain:= 0 .. 60 ; # initial t to final t values (of
ten called the time domain)" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 88 "init
1:= [R(0)=10]; init2:= [R(0)=150]; init3:= [R(0)=30]; # initial values
of S at t = 0" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 87 "DEplot(ra
te_eqR, vars, domain, [init1], stepsize = 0.1, scene = [t, R], arrows \+
= NONE);" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "
" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 141 "Now try the same thing usin
g each of the other initial conditions. You can also see all the solut
ions superimposed on one graph, as follows." }}}{EXCHG {PARA 0 "> " 0
"" {MPLTEXT 1 0 128 "DEplot(rate_eqR, vars, domain, [init1, init2, ini
t3], stepsize=0.1, scene=[t,R], arrows=NONE, linecolor = [BLUE, GREEN,
BLACK]);" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "
" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 70 "rate_eqS:= [ diff( S(t)
, t ) = 0.1 * S(t) * ( (100 - S(t)) / 100 ) ];" }}{PARA 0 "> " 0 ""
{MPLTEXT 1 0 39 "vars:= [S(t)] ; # what depends on what?" }}{PARA 0 ">
" 0 "" {MPLTEXT 1 0 80 "domain:= 0 .. 60 ; # initial t to final t va
lues (often called the time domain)" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0
88 "init1:= [S(0)=10]; init2:= [S(0)=150]; init3:= [S(0)=30]; # initia
l values of S at t = 0" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 87 "D
Eplot(rate_eqS, vars, domain, [init1], stepsize = 0.1, scene = [t, S],
arrows = NONE);" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT
1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 165 "One can give a DEplot
a name (BE SURE TO END IT WITH A COLON IN THIS CASE!) to save it up t
o plot later. Usually this is done to get several plots showing toget
her." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 89 "fall:= DEplot(rate_
eqS, vars, domain,[init2], stepsize=0.1, scene=[t, S], arrows = NONE):
" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 90 "rise:= DEplot(rate_eqS, vars, d
omain, [init3], stepsize=0.1, scene=[t, S], arrows = NONE):" }}}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "display( [fall , rise ]);" }
{TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG
{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 96 "Another w
ay to accomplis,h the same end is to put all the initial conditions in
one statement. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 128 "DEplo
t(rate_eqS, vars, domain, [init1, init2, init3], stepsize=0.1, scene=[
t,S], arrows=NONE, linecolor = [BLUE, GREEN, BLACK]);" }{TEXT -1 0 ""
}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "
" {TEXT -1 330 "Now try all the various experiments that you did earli
er, changing the time domain, step size, initial conditions, paramete
r values, and KEEP TRACK OF YOUR OBSERVATIONS! This is what we mean b
y \"playing\" with a model. What features are stable, which are highly
variable (the model is \"sensitive\" to what, \"insensitive\" to what
)?" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{MARK "0 0 0" 0
}{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }