Lotka–Volterra Predator–Prey 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
- α — prey per-capita birth rate when no predators are present.
- β — predation rate. Encounters remove prey in proportion to the product xy.
- γ — predator per-capita death rate when no prey are present.
- δ — conversion efficiency. The same encounters increase the predator population.
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
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
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
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
- Equilibrium — the balance point implied by the rates. Starting there should stay there.
- Small-oscillation period — the linear benchmark 2π / √(αγ). A large cycle should run somewhat slower.
- Ranges — the smallest and largest prey and predator values on the computed trajectory, including the initial state.
- Period estimate — the mean time between successive prey peaks. You need a horizon longer than two cycles.
- Predator density at the prey maximum — should lie near y* when the numerical orbit is still the true one.
- Sample averages — averages of the stored states. They approach x* and y* over complete cycles. An arbitrary window that cuts a cycle in half will not match, and neither will an Euler orbit that has spiraled away.
- Invariant drift ΔV — zero for the differential equation. Roundoff produces values near 10−15 on a good fine step. A drift of tenths, or a growing drift as you lengthen the horizon, means the step is distorting the cycle.
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.
Start the game, then use your pointer or arrow keys to catch useful population inputs and avoid unsuitable assumptions.
