Predator and Prey Simulator
The Lotka-Volterra equations produce something striking: predator and prey populations cycle forever, with the predators always peaking after the prey. The equations also have a conserved quantity that stays exactly fixed on a true orbit — which makes it a perfect check on the numerical method, because a sloppy integrator makes the cycles spiral. This reports that drift rather than quietly absorbing it.
What this generator does
Integrates the Lotka-Volterra equations with the midpoint method and records the populations along the way, together with the model's conserved quantity at each step so its drift can be reported.
How to use this tool
- Set the starting prey and predator numbers.
- Run, and look at how the two populations rise and fall in turn.
- Note the equilibrium: starting there gives no cycle at all.
- Check the drift figure — it is the error in the simulation, not in the ecology.
Understanding the controls
- Starting prey
- The prey population at time zero. Further from equilibrium means larger cycles.
- Starting predators
- The predator population at time zero. Setting both to the equilibrium values produces a flat line, which is itself worth seeing.
Common use cases
- Teaching predator-prey cycles with the lag made visible
- Showing why populations peak in sequence rather than together
- Demonstrating a conserved quantity as a check on a simulation
- Producing population data for a graph or a modelling exercise
- Exploring how the starting point changes the size of the cycles
How this generator works
Prey grow exponentially in the absence of predators and are eaten at a rate proportional to the product of the two populations; predators die off without prey and grow from what they eat. The midpoint method is used rather than plain Euler because Euler spirals outwards fast enough to visibly destroy the cycles. Lotka-Volterra has a quantity that is exactly constant along any true orbit, so it is computed at every recorded step and its total drift is reported — that number is the integration error, and it is shown rather than smoothed away.
Randomness and fairness
Nothing here is random. The equations are deterministic, so the same starting populations always trace the same cycle.
For how randomness is produced across the whole site, see how Generate Random works.
Limitations and good to know
- Neither population has a carrying capacity, so prey grow without limit whenever predators are scarce.
- The model is famously fragile: it has no stable cycle, only a family of orbits, so any real-world detail changes the behaviour qualitatively.
- Rates are fixed rather than seasonal, and there is no age structure, migration or third species.
- Populations are continuous quantities, so fractional animals appear — a real small population needs a stochastic model instead.
Privacy and your data
The simulation runs in your browser and nothing you set is transmitted, stored or included in analytics.
Related generators
- SIR Epidemic SimulatorRuns the standard susceptible-infected-recovered model day by day, with the three groups re-totalled against the population every step.
- Markov Chain SimulatorDefine states and transition probabilities, then simulate — with a long-run distribution quoted only when the chain genuinely has one.
- Science Observation Prompt GeneratorWhat to observe before drawing conclusions, distinct from a stated science fact or hypothesis.
- Random Walk SimulatorTakes a walk one coin flip at a time, draws the path, and says exactly how unusual the finish was.