predator_prey_ode, a MATLAB code which sets up and solves a pair of ordinary differential equations (ODE) that model a pair of predator and prey populations, for which a limit cycle exists.
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:
PREY(0) = 5000 PRED(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.
The computer code and data files described and made available on this web page are distributed under the MIT license
predator_prey_ode is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version and an Octave version and a Python version.
matlab_ode, MATLAB codes which set up various ordinary differential equations (ODE).