SIR Epidemic Model
The SIR (Susceptible–Infected–Recovered) model is a classic compartmental framework for infectious disease dynamics. This simulator uses normalized fractions with S + I + R = 1, representing the entire population divided into three groups: susceptible individuals who can still catch the disease, infected individuals who can transmit it, and recovered (or removed) individuals who are no longer infectious and are assumed immune. The ordinary differential equations are S′ = −β S I, I′ = β S I − γ I, and R′ = γ I, where β is the transmission rate combining contact frequency and probability of transmission per contact, and γ is the recovery rate (inverse of the typical infectious period). The basic reproduction number ℛ₀ = β/γ describes how many secondary infections one typical infective would cause in a fully susceptible population; when ℛ₀ > 1, an outbreak can grow initially. A standard threshold argument shows that growth slows once the susceptible fraction drops near S_crit ≈ 1/ℛ₀, and in a homogeneous well-mixed model with no demography, a herd-immunity reference level is often quoted as an immune fraction of about 1 − 1/ℛ₀, above which the effective reproduction number would fall below one if susceptibles were the only constraint. The simulator integrates the ODEs with a fixed-step fourth-order Runge–Kutta method, renormalizes S + I + R after each step to correct drift, plots S, I, and R versus time, marks the peak of I(t), and draws a dashed horizontal line at y = 1 − 1/ℛ₀ when ℛ₀ > 1. Sliders allow β, γ, initial infected fraction I(0), and initial immune fraction R(0). The model omits births, deaths, seasonality, spatial structure, age structure, stochasticity, and waning immunity—standard extensions appear in SEIR models and network epidemiology.
Who it's for: Undergraduate students in calculus-based biology, public health, or mathematical modeling courses, and anyone learning compartment models and epidemic thresholds.
Key terms
- SIR model
- Compartment model
- Basic reproduction number (ℛ₀)
- Transmission rate (β)
- Recovery rate (γ)
- Herd immunity threshold
- Runge–Kutta integration
- ODE
How it works
Standard **SIR** compartment model in fractions **S + I + R = 1**: infection rate **β S I**, recovery **γ I**. **ℛ₀ ≈ β/γ** when everyone is susceptible. The dashed line marks the **immune fraction** **1 − 1/ℛ₀** needed for **ℛ_eff < 1** in this homogeneous threshold picture (ignoring demography and heterogeneity). **RK4** integration; **pink dot** — maximum **I(t)** on the current run.
Key equations
Frequently asked questions
- Why is ℛ₀ shown as β/γ here?
- In this standard SIR formulation with mass-action infection β S I and exponential recovery γ I, at the start of an outbreak when S ≈ 1, each infective loses infection at rate γ while creating new infectives at rate β S ≈ β per infective in appropriate time units, so the ratio β/γ is the basic reproduction number ℛ₀. If ℛ₀ ≤ 1, the infection cannot sustain growth from a small seed in this deterministic model.
- What does the dashed horizontal line at 1 − 1/ℛ₀ mean?
- It is a textbook reference for the immune fraction needed in a simplified homogeneous model so that, if susceptibles were the limiting factor and everyone else were immune, the effective reproduction number would drop below one. It is not a prediction for real policy: real populations mix unevenly, immunity may wane, and vaccines or prior infection do not affect everyone equally.
- Why do I need to press Reset after changing β, γ, or initial conditions?
- The time series and peak marker describe the current run. Changing parameters mid-simulation would mix different dynamics on one graph. Reset restarts the clock and rebuilds the history from your chosen I(0) and R(0).
- What important effects does this simple SIR model leave out?
- It ignores exposed (latent) periods (SEIR would add a compartment), demographic turnover, seasonality, spatial or network structure, age stratification, stochastic extinction of small outbreaks, behavioral change, and medical interventions such as vaccination campaigns modeled explicitly. It is a pedagogical core model, not a forecasting tool for a specific disease.
More from Math Visualization
Other simulators in this category — or see all 30.
Sandpile (SOC)
BTW abelian model: add grains, ≥4 topples to neighbors; critical avalanches.
Flow Field Particles
Synthetic v(x,y,t); advection with wrap; optional arrow grid.
Fractal Generator
Mandelbrot, Julia, Koch snowflake. Zoom infinitely.
Conway's Game of Life
B3/S23 on a torus: paint cells, run, step — glider, LWSS, Gosper gun, pulsar, and more.
a → v → x
Integrate acceleration to velocity and position; stacked time graphs.
Taylor Polynomial
sin, cos, or exp vs Taylor sum about center a up to order n.