Lotka–Volterra Predator–Prey Calculator

JJ Ben-Joseph headshot JJ Ben-Joseph

Use calculator

Classical predator–prey cycles

The Lotka–Volterra predator–prey model is the simplest differential-equation picture of a two-species cycle. Prey grow when predators are scarce. Predators grow when prey are abundant and decline when prey are not. Alfred J. Lotka introduced the system while studying rhythmic chemical and biological kinetics, and Vito Volterra, prompted by Umberto D'Ancona's Adriatic fishery records, used the same equations to explain why the share of predators in the catch rose when fishing eased during the First World War. The calculator integrates that classical system and reports the quantities needed to tell a real cycle from a numerical artifact.

For positive rates and positive initial populations, the continuous model does not send either population through zero, and it does not let either population run away to infinity. Every orbit in the positive quadrant is a closed cycle around one coexistence equilibrium, or that equilibrium itself. Negative counts and ever-growing peaks are properties of a bad time step, not of the differential equations.

Equations

Let x be prey density and y predator density. The calculator solves

dxdt = x(α−βy) dydt = y(δx−γ)

These constants are scenario parameters in whatever population and time units you choose. They are not universal biological constants.

Equilibrium, period, and the first integral

The positive coexistence equilibrium is

x*=γδ , y*=αβ .

It is a center, not a spiral sink. Small oscillations have period 2π / √(αγ), which does not depend on β or δ. A finite-amplitude cycle is longer. Prey stop increasing at the moment the predator density passes through y*, and predators stop increasing when the prey density passes through x*.

Along every positive solution the first integral

V(x,y) = δx−γlnx + βy−αlny

is exactly constant. Closed level curves of V are the orbits. Volterra's conservation-of-averages law is the companion statement: over a complete cycle, the average prey density is x* and the average predator density is y*, regardless of where on that orbit the cycle started. The calculator reports V(T) − V(0) so a drifting time step cannot hide inside a smooth-looking plot.

Three numerical methods

Forward Euler advances both populations from the current state. It is first-order. On this center it is weakly unstable: the numerical orbit spirals outward, peaks grow, the period lengthens, and a long enough run can cross into negative populations. Those negatives are discarded as a failed step. They are not clipped back to zero, because clipping would invent a different model.

Classical RK4 is the fourth-order Runge–Kutta step and the default. On this smooth, non-stiff system it keeps V nearly constant at ordinary step sizes and is the right choice when you want the cycle's amplitude and timing.

Symplectic Euler is the first-order symplectic Euler method written in logarithmic coordinates u = ln x and v = ln y, where the model is a separable Hamiltonian system and V is the Hamiltonian. One step is

xn+1 = xnexp[Δt(α−βyn)] yn+1 = ynexp[Δt(δxn+1−γ)]

The exponential keeps both populations positive for every finite step. The orbit stays on a nearby closed curve: the error in V oscillates instead of winding outward. Local truncation error is still first-order, so RK4 is more accurate at the same step. Use the symplectic step when the horizon is long or the step is coarse and the question is whether the cycle stays a cycle.

How to read a run

Worked example

The form opens on α = 1.1, β = 0.4, γ = 0.4, δ = 0.1, with 6 prey and 2 predators. Then x* = 4 and y* = 2.75. The small-oscillation period is 9.472 time units. A reference RK4 integration at Δt = 0.0005 out to time 40 keeps prey between 1.897 and 7.272 and predators between 1.791 and 4.002, returns a peak-to-peak period of 9.711, and changes V only in the fifteenth decimal place. Prey maxima fall at predator density 2.750. Over the four complete cycles the average populations reproduce x* and y*.

The same window with forward Euler at Δt = 0.1 is not that cycle. The prey maximum rises from 7.27 to 11.68, about 61 percent too high, the period stretches to about 10.07, and ΔV grows to 0.383. Extending that Euler run further makes the spiral worse. RK4 at Δt = 0.05, the default, stays on the reference cycle for practical purposes. Changing one rate at a time, then checking ΔV, is the useful experiment.

α β γ δ x* y* 2π/√(αγ)
1.1 0.4 0.4 0.1 4 2.75 9.472
0.6 0.2 0.3 0.05 6 3 14.810
2.0 0.5 0.8 0.2 4 4 4.967

What this model leaves out

Real prey face a carrying capacity, and real predators satiate. A Holling type II response or a logistic prey term replaces the neutrally stable center with a spiral point or a stable limit cycle. The closed orbit here is structurally fragile: a small change in the equations changes the kind of attractor, which is why laboratory predator–prey systems and the Canada lynx cycle are not evidence for this exact mechanism. Harvest, seasonality, age structure, and chance are absent. The run is a forward scenario, not a fit to a time series and not a management forecast.

The step count is capped so an unbounded horizon cannot freeze the page. Non-numeric, non-positive, and non-finite entries are rejected in the result panel. Editing an input clears the previous result, so a number on screen always belongs to the inputs currently in the form.

Arcade Mini-Game: Lotka-Volterra Predator-Prey Calculator Calibration Run

Use this quick predator–prey calibration run to identify the population inputs and rate assumptions that belong in a Lotka–Volterra simulation.

Score: 0 Timer: 30s Best: 0

Start the game, then use your pointer or arrow keys to catch useful population inputs and avoid unsuitable assumptions.

Enter prey and predator values, then run the simulation.