This page contains a maple code for the course: MATH 111 Applied Mathematical Modelling I --- Maple Assignment II.
# ricker.maple (05.08.07)
# A simple maple program to iterate the scaled Ricker model
# x_{n+1} = x_{n}*exp[r*(1-x_n)];
#
# 21.08.07 Revised to add a utility useful in examining
# periodic solutions
finalyear := 500; # The final value of `n'.
r := 2.656; # static birth rate.
year := n->n; # define the `time' variable.
f := x -> x*exp(r*(1-x)); # x_{n+1} = f(x_{n})
# Instead of using the variable x_{n} we will use the variable
# pop{n}
pop := proc(n) # define the values of pop(n) recursively.
option remember; # Note that using the option remember causes the
f(pop(n-1)) # previous values pop(n-1) to be retained so that
end: # subsequent values may be based on them.
pop(0) := 0.1; # the initial population size.
# calculate the ordered pairs (pop_n,time_n) for n=0..finalyear
solution := [seq([year(n),pop(n)],n=0..finalyear)]:
# if you want to see the values of the data points remove the hash
# at the start of the next line
# array(solution):
# plot ALL the data points
plot(solution,style=POINT,symbol=BOX,color=BLACK,\
labels=["generations","population size"],\
labeldirections=[horizontal,vertical]);
#
# Sometimes we don't want to plot ALL of our data: We might not
# want to show any `transient' behaviour, just the long-term
# `steady' behaviour. The following piece of code pulls out
# the population size for the last 10 generations.
#
lookback := 10;
solution2 := [seq([solution[n,1],solution[n,2]],n=finalyear-lookback..finalyear)]:
# plot the last "lookback" points
p1 := plot(solution2,style=POINT,symbol=BOX,color=BLACK):
p2 := plot(solution2,style=LINE,color=BLACK):
# the following code plots the population in year n as a function
# of the population size in the previous year. It is useful when
# you have a periodic orbit.
#
solution3 := [seq([solution[n,2],solution[n-1,2]],n=finalyear-lookback..finalyear)]:
p3 := plot(solution3,style=POINT,symbol=BOX,color=RED):
# If you have a period n solution then there should be `n' points on
# this figure - but you might need to increase lookback.
p4 := plot(solution3,style=LINE,color=BLUE):
with(plots):
display({p1,p2});
display({p3});
display({p3,p4});
pop := 'pop':