← Back

Dynamical Systems · Interactive

SIR Model Simulation

How an epidemic sweeps through a population — and when it doesn't.

View project on GitHub →

The SIR model splits a population into three groups — Susceptible, Infected, and Recovered — and uses three coupled differential equations to track how people flow from S to I to R over time. The shape of the outbreak is governed by a tug-of-war between how fast the disease spreads (β) and how fast people recover (γ), summarized by a single number: the basic reproduction number R₀. Drag the sliders to change the population and the disease, and watch the outbreak respond in real time.

Differential Equations

dSdt=βSINdIdt=βSINγIdRdt=γI\begin{aligned} \frac{dS}{dt} &= -\beta\,\frac{S\,I}{N} \\[4pt] \frac{dI}{dt} &= \beta\,\frac{S\,I}{N} - \gamma\,I \\[4pt] \frac{dR}{dt} &= \gamma\,I \end{aligned}

These equations are solved numerically with RK4 (4th-order Runge-Kutta). The disease-free equilibrium (I = 0) is stable when R₀ < 1 and unstable when R₀ > 1, which is what separates "no outbreak" from "epidemic."