# PREDATOR_PREY_ODE ODE Solution of a Predator Prey System

PREDATOR_PREY_ODE, a MATLAB program which applies the ODE23 function to estimate solutions of a pair of ordinary differential equations that model the behavior of a pair of predator and prey populations.

The physical system under consideration is a pair of animal populations.

The PREY reproduce rapidly; for each animal alive at the beginning of the year, two more will be born by the end of the year. The prey do not have a natural death rate; instead, they only die by being eaten by the predator. Every prey animal has 1 chance in 1000 of being eaten in a given year by a given predator.

The PREDATORS only die of starvation, but this happens very quickly. If unfed, a predator will tend to starve in about 1/10 of a year. On the other hand, the predator reproduction rate is dependent on eating prey, and the chances of this depend on the number of available prey.

The resulting differential equations can be written:

PRED(0) = 5000
PREY(0) =  100

d PREY / dT =    2 * PREY(T) - 0.001 * PREY(T) * PRED(T)
d PRED / dT = - 10 * PRED(T) + 0.002 * PREY(T) * PRED(T)

Here, the initial values (5000,100) are a somewhat arbitrary starting point.

The pair of ordinary differential equations that result have an interesting behavior. For certain choices of the interaction coefficients (such as those given here), the populations of predator and prey will tend to a periodic oscillation. The two populations will be out of phase; the number of prey will rise, then after a delay, the predators will rise as the prey begins to fall, causing the predator population to crash again.

In this program, the pair of ODE's is solved by calling MATLAB's ODE23 function.

### Usage:

predator_prey_ode ( [ pred, prey ], [ t0, t_max ] )
where
• [ pred, prey ] is a vector containing the initial numbers of predators and prey at the initial time;
• [ t0, t_max ] is a vector containing the initial and final time;
The program uses ODE23 to estimate the solution from T0 to T_MAX, and displays a plot of the pair of solution curves.

### Licensing:

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

### Languages:

PREDATOR_PREY_ODE is available in a MATLAB version.

### Related Data and Programs:

FD_PREDATOR_PREY, a MATLAB program which solves a pair of predator prey ODE's using a finite difference approximation.

FD1D_PREDATOR_PREY, a MATLAB program which implements a finite difference algorithm for predator-prey system with spatial variation in 1D.

FD2D_PREDATOR_PREY, a MATLAB program which implements a finite difference algorithm for a predator-prey system with spatial variation in 2D.

FLAME_ODE, a MATLAB library which considers an ordinary differential equation (ODE) which models the growth of a ball of flame in a combustion process.

LORENZ_ODE, a MATLAB program which approximates solutions to the Lorenz system, creating output files that can be displayed by gnuplot.

PENDULUM_ODE, a MATLAB library which looks at some simple topics involving the linear and nonlinear ordinary differential equations (ODEs) that represent the behavior of a pendulum of length L under a gravitational force of strength G.

SPRING_ODE, a MATLAB program which shows how line printer graphics can be used to make a crude illustration of a solution of the ordinary differential equation (ODE) that describes the motion of a weight attached to a spring.

TEST_ODE, a MATLAB library which defines ordinary differential equations (ODE) test problems.

### Reference:

1. George Lindfield, John Penny,
Numerical Methods Using MATLAB,
Second Edition,
Prentice Hall, 1999,
ISBN: 0-13-012641-1,
LC: QA297.P45.

### Source Code:

Last revised on 04 March 2019.