Predator-Prey Simulator
Simulate predators and prey with the Lotka-Volterra equations: population graphs over time, the cycle in the phase plane, the equilibrium and the period.
Simulator
Drag anywhere on the graph to choose the starting prey and predators, or nudge them with the arrow keys. Space plays and pauses.
- Cycle period The exact time for one full cycle, worked out from the quantity the model conserves rather than read off the animation. A larger cycle takes longer.
- 10.15 yr
- Small-swing period 2π/√(αγ), the period of a cycle too small to see. Every real cycle is slower, the way a pendulum swinging wide is slower than the small-angle formula says.
- 9.472 yr
- Equilibrium Prey γ/δ and predators α/β, where neither population changes. Over any complete cycle each population also averages exactly this value.
- 33.33, 19.64 thousand
- Prey range The lowest and highest prey on this cycle, found from the conserved quantity.
- 12.7 to 69.23 thousand
- Predator range The lowest and highest predators on this cycle, found from the conserved quantity.
- 5.9 to 46.43 thousand
- Predator peak lag Time from a prey peak to the next predator peak. For a very small cycle it is a quarter of the small-swing period, 2.37 yr; a larger cycle has its predator peak sooner after the prey peak.
- 1.64 yr
- Prey (thousands)
- Predators (thousands)
- Prey equilibrium
- Predator equilibrium
Citing this tool
Last updated . Add the date you accessed it as well, which a citation of a page that can change asks for. If a specific result matters, cite the permalink from the tool’s share row instead of this page: it reproduces the exact parameters.
The equation
Lotka (1925) and Volterra (1926)
What is the Lotka-Volterra predator-prey model?
The Lotka-Volterra model is a pair of equations for a prey population x and a predator
population y that makes the two rise and fall in a cycle that repeats for ever:
dx/dt = αx − βxy and dy/dt = δxy − γy. Prey multiply at rate α when
left alone and are eaten at a rate βxy that grows with how often the two meet. Predators die out
at rate γ with nothing to eat and grow at a rate δxy by eating. This simulator solves both
equations and shows the answer twice: as the two populations against time in the graph, and as a
loop of predators against prey on the stage above it.
The cycle is easy to follow in words. Plenty of prey feed the predators, so the predators multiply. More predators eat the prey faster than they breed, so the prey decline. With less to eat the predators starve and decline in turn, and with fewer predators the prey recover. Then it starts again. Nothing in the equations mentions a cycle or a period; both come out of the solution.
The populations here are in thousands and time is in years, and the defaults are the estimates
from Bob Carpenter’s 2018 fit of these equations to the numbers of snowshoe hare and Canada lynx
pelts the Hudson’s Bay Company collected between 1900 and 1920: α = 0.55,
β = 0.028, γ = 0.80 and δ = 0.024, with α and γ per year
and β and δ per thousand animals per year, starting from his 33.956 and 5.933 thousand rounded
to 34 and 5.9. The equations do not care about the units. Scale both
populations by the same factor and divide β and δ by it and the curves are the same, so a
textbook problem written in single animals can be typed straight in.
Where the populations balance
Set both rates to zero and the one point where nothing changes drops out:
x* = γ/δ prey and y* = α/β predators. The prey stop changing when
predators number exactly α/β, which is the horizontal dashed line on the stage, and the predators
stop changing when prey number exactly γ/δ, the vertical one. Each is drawn in the colour of the
population it holds still, so every time the loop crosses the blue line the prey are at a peak or
a trough, and every time it crosses the orange line the predators are.
Look at which parameters set which. The prey level depends only on the predators’ death rate and gain, and the predator level only on how fast the prey breed and are caught. Make the prey breed faster and the prey do not become more common on average: the predators do. Volterra also showed that over any complete cycle each population averages exactly its equilibrium value, however large the swings, which is why each dashed line on the graph sits where its curve has equal area above and below it over a cycle, not halfway between the highs and lows.
Worked example: the hare and lynx defaults
Take the defaults as the page opens: α = 0.55, β = 0.028,
γ = 0.80 and δ = 0.024, starting from 34 thousand prey and 5.9
thousand predators.
- The equilibrium.
x* = 0.80 / 0.024 = 33.33thousand prey andy* = 0.55 / 0.028 = 19.64thousand predators, the Equilibrium readout. - The small-swing period.
2π/√(αγ) = 2π/√(0.55 × 0.80) = 9.472years. That is the period of a cycle too small to see. - How big this cycle is. Writing
X = x/x*andY = y/y*, the start is atX = 34/33.33 = 1.020andY = 5.9/19.64 = 0.3004, and the quantity the model conserves isH = γ(X − 1 − ln X) + α(Y − 1 − ln Y) = 0.80 × 0.000197 + 0.55 × 0.5031 = 0.2769per year. It stays at that value for as long as the simulation runs, which the stage prints in its corner. - The highs and lows. Prey are at their extremes when
Y = 1, so solving0.80(X − 1 − ln X) = 0.2769givesX = 2.077andX = 0.3809: prey swing between 12.70 and 69.23 thousand. Predators are at theirs whenX = 1, and0.55(Y − 1 − ln Y) = 0.2769givesY = 2.364andY = 0.3002: predators swing between 5.898 and 46.43 thousand. Starting almost exactly atx*put the start almost at the predators’ low. - The period. Integrating the time taken once round the loop gives 10.15 years, 7.2 percent longer than the small-swing figure, and the Cycle period readout shows it. Within the cycle the predators peak 1.64 years after the prey, about a sixth of the period rather than the quarter a tiny cycle would give.
Averaged over those 10.15 years, the prey come to exactly 33.33 thousand and the predators to 19.64 thousand, the equilibrium values, even though the prey spend nearly three fifths of the cycle below 33.33 thousand and make up for it with a peak that rises further above it.
Reading the phase plane
Every starting point gives a closed loop around the equilibrium, travelled anticlockwise: prey rise along the bottom, predators rise up the right-hand side, prey fall along the top and predators fall down the left. Drag the start point on the stage and a different loop appears. There is no preferred cycle and no natural amplitude; the size of the cycle is set entirely by where it starts, which is what ecologists mean by calling it neutrally stable.
What labels each loop is the conserved quantity H, zero at the equilibrium and larger on every loop further out. It is what lets the page give an exact period and exact highs and lows without trusting the animation, and the faint loop under the trajectory is drawn from it, so any gap between the two would be integration error. The period grows with H, as Jörg Waldvogel proved in 1986, so a large cycle is always slower than 2π/√(αγ), the way a pendulum swinging wide is slower than its small-angle formula; the simple pendulum simulator shows the same relationship for a swing.
Take the start far from the equilibrium and the loop hugs the axes. The prey then crash to a
small fraction of their peak and spend most of the cycle there, the predators starving slowly,
before a short explosive recovery. Without predators the prey would grow exponentially at rate
α, doubling every ln 2/α years, 1.26 years at the default α, the same arithmetic the
cell doubling time calculator does for a
culture.
What a carrying capacity changes
Switch on Limit prey growth and the prey’s own growth becomes logistic,
αx(1 − x/K), so prey compete for food even with no predators about. The closed loops
disappear. As long as K is above γ/δ, every start now settles to a single steady state, at the
same x* = γ/δ prey and fewer predators, y* = (α/β)(1 − γ/(δK)).
With the defaults and K = 100 thousand the populations settle at 33.33 thousand prey
and 13.10 thousand predators, in swings that halve about every 7.56 years and repeat every 11.77
years, the readouts under the stage. Lower K towards γ/δ and the spiral tightens into a steady
approach with no swings at all; take K to or below γ/δ and there is no longer enough prey to
sustain any predators, which die out while the prey settle at K.
That is the most important thing the simulator can show about the classic model. Its cycles are a knife-edge: the tiniest bit of competition among the prey turns them into a spiral, and most other small changes to the equations break them too. A model whose cycles persist in nature needs something that holds their size in place, which the classic equations do not have.
Volterra’s fishing puzzle
Volterra came to these equations through a question from the biologist Umberto D’Ancona. The catch landed at the Adriatic port of Fiume held a far larger share of sharks, skates and rays while fishing was cut back during the First World War: 11.9 percent of the catch in 1914 and 36.4 percent in 1918, in the figures Martin Braun reproduces in his textbook. Less fishing should have helped every species, so why did it help the predators more?
Because fishing both kinds of fish at the same rate e is the same as lowering the prey’s growth
rate to α − e and raising the predators’ death rate to γ + e. The
averages move to (γ + e)/δ prey and (α − e)/β predators, so fishing
harder means more prey and fewer predators, and fishing less the reverse. Try it here: from the
defaults, set α to 0.45 and γ to 0.90, the effect of fishing at 0.1 a year, and the equilibrium
moves from 33.33 and 19.64 to 37.5 thousand prey and 16.07 thousand predators.
Common mistakes
- Swapping which parameters set which equilibrium. The prey level is γ/δ, the predators’ numbers, and the predator level is α/β, the prey’s. Feeding the prey better raises the predators.
- Using 2π/√(αγ) as the period of a real cycle. It is the small-swing limit, and every larger cycle is slower. The defaults’ cycle takes 10.15 years, not 9.47.
- Expecting the predator peak a quarter of a cycle after the prey peak. True only for a very small cycle. On a large one the predators peak sooner after the prey and take longer to recover from the trough.
- Treating β and δ as the same number. β is the prey lost per predator and δ the predators gained per prey, and catching a prey does not make a predator. In the defaults β is 0.028 and δ is 0.024.
- Reading the size of the cycle as a property of the species. In this model it is set by the starting numbers, and any disturbance moves the populations to a different cycle for good.
- Believing a trough of a fraction of an animal. The equations treat populations as smooth numbers, so they recover from any low, however small. When a cycle takes either population below one animal the page says so, because a real population would be extinct.
What this model leaves out
Predators that fill up. Here each predator eats in proportion to the prey available, however many there are. Real predators can only catch and eat so fast, which Holling described in 1959 as a saturating functional response, and the curve is the same shape as the Michaelis-Menten rate in the enzyme kinetics simulator. Add that and a carrying capacity, the model Rosenzweig and MacArthur analysed in 1963, and the swings either die away or settle into a cycle of one size, rather than keeping whatever size they started at.
Chance, and whole animals. Births, deaths and hunts happen one at a time and at random, which matters most when numbers are small and a run of bad luck ends a population. The radioactive decay simulator shows how chance scatters a small count around the smooth curve an equation predicts.
Everything else in the ecosystem. Age structure, the time a predator takes to mature, weather, disease, space and every other species. The real hare cycle, about ten years long, comes from the interaction of predation with the hares’ food supply, as Krebs and colleagues showed with large-scale experiments in the Yukon, reported in 2001.
What the data actually counted. The Hudson’s Bay Company records are pelts collected, not animals counted, and Charles Gordon Hewitt, who analysed them in 1921, noted that lynx are easier to trap when they are hungry, which is when hares are scarce. A good fit of these equations to those numbers is a description of the data, not a census.
Model and assumptions
- Method
- Runge-Kutta 4th order
- Largest step
- 0.01 years
- Repeatability
- Deterministic. The same link gives the same numbers on any machine.
What it assumes
- Prey grow exponentially at rate α when there are no predators, and predators die out at rate γ when there are no prey.
- Predation follows the law of mass action: prey are eaten at a rate βxy and predators grow at a rate δxy, so a predator never fills up.
- Populations are continuous numbers rather than counts of animals, and nothing happens by chance.
- The equations are stepped in the logarithms of the two populations, so neither can ever reach zero, and a step is split wherever either population would change by more than about 5 percent in one step.
- The optional carrying capacity makes the prey’s own growth logistic, αx(1 − x/K), and changes nothing else.
Where it stops holding. A population near its trough is a small whole number of animals that can die out, which these continuous numbers never do. And real predators fill up: once prey are plentiful each eats at a limited rate rather than in proportion to the prey, and with that and a carrying capacity the swings either die away or settle into a cycle of one size, rather than keeping whatever size they start at.
Numerical accuracy
- Estimated error
- 3.2e-5 animals in the prey population, about 4.6e-10 of the largest value reached
- How that was obtained
- Running the same problem again at half the step changed the answer by at most 3.0e-5 animals over 40 years, about four cycles. Richardson extrapolation of that difference gives the figure above.
- Observed order
- 3.99, measured from a second halving rather than assumed
- Conditions
- α 0.55, β 0.028, γ 0.80 and δ 0.024, from 34 thousand prey and 5.9 thousand predators with no carrying capacity, the shipped defaults
Common questions
What are the Lotka-Volterra equations?
Two differential equations for a prey population x and a predator population y: dx/dt = αx − βxy and dy/dt = δxy − γy. Prey multiply at rate α on their own and are eaten at a rate βxy that grows with how often the two meet; predators die at rate γ on their own and grow at a rate δxy from what they eat. Alfred Lotka applied them to predators and prey in his 1925 book Elements of Physical Biology, and Vito Volterra did so independently in 1926, when he used them to explain why predatory fish made up more of the Adriatic catch while fishing was reduced during the First World War.
What is the equilibrium of the predator-prey model?
x = γ/δ prey and y = α/β predators, the one point where neither population changes. Which parameters set which is the surprise: the prey level depends only on the predators’ death rate and gain, and the predator level only on how fast the prey grow and are caught. At the defaults that is 33.33 thousand prey and 19.64 thousand predators. The populations cycle round this point rather than settling on it, and averaged over a whole cycle each equals its equilibrium value exactly.
Why do predator numbers peak after prey numbers?
Because predators keep increasing for as long as prey are above γ/δ, so they go on rising after the prey have peaked and begun to fall, and peak only when the prey drop back through γ/δ. For a very small cycle the predator peak comes exactly a quarter of a period after the prey peak. For a larger one it comes sooner: 1.64 years after the prey peak in the 10.15-year cycle of the defaults, because abundant prey let the predators multiply fast, and the slow part of the cycle is the long recovery from the trough.
Do predator-prey cycles go on for ever?
In the Lotka-Volterra model, yes. The quantity V = δx − γ ln x + βy − α ln y never changes, so the populations come back exactly to where they started and repeat the same cycle indefinitely, whatever its size. That is also the model’s weakness: any disturbance moves them onto a different cycle, and nothing brings them back. Add a carrying capacity, so prey compete for food, and the cycles spiral in to a steady state instead; at the defaults with K = 100 thousand the swings halve about every 7.6 years.
Why did less fishing mean more sharks in the catch?
Because fishing both species at the same rate is the same as lowering the prey’s growth rate α and raising the predators’ death rate γ, which moves the average populations, γ/δ prey and α/β predators, towards more prey and fewer predators. Fishing less does the reverse. Volterra worked this out for the biologist Umberto D’Ancona, whose catch records for the Adriatic port of Fiume show sharks, skates and rays rising from 11.9 percent of the catch in 1914 to 36.4 percent in 1918, while fishing was cut back during the war. To see it here, lower α and raise γ by the same amount.