<?xml version="1.0" encoding="UTF-8"?>
<Worksheet><Version major="6" minor="1"/><View-Properties><Zoom percentage="100"/></View-Properties><Styles><Layout alignment="left" bullet="none" linespacing="0.0" name="Heading 1" spaceabove="8.0" spacebelow="4.0"/><Layout alignment="left" bullet="none" firstindent="0.0" leftmargin="0.0" linebreak="space" linespacing="0.0" name="Normal" rightmargin="0.0" spaceabove="0.0" spacebelow="0.0"/><Font background="[0,0,0]" bold="true" executable="true" family="Monospaced" foreground="[255,0,0]" name="Maple Input" opaque="false" size="12"/><Font background="[0,0,0]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="Text" opaque="false" size="12" underline="false"/><Font background="[0,0,0]" bold="true" family="Serif" name="Heading 1" opaque="false" size="18"/></Styles><Group><Input><Text-field alignment="centred" firstindent="0.0" layout="Heading 1" leftmargin="0.0" linebreak="space" rightmargin="0.0" style="Heading 1"><Font executable="false" foreground="[0,0,0]" italic="false" underline="false">Introduction to Iteration Maps</Font></Text-field><Text-field firstindent="0.0" layout="Heading 1" leftmargin="0.0" linebreak="space" rightmargin="0.0" style="Heading 1"><Font style="Text">This worksheet is intended to provide an introduction to Maple as well as to allow you to explore the behavior of iteration maps.</Font></Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input">restart;</Text-field><Text-field layout="Normal" style="Text">This command (restart) resets the Maple program so that it forgets any other commands. If you don't execute this command, then you sometimes find surprises in calculations coming from previous results that you don't realize Maple is using.</Text-field></Input></Group><Group><Input><Text-field layout="Normal" style="Text"/><Text-field layout="Normal" style="Text">The following list of functions are three simple examples of iteration functions for population dynamics. The pound sign (#) at the beginning of a line is a way of hiding the command from Maple. Everything following a '#' is ignored (technically, it's callled a comment). Remove the '#' to select a function to use for iteration.</Text-field><Text-field layout="Normal" style="Text"/><Text-field layout="Normal" style="Text">Second, note that the sequence '<Font italic="false" style="Maple Input" underline="false">:=</Font>' is used to define f. The arrow '<Font italic="false" style="Maple Input" underline="false">-&gt;</Font>' describes a function. The name on the left is the input value and the expression on the right is the output value. For example, the first equation would be written on paper as 'f(x) = ax'. Also, note that every operation must be explicitly written (multiplication, in particular).</Text-field><Text-field layout="Normal" style="Text"/></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input"># f := x-&gt;a*x;		# geometric
# f := x-&gt;K + a*(x-K);	# shifted geometric
# f := x-&gt;lambda*x*(M-x);	# logistic</Text-field></Input></Group><Group><Input><Text-field layout="Normal" style="Text"/><Text-field layout="Normal" style="Text">Each of the possible functions have parameters that need to be set before exploring this numerically. You should be sure to select parameters that match the equation you used above.</Text-field><Text-field layout="Normal" style="Text"/></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input"># a := 1.25;		# geometric
# a := 0.75; K := 200;	# shifted geometric
# lambda := 0.0125; M := 200;	# logistic</Text-field></Input></Group><Group><Input><Text-field layout="Normal" style="Text"/><Text-field layout="Normal" style="Text">Now that we have selected a method for iteration, we set up our iteration itself.</Text-field><Text-field layout="Normal" style="Text"/><Text-field layout="Normal" style="Text">We need to know how many repeats we should ask the computer to compute (N).</Text-field><Text-field layout="Normal" style="Text"/><Text-field layout="Normal" style="Text">We also need to tell the computer the first value (<Font italic="true">initial condition</Font>) (p[0]). We are creating a table of values that we call 'p'. To indicate which entry in the table we use (in other words, which generation of the population), we use brackets '[' and ']' around our <Font italic="true">index</Font>.</Text-field><Text-field layout="Normal" style="Text"/></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input">N:=20;
p[0]:=10;</Text-field></Input></Group><Group><Input><Text-field layout="Normal" style="Text"/><Text-field layout="Normal" style="Text">Now we ask the computer to do the iteration. We use a <Font italic="true">loop</Font>, where the computer repeats a task but on different <Font italic="true">index</Font> in the table each time.</Text-field><Text-field layout="Normal" style="Text"/><Text-field layout="Normal" style="Text">In Maple, we use a <Font italic="false" style="Maple Input" underline="false">for</Font> loop to let the index 't' increment through a sequence of values. Note that we use our variable <Font italic="false" style="Maple Input" underline="false">N</Font> defined above as the last index to use in the loop.</Text-field><Text-field layout="Normal" style="Text"/><Text-field layout="Normal" style="Text">The repeated task is surrounded by the key phrases <Font italic="false" style="Maple Input" underline="false">do</Font> and <Font italic="false" style="Maple Input" underline="false">end do</Font>. Note that we use the previous table entry to fill in the next table entry.</Text-field><Text-field layout="Normal" style="Text"/></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input">for t from 1 by 1 to N do
	p[t] := f(p[t-1]); end do;</Text-field></Input></Group><Group><Input><Text-field layout="Normal" style="Text"/><Text-field layout="Normal" style="Text">If you want to look at the list as a sequence, use the <Font italic="false" style="Maple Input" underline="false">seq</Font> command in Maple to extract information in the table.</Text-field><Text-field layout="Normal" style="Text"/></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input">seq(p[t], t=0..N);</Text-field></Input></Group><Group><Input><Text-field layout="Normal" style="Text"/><Text-field layout="Normal" style="Text">We usually prefer graphical methods to visualize the data, so let's send this sequence to Maple's listplot command. Note that we used the <Font italic="false" style="Maple Input" underline="false">seq</Font> command inside to create the sequence of data values. But we also needed to surround it with brackets '[ ]' so that the sequence is treated as a single object (an ordered list of numbers) instead of a long sequence of independent numbers (a sequence).</Text-field><Text-field layout="Normal" style="Text"/></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input">with(plots):
listplot([ seq(p[t], t=0..N) ], style=POINT);</Text-field></Input></Group><Group><Input><Text-field layout="Normal" style="Text"/><Text-field layout="Normal" style="Text">If you look at the above plot carefully, you'll notice that the first point is plotted at t=1, rather than t=0. Why?</Text-field><Text-field layout="Normal" style="Text"/><Text-field layout="Normal" style="Text">Remember, the listplot command was simply sent an ordered list of values. It didn't know anything more, and so the x-axis is just showing the order in the list. To give more information, such as the true value of the index (which generation), then we need to pass two pieces of information about each point. Notice that the <Font italic="false" style="Maple Input" underline="false">seq</Font> command now creates a sequence of ordered pairs [t, p[t]], which is then combined into a single list before being sent on to <Font italic="false" style="Maple Input" underline="false">listplot</Font>.
</Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input">listplot([ seq([t, p[t]], t=0..N) ], style=POINT, 
	title="Population Size vs Generation", 
	labels=["t", "p[t]"], 	
	labeldirections=[HORIZONTAL,VERTICAL]);</Text-field></Input></Group><Group><Input><Text-field layout="Normal" style="Text"/><Text-field layout="Normal" style="Text">Notice that we added a title to the plot and labels for the axes. You can read about these and other options in the Maple help viewer under plot,options.</Text-field><Text-field layout="Normal" style="Text"/></Input></Group><Group><Input><Text-field layout="Normal" style="Text"/><Text-field layout="Normal" style="Text">Another plot that we want to consider compares the size of one generation with a previous generation. Again, we use a listplot, but with a different order pair in the seq command:</Text-field><Text-field layout="Normal" style="Text"/></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input">k := 1;	# Number of generations between population sizes.
listplot([ seq([p[t-k], p[t]], t=k..N) ], style=POINT, 
	title=cat("Compare generations with lag k=", k), 
	labels=["p[t-k]", "p[t]"], 	
	labeldirections=[HORIZONTAL,VERTICAL]);</Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input"/></Input></Group><Text-field/></Worksheet>