Section 20.2 Predator-prey models
A traditional example of predator-prey relation is foxes and rabbits (in SU neighborhood, it could be hawks and squirrels instead). The Lotka-Volterra model of this relationship involves four positive parameters a,b,c,d:
R′=aR−bRFF′=−cF+dRF
The first equation indicates that without foxes, rabbit population would grow at a constant relative rate. As in SIR model, the number of interactions is proportional to the product RF. Each interaction has a chance of reducing the number of rabbits. These interactions also contribute to the growth of foxes but not necessarily at the same rate (an eaten rabbit does not mean there is now an extra fox; we are not modeling a zombie apocalipse). Finally, the minus sign in −cF ensures that without rabbits, foxes die out.
Example 20.2.1. Implement Lotka-Volterra model.
Use ode45
to solve the equations (20.2.1)-(20.2.2) on the interval \([0, 100]\) with
a = 0.1; b = 0.004; c = 0.2; d = 0.001; y0 = [100, 30];
Answer
To the code lines written above, we only have to add
rhs = @(t, y) [a*y(1) - b*y(1)*y(2); -c*y(2) + d*y(1)*y(2)]; [t, y] = ode45(rhs, [0, 100], y0); plot(t, y, 'LineWidth', 3) legend('Rabbits', 'Foxes')
Observing the periodicity of the solution, one may want to summarize it with a phase plot in addition to time-series plot:
figure() plot(y(:,1), y(:,2), 'LineWidth', 3) xlabel('Rabbits') ylabel('Foxes')