Lesson 11 of 15
Lotka-Volterra (Predator-Prey)
Lotka-Volterra Equations
The predator-prey model describes two interacting populations: prey (rabbits) and predators (foxes):
- : prey birth rate
- : predation rate (prey killed per encounter)
- : predator growth rate per prey eaten
- : predator death rate
Oscillations
The populations oscillate: when prey are abundant, predators multiply. More predators reduce prey. Fewer prey starve predators. Then prey recover, and the cycle repeats.
Equilibrium
There is a non-trivial equilibrium where both populations are constant:
Starting exactly at this point, populations stay fixed forever.
Conservation Law
The Lotka-Volterra system has a conserved quantity (a "first integral"):
This means the phase-plane trajectories are closed curves.
Your Task
Implement lotka_volterra(alpha, beta, delta, gamma, x0, y0, t_end, n) using Euler's method. Return (x, y).
Pyodide loading...
Loading...
Click "Run" to execute your code.