In this lab we will use simulation to study various systems of
difference equations.
Our main focus will be on interacting species models like
predator-prey and competing species.
1. Linear Predator-Prey
Let x(n) be the number of rabbits and y(n) be the number
of foxes after n weeks. The model for their interaction is:
x(n+1) = x(n) + 0.1 x(n) - 0.25 y(n)
y(n+1) = y(n) - 0.2 y(n) + 0.15 x(n)
On their own rabbits would grow in number, foxes would decrease.
Write a MATLAB script (or use the one below) to simulate this
system for 100 weeks. Plot the number of foxes vs. the number
of rabbits, i.e. y vs. x.
Try starting with 20 rabbits and 4 foxes. Do both species survive?
Try increasing the starting rabbit population. Is there any value
which lets both species survive?
2. Nonlinear Predator-Prey
Let x(n) and y(n) be as in 1. Now we are going to
model the interaction between the rabbits and the foxes by a
mixing term: x(n)y(n). The model is then
x(n+1) = x(n) + 0.1 x(n) - 0.02 x(n)y(n)
y(n+1) = y(n) - 0.2 y(n) + 0.01 x(n)y(n)
On their own rabbits would grow in number, foxes would decrease.
When the number of rabbits is low, it is harder for the foxes to
find them.
Write a MATLAB script (or use the one below) to simulate this
system for 100 weeks. Plot the number of foxes vs. the number
of rabbits, i.e. y vs. x.
Try starting with 20 rabbits and 4 foxes. Do both species survive?
What do you think would happen if you extended the simulation?
Try different starting values. Is there an equilibrium
value, i.e. are there starting values so that the populations
never change?
3. Competing Species Model
Let x(n) be the number of owls and y(n) be the number
of hawks after n weeks. The model for their interaction is:
x(n+1) = x(n) + 0.1 x(n) - 0.25 y(n)
y(n+1) = y(n) + 0.05 y(n) - 0.15 x(n)
On their own both would grow in number, and each are hurt by
the existence of the other.
Write a MATLAB script (or use the one below) to simulate this
system for 100 weeks. Plot the number of hawks vs. the number
of owls, i.e. y vs. x.
Try starting with 10 owls and 10 hawks. Which species survives?
You will need to zoom in to see what happens.
Increase the starting number of owls, until they survive.
Is is possible for both species to survive?
There is a nonlinear version of this model:
x(n+1) = x(n) + 0.1 x(n) - 0.02 x(n)y(n)
y(n+1) = y(n) + 0.05 y(n) - 0.01 x(n)y(n)
Write a script to simulate this system. Is there an equilibrium
solution to this system?
Scripts
% script file to simulate the linear predator-prey model
x(1) = input('Enter the initial number of rabbits:');
y(1) = input('Enter the initial number of foxes:');
for n = 1:100
x(n+1) = x(n) + 0.1*x(n) - 0.25*y(n);
y(n+1) = y(n) - 0.2*y(n) + 0.15*x(n);
end
plot(x,y), xlabel('Rabbits'), ylabel('Foxes')
% end of script
% script file to simulate the nonlinear predator-prey model
x(1) = input('Enter the initial number of rabbits:');
y(1) = input('Enter the initial number of foxes:');
for n = 1:100
x(n+1) = x(n) + 0.1*x(n) - 0.02*x(n)*y(n);
y(n+1) = y(n) - 0.2*y(n) + 0.01*x(n)*y(n);
end
plot(x,y), xlabel('Rabbits'), ylabel('Foxes')
% end of script
% script file to simulate the linear competing species model
x(1) = input('Enter the initial number of owls:');
y(1) = input('Enter the initial number of hawks:');
for n = 1:100
x(n+1) = x(n) + 0.1*x(n) - 0.25*y(n);
y(n+1) = y(n) + 0.05*y(n) - 0.15*x(n);
end
plot(x,y), xlabel('Owls'), ylabel('Hawks')
% end of script