Predator-Prey Equations

LotkaVolterra[{a_,b_,c_,d_},{x0_,y0_},t1_]:=Module[{x,y,t},
{x,y}/.Quiet[NDSolve[{
x'[t]==a x[t]-b x[t] y[t],
y'[t]==-c y[t]+d x[t]y[t],
x[0]==x0,
y[0]==y0
},{x,y},{t,0,t1}]]//Flatten
];

Manipulate[
Module[
{soln,col1=RGBColor[1,.47,0],col2=ColorData["HTML","SlateBlue"]},
Plot[Evaluate[{#[[1]][t],#[[2]][t]}&[soln=Quiet@LotkaVolterra[{a,b,c,d},{prey0,predator0},tmax]]],{t,0,Min[tmax,Min[#[[1,1,2]]&/@soln]]},
AxesLabel->TraditionalForm/@{t,{Style[prey[t],col1],Style[predator[t],col2]}},
PlotRange->All,AxesOrigin->{0,0},PlotStyle->{col1,col2},ImageSize->{400,300},ImagePadding->{{40,10},{10,25}}]
],
{{a,1,"A"},-5,5,.01,ImageSize->Tiny,Appearance->"Labeled"},{{b,1,"B"},-5,5,.01,ImageSize->Tiny,Appearance->"Labeled"},{{c,1,"C"},-5,5,.01,ImageSize->Tiny,Appearance->"Labeled"},{{d,1,"D"},-5,5,.01,ImageSize->Tiny,Appearance->"Labeled"},Delimiter,
"initial populations",
{{prey0,3,"prey"},0,20,ImageSize->Tiny},
{{predator0,5,"predator"},0,20,ImageSize->Tiny},Delimiter,{{tmax,40,"maximum time"},.01,50,ImageSize->Tiny},
SaveDefinitions->True,ControlPlacement->Left]

CAPTION

The Lotka–Volterra equations describe an ecological predator-prey (or parasite-host) model which assumes that, for a set of fixed positive constants A (the growth rate of prey), B (the rate at which predators destroy prey), C (the death rate of predators), and D (the rate at which predators increase by consuming prey), certain simple conditions hold in the population change rates for prey and predator. (from Wolfram MathWorld)

THIS NOTEBOOK IS THE SOURCE CODE FROM

"Predator-Prey Equations" from the Wolfram Demonstrations Project
 http://demonstrations.wolfram.com/PredatorPreyEquations/

Contributed by: Eric W. Weisstein

A full-function Wolfram Mathematica system (Version 6 or higher) is required to edit this notebook.
GET WOLFRAM MATHEMATICA »

© Wolfram Demonstrations Project & Contributors   |   Terms of Use   |   Make a new version of this Demonstration »