Flow Lab

Syllabus / Module 15: Applications: Biology, Chemistry & Society

Lesson 15.3

Epidemic Models

SIR, SEIR, the basic reproduction number R₀, herd immunity, vaccination and spatial spread.

Written byClaude Sonnet

🌊
Why this matters for simulation: Spatial epidemics are reaction-diffusion PDEs — the same numerics as heat flow.

By the end of this lesson you can…

  • Write the SIR equations from a mass-action contact law, define $R_0$ and show that infection grows exactly when $R_0 S \gt 1$.
  • Derive the conserved quantity $I + S - (\gamma/\beta)\ln S$, and use it to get the peak prevalence and the final-size relation.
  • Solve the transcendental final-size equation by Newton's method, and say why the final size overshoots the herd-immunity threshold $1 - 1/R_0$.
  • Predict the effect of vaccination and of a mid-course drop in the contact rate, and explain why timing matters so much.
  • Add a latent class (SEIR) and explain what it changes (growth rate, timing, peak) and what it does not (final size).
  • Find the endemic point of SIR with births and show from the Jacobian that it is a damped oscillation, with a period you can predict.
On this page
·
  1. The SIR model
  2. The conserved quantity
  3. The final-size relation
  4. Herd immunity and vaccination
  5. Changing beta mid-course
  6. SEIR: a latent period
  7. Births, waning immunity and the endemic state
  8. What the model leaves out
  9. The exercise: final size by Newton, and the endemic eigenvalues
  10. Concept checks
  11. Problems
  12. What comes next
  13. Key Takeaways

15.2 Predator–Prey & Competing Species ended on a coupling: a product of two populations, a conserved quantity, a threshold that decides who invades. An epidemic is the same machinery with the roles changed. Susceptibles SS meet infectious people II at a rate proportional to S IS\,I, which is mass-action again, and the infectious recover into a class RR that cannot be infected twice. There is no predator to starve, so no cycle: the susceptibles are only used up. What replaces the oscillation is a threshold and a final size, and both come out of one conserved quantity.

▶ Video The SIR equations, the conserved quantity and the final-size equation, herd immunity and vaccination, a mid-course drop in contacts, the latent class of SEIR, and the endemic oscillationcaptions only
Transcript
  1. Last lesson ended on a promise, so let us cash it. Susceptibles S and infectious people I meet at a rate proportional to the product S times I, which is mass action again. The equations are S prime equals minus beta S I, I prime equals beta S I minus gamma I, and R prime equals gamma I. Take beta 0.4, gamma 0.2 and a seed of 0.001. Dividing dI by dS separates the variables, and Q equals I plus S minus one over R 0 times ln S is conserved. It starts at 1.000500, and over 300 days it drifts by only 6 times 10 to the minus 13.
  2. Factor the second equation: I prime equals I times beta S minus gamma. Infection grows exactly when beta S exceeds gamma. At the start S is about 1, so R 0 equals beta over gamma, the number of people one infectious person infects in a wholly susceptible population. Here R 0 is 2. Early on I grows like e to the beta minus gamma times t, with a doubling time of 3.47 days, and I first reaches 0.01 on day 11.7. Then I peaks exactly when S equals 1 over R 0, and falls afterwards. This is last lesson's invasion test again.
  3. Now the peak. At the peak S equals 1 over R 0, so set Q there equal to Q at the start and solve. I max equals I 0 plus S 0 minus one plus ln of R 0 S 0, all over R 0. For R 0 equal to 2 the formula gives 0.153927. The run peaks at 0.153926 on day 33.8, when S is 0.4996, and an independent scipy integration agrees at 0.153927.
  4. How far does it go? The epidemic ends when I returns to 0, and Q at the end gives ln of S 0 over S infinity equals R 0 times 1 minus S infinity. This is transcendental: no elementary formula. But g is convex and decreasing left of 1 over R 0, so Newton's method from the left converges monotonically. For R 0 equal to 2 the iterates are 0.185561, 0.201935, 0.203181, 0.2031879 and 0.20318787. So S infinity is 0.203188, and 79.7 percent are infected, although the herd immunity threshold is 0.5: 15 percent are still infectious when S passes 1 over R 0.
  5. Vaccinating a fraction v starts those people in R. An outbreak is impossible when R 0 S 0 is at most 1, so v must reach 1 minus 1 over R 0: 50 percent for R 0 equal to 2. Short of that, vaccination still helps. With 30 percent vaccinated the peak falls from 0.1539 to 0.0325 and arrives on day 61.9. With 40 percent it is 0.0097, on day 87.9. At 50 percent there is no outbreak.
  6. Distancing lowers beta. Cut it to 0.6 beta on day 30, so the new R 0 is 1.2. On day 30 the epidemic is at its peak, I is 0.1401, and R 0 prime times S is 0.752, below 1, so infection falls. Restarting the final-size equation from that state gives S infinity of 0.40695: 59.3 percent infected instead of 79.7. The same cut on day 60, when the epidemic is almost over, leaves 79.0 percent. Timing matters.
  7. Now add a latent class E, with rate sigma. The final-size derivation never used sigma, so the final size is unchanged, 79.7 percent. What changes is timing. Linearising gives a growth rate of 0.0922 for a four-day latent period, against 0.2000 without it. The peak is lower, 0.0848 against 0.1539, and later, on day 71.1 instead of 33.8. And I first reaches 0.01 on day 32.3, instead of 11.7.
  8. Add births and deaths at rate mu and the epidemic need not end. With mu equal to 0.01, R 0 is 1.905, and the endemic point has S star 0.525 and I star 0.022619. The trace of the Jacobian is minus 0.019048 and the determinant is 0.0019, so the eigenvalues are minus 0.009524 plus or minus 0.042536 i: a stable spiral. The period is 2 pi over 0.042536, or 147.7 days, and the run measures 146.7. The epidemic rings, and the ringing dies out with e-folding time 105 days.
  9. SIR is a reaction network written as differential equations: S plus I makes 2 I at rate beta S I, and I becomes R at rate gamma I. That product is the law of mass action, and the next lesson on chemical kinetics builds on it: rate constants, equilibrium, Michaelis-Menten saturation. One warning. Here beta and gamma differ by a factor of two, so RK4 at 0.05 days is far from its stability limit. In chemistry rate constants differ by many orders of magnitude, and that is stiffness.

The SIR model

Take the population as fractions, S+I+R=1S + I + R = 1, and time in days. Each infectious person makes contacts that infect a susceptible at rate βS\beta S per day, and recovers at rate γ\gamma, so the infectious period averages 1/γ1/\gamma:

S′=−βSI,I′=βSI−γI,R′=γI.S' = -\beta S I, \qquad I' = \beta S I - \gamma I, \qquad R' = \gamma I.

The three equations sum to (S+I+R)′=0(S + I + R)' = 0, so R=1−S−IR = 1 - S - I can be dropped: the dynamics live in the (S,I)(S, I) plane. We use β=0.4\beta = 0.4 and γ=0.2\gamma = 0.2 per day and a seed I0=0.001I_0 = 0.001 throughout (teaching values, not fitted to any disease).

The threshold. Factor the second equation: I′=I (βS−γ)I' = I\,(\beta S - \gamma). Infection grows iff βS>γ\beta S \gt \gamma. At the start S≈1S \approx 1, so define the basic reproduction number

R0=βγ,R_0 = \frac{\beta}{\gamma},

the number of people one infectious person infects in a wholly susceptible population: β\beta per day, over 1/γ1/\gamma days. With SS below 11 the relevant number is the effective reproduction number R0SR_0 S. Then II rises while R0S>1R_0 S \gt 1, peaks exactly when S=1/R0S = 1/R_0, and falls afterwards. Here R0=2R_0 = 2. In the linearised early phase I≈I0e(β−γ)tI \approx I_0 e^{(\beta - \gamma)t}, a doubling time of ln⁡2/0.2=3.47\ln 2/0.2 = 3.47 days, and in the full run II first reaches 0.010.01 on day 11.711.7 (sim and scipy agree).

This is the invasion test of the last lesson: a rare newcomer grows iff its per-capita growth rate, here βS−γ\beta S - \gamma, is positive.

The conserved quantity

Divide the equations, as for Lotka-Volterra:

dIdS=βSI−γI−βSI=−1+γβS=−1+1R0S.\frac{dI}{dS} = \frac{\beta S I - \gamma I}{-\beta S I} = -1 + \frac{\gamma}{\beta S} = -1 + \frac{1}{R_0 S}.

This separates, and integrating gives

Q(S,I)=I+S−1R0ln⁡S=constant along every solution.Q(S, I) = I + S - \frac{1}{R_0}\ln S = \text{constant along every solution}.

Check by differentiating: Q′=I′+S′−S′/(R0S)=(βSI−γI)−βSI+γI=0Q' = I' + S' - S'/(R_0 S) = (\beta S I - \gamma I) - \beta S I + \gamma I = 0. For the run above, Q=1.000500Q = 1.000500 at the start and the largest deviation over 300300 days is 6×10−136\times10^{-13} for RK4 with step 0.050.05 (scipy gives 2×10−122\times10^{-12}). Unlike the Lotka-Volterra HH, this QQ has no interior minimum: its level sets are arcs from the start, over the line S=1/R0S = 1/R_0, down to the axis I=0I = 0.

Peak prevalence. At the peak, S=1/R0S = 1/R_0. Equate QQ there to QQ at the start:

Imax⁡+1R0−1R0ln⁡1R0=I0+S0−1R0ln⁡S0⟹Imax⁡=I0+S0−1+ln⁡(R0S0)R0.I_{\max} + \frac{1}{R_0} - \frac{1}{R_0}\ln\frac{1}{R_0} = I_0 + S_0 - \frac{1}{R_0}\ln S_0 \quad\Longrightarrow\quad I_{\max} = I_0 + S_0 - \frac{1 + \ln(R_0 S_0)}{R_0}.

For R0=2R_0 = 2, S0=0.999S_0 = 0.999 the formula gives 0.1539270.153927, the sim’s RK4 run 0.1539260.153926 on day 33.833.8 (at S=0.4996S = 0.4996), and scipy at tolerance 10−1110^{-11} gives 0.1539270.153927 at S=0.49999S = 0.49999.

The final-size relation

The epidemic ends when I→0I \to 0. Where does SS stop? The conserved quantity again, now at the end of the run, where I=0I = 0:

I0+S0−1R0ln⁡S0=S∞−1R0ln⁡S∞.I_0 + S_0 - \frac{1}{R_0}\ln S_0 = S_\infty - \frac{1}{R_0}\ln S_\infty.

Rearranged, and using S0+I0=1S_0 + I_0 = 1 with no one vaccinated,

ln⁡S0S∞=R0 (1−S∞).\ln\frac{S_0}{S_\infty} = R_0\,(1 - S_\infty).

This is transcendental: S∞S_\infty appears both inside a logarithm and linearly, so there is no elementary closed form (the Lambert W function solves it, from memory). Solve it numerically. Let g(s)=ln⁡(S0/s)−R0(S0+I0−s)g(s) = \ln(S_0/s) - R_0(S_0 + I_0 - s). Then g′(s)=R0−1/sg'(s) = R_0 - 1/s and g′′=1/s2>0g'' = 1/s^2 \gt 0: on s<1/R0s \lt 1/R_0 the function is convex and decreasing, positive near 00 and negative at s=S0s = S_0 (it equals −R0I0-R_0 I_0 there). So exactly one root lies below 1/R01/R_0 and Newton’s method started from the left converges monotonically, because every tangent of a convex decreasing function undershoots the root. A good left start is s=S0e−R0s = S_0 e^{-R_0}.

For R0=2R_0 = 2 and I0=0I_0 = 0 the iterates are 0.1855610.185561, 0.2019350.201935, 0.2031810.203181, 0.20318790.2031879, 0.203187870.20318787 (sim); an independent bracketing root-finder (scipy brentq) gives 0.2031880.203188. So 79.7%79.7\% of the population is infected. With the seed I0=0.001I_0 = 0.001 the root is S∞=0.202846S_\infty = 0.202846 and the ODE run ends at 0.2028460.202846, so 79.7%79.7\% again. Newton takes 66 steps to reach 10−1410^{-14} (sim).

R0R_0final size 1−S∞1 - S_\inftypeak Imax⁡I_{\max}herd threshold 1−1/R01 - 1/R_0
1.51.50.58390.58390.06370.06370.33330.3333
220.79720.79720.15390.15390.50000.5000
330.94060.94060.30080.30080.66670.6667
440.98020.98020.40370.40370.75000.7500
660.99750.99750.53490.53490.83330.8333

All rows use I0=0.001I_0 = 0.001. Each final size was checked two ways, Newton in the sim and the end of a long scipy integration, which agree to 10−1210^{-12}. The peak column is the formula, checked against an integrated peak for R0=2R_0 = 2 only.

The overshoot. At R0=2R_0 = 2 the peak occurs when half the population has been infected, yet the epidemic ends with 79.7%79.7\%. When SS passes 1/R01/R_0 the number currently infectious is 15%15\% of the population, and those people keep infecting for a while after the growth has stopped. Reaching the tipping point is not the same as stopping there.

◆ Interactive SIR: change beta, gamma, the vaccinated fraction and a mid-course drop in beta; read the peak, the conserved-quantity curve and the Newton final size

Loading simulation…

Herd immunity and vaccination

Vaccinate a fraction vv before the epidemic: they start in RR, so S0=1−I0−vS_0 = 1 - I_0 - v and the effective number is R0S0R_0 S_0. An outbreak is impossible iff R0S0≤1R_0 S_0 \le 1, that is

v≥vc=1−1R0(up to the tiny seed I0),v \ge v_c = 1 - \frac{1}{R_0} \quad(\text{up to the tiny seed } I_0),

the herd-immunity threshold: each case then infects fewer than one other. For R0=2R_0 = 2 that is 50%50\%; for R0=4R_0 = 4, 75%75\%. The final-size relation becomes ln⁡(S0/S∞)=R0(S0+I0−S∞)\ln(S_0/S_\infty) = R_0(S_0 + I_0 - S_\infty), which is how the sim computes the table below.

vvR0S0R_0 S_0peak II (day)ever infected
001.9981.9980.15390.1539 (day 33.833.8)0.79720.7972
0.30.31.3981.3980.03250.0325 (day 61.961.9)0.35920.3592
0.40.41.1981.1980.00970.0097 (day 87.987.9)0.19200.1920
0.50.50.9980.998no outbreak0.03100.0310
0.60.60.7980.798no outbreak0.00490.0049

(Sim and scipy agree on every entry. “Ever infected” counts everyone who leaves SS, seed included; “no outbreak” means II never exceeds I0I_0.) Vaccinating 30%30\% and 40%40\%, short of the threshold, shrinks the peak by factors of 55 and 1616 and delays it by weeks.

Changing beta mid-course

Distancing and masks lower β\beta. Suppose β\beta drops to 0.6β0.6\beta on day 3030, so the new reproduction number is R0′=1.2R_0' = 1.2. At day 3030 the epidemic is at its peak (I=0.1401I = 0.1401, S=0.6269S = 0.6269, R=0.2330R = 0.2330, so R0′S=0.752<1R_0' S = 0.752 \lt 1), and infection falls from there. The conserved quantity changes at the jump, but the final-size argument can be restarted from the state at day 3030 with the new constant: ln⁡(Sc/S∞)=R0′(Sc+Ic−S∞)\ln(S_c/S_\infty) = R_0'(S_c + I_c - S_\infty). Solving gives S∞=0.40695S_\infty = 0.40695, and the full ODE run ends at 0.406950.40695 too. So 59.3%59.3\% are infected instead of 79.7%79.7\%.

Timing matters. The same cut on day 6060, when the epidemic is almost over (S=0.2159S = 0.2159, I=0.0181I = 0.0181), leaves the peak at 0.15390.1539 and the final size at 0.79030.7903: the intervention came too late to matter.

SEIR: a latent period

After exposure a person is infected but not yet infectious. Add a class EE with rate σ\sigma (mean latent period 1/σ1/\sigma):

S′=−βSI,E′=βSI−σE,I′=σE−γI,R′=γI.S' = -\beta S I, \quad E' = \beta S I - \sigma E, \quad I' = \sigma E - \gamma I, \quad R' = \gamma I.

What does not change. The derivation of the final size used only (ln⁡S)′=−βI(\ln S)' = -\beta I and R′=γIR' = \gamma I, so ln⁡(S0/S∞)=R0(1−S∞)\ln(S_0/S_\infty) = R_0(1 - S_\infty) is unchanged for the same R0=β/γR_0 = \beta/\gamma: latency delays but does not reduce the number infected. In the runs below the final size is 0.7971540.797154 for latent periods of 22 and 44 days alike.

What does. Linearise the (E,I)(E, I) block at S=1S = 1. The matrix (−σβσ−γ)\begin{pmatrix} -\sigma & \beta\\ \sigma & -\gamma\end{pmatrix} has the growth rate

r=12[−(σ+γ)+(σ−γ)2+4σβ],r = \tfrac12\left[-(\sigma + \gamma) + \sqrt{(\sigma - \gamma)^2 + 4\sigma\beta}\right],

which tends to β−γ\beta - \gamma as σ→∞\sigma \to \infty and is smaller otherwise.

latent periodgrowth rate rrpeak IIday of peak
none (SIR)0.20000.20000.15390.153933.833.8
22 days0.12170.12170.10930.109354.554.5
44 days0.09220.09220.08480.084871.171.1
88 days0.06420.06420.05870.0587100.5100.5

(Growth rates from the formula and numpy; peaks from the sim and scipy, agreeing to four digits.) With a four-day latent period the infectious fraction reaches 0.010.01 on day 32.332.3 instead of 11.711.7: slower to start, later and flatter at the peak, the same endpoint.

◆ Interactive SEIR against SIR: drag the latent period and watch the growth rate, the peak height and the peak day, while the final size stays put

Loading simulation…

Births, waning immunity and the endemic state

If the population is replenished the epidemic need not end. Let births and deaths both occur at rate μ\mu (a constant population), with newborns susceptible:

S′=μ−βSI−μS,I′=βSI−(γ+μ)I.S' = \mu - \beta S I - \mu S, \qquad I' = \beta S I - (\gamma + \mu) I.

Now R0=β/(γ+μ)R_0 = \beta/(\gamma + \mu). For R0>1R_0 \gt 1 there is an endemic fixed point. Setting I′=0I' = 0 gives S∗=1/R0S^* = 1/R_0, and S′=0S' = 0 then gives I∗=μ(1−S∗)/(γ+μ)I^* = \mu(1 - S^*)/(\gamma + \mu). The Jacobian there, with βS∗=γ+μ\beta S^* = \gamma + \mu, is

J=(−βI∗−μ−(γ+μ)βI∗0),τ=−μR0,Δ=μ(β−γ−μ).J = \begin{pmatrix} -\beta I^* - \mu & -(\gamma + \mu) \\ \beta I^* & 0\end{pmatrix}, \qquad \tau = -\mu R_0, \quad \Delta = \mu(\beta - \gamma - \mu).

(Since βI∗=μ(R0−1)\beta I^* = \mu(R_0 - 1), the trace is −μ(R0−1)−μ-\mu(R_0 - 1) - \mu, and Δ=βI∗(γ+μ)=βμ(1−S∗)\Delta = \beta I^*(\gamma + \mu) = \beta\mu(1 - S^*).) The determinant is positive whenever R0>1R_0 \gt 1 and the trace is negative, and for small μ\mu we have τ2<4Δ\tau^2 \lt 4\Delta: a stable spiral. The epidemic rings, and the ringing dies out.

With β=0.4\beta = 0.4, γ=0.2\gamma = 0.2 and μ=0.01\mu = 0.01: R0=1.905R_0 = 1.905, S∗=0.525S^* = 0.525, I∗=0.022619I^* = 0.022619, trace −0.019048-0.019048, determinant 0.00190.0019 and eigenvalues −0.009524±0.042536i-0.009524 \pm 0.042536i (sim and numpy). The period of the ringing is 2π/0.042536=147.72\pi/0.042536 = 147.7 days; the long ODE run measures 146.7146.7 between the last two upward crossings before day 600600, the small difference being the nonlinearity of the first cycles. Amplitudes shrink with ee-folding time 105105 days. The first epidemic peaks at 0.14770.1477 on day 35.535.5 (against 0.15390.1539 without births), falls to a trough of 0.00510.0051 and then recovers.

Since Δ=μ(γ+μ)(R0−1)\Delta = \mu(\gamma + \mu)(R_0 - 1), the period is close to 2πAD2\pi\sqrt{A D} where D=1/(γ+μ)D = 1/(\gamma + \mu) is the infectious period and A=1/(μ(R0−1))A = 1/(\mu(R_0 - 1)) is the average age at infection (Anderson and May’s interepidemic period, from memory; here 2πAD=144.12\pi\sqrt{AD} = 144.1). SIRS, with immunity that wanes at rate δ\delta, behaves similarly: it keeps S∗=1/R0S^* = 1/R_0 and an endemic prevalence I∗=(1−1/R0)/(1+γ/δ)I^* = (1 - 1/R_0)/(1 + \gamma/\delta) (algebra from I′=0I' = 0, R′=0R' = 0).

◆ Interactive Endemic SIR: raise mu and watch the oscillation damp faster; the readout compares the measured period with 2 pi over the imaginary part of the eigenvalue

Loading simulation…

What the model leaves out

  • Heterogeneity. Everyone mixes equally. Real contact rates vary enormously, and a few high-contact people drive transmission; this lowers the final size and herd threshold below the formulas above (from memory) and replaces β\beta by a matrix of contact rates.
  • Networks and space. Contacts form a graph with clusters, so early growth is slower and patchier than erte^{rt}.
  • Stochasticity. With II a handful of people, new cases are random. An outbreak with R0=2R_0 = 2 can die out by chance (a branching-process estimate for one seed case is 1/R0=50%1/R_0 = 50\%, from memory), and the model also cannot show endemic fade-out.
  • Fixed parameters. β\beta and γ\gamma change with behaviour and season.

Treat every number here as a property of these equations, not a forecast. The value is calibration: threshold, overshoot, sensitivity to timing.

The exercise: final size by Newton, and the endemic eigenvalues

The playground runs SIR and SEIR with RK4. In the exercise you implement the final-size solver, the peak formula, the endemic point and its eigenvalues; the tests are table entries.

🐍 PythonRK4 on SIR and SEIR: the conserved quantity, the peak and the delay from latency
⌘/Ctrl + Enter
🧪 Coding exerciseExercise: final size, peak prevalence and the endemic eigenvalues
⌘/Ctrl + Enter

Concept checks

✅ Concept check

In the SIR model, at what value of $S$ does the number of infectious people reach its maximum?

✅ Concept check

A disease has $R_0 = 4$. What fraction of the population must be immune (before the outbreak) so that it cannot spread?

✅ Concept check

For $R_0 = 2$ the herd-immunity threshold is $50\%$, but an uncontrolled epidemic infects about $79.7\%$. Why the difference?

✅ Concept check

Compared with SIR with the same $\\beta$ and $\\gamma$, a SEIR model with a four-day latent period has:

✅ Concept checkselect all that apply

Select all true statements about SIR with births and deaths at rate $\mu$ and $R_0 = \beta/(\gamma + \mu) \gt 1$.

Problems

✏️ Pen & paperPeak and final size by hand●○○

Take β=0.3\beta = 0.3, γ=0.1\gamma = 0.1 and an infinitesimal seed (S0=1S_0 = 1, I0→0I_0 \to 0). Find R0R_0, the herd-immunity threshold, the peak prevalence, and use one Newton step from s=e−R0s = e^{-R_0} to estimate S∞S_\infty in ln⁡(1/s)=R0(1−s)\ln(1/s) = R_0(1 - s) (the exact root is S∞=0.0595S_\infty = 0.0595).

Show worked solution

R0=3R_0 = 3, the threshold is 1−1/3=2/31 - 1/3 = 2/3, and the peak is 1−(1+ln⁡3)/3=1−2.0986/3=0.30051 - (1 + \ln 3)/3 = 1 - 2.0986/3 = 0.3005 (at S=1/3S = 1/3). For Newton, s0=e−3=0.04979s_0 = e^{-3} = 0.04979, g(s0)=3−3(1−0.04979)=3(0.04979)=0.14936g(s_0) = 3 - 3(1 - 0.04979) = 3(0.04979) = 0.14936 and g′(s0)=3−1/0.04979=3−20.086=−17.086g'(s_0) = 3 - 1/0.04979 = 3 - 20.086 = -17.086, so s1=0.04979+0.14936/17.086=0.0585s_1 = 0.04979 + 0.14936/17.086 = 0.0585. Repeating once more brings it to 0.05950.0595 (the verified root is 0.059520.05952: 94.05%94.05\% infected, far above the 66.7%66.7\% threshold).

✏️ Pen & paperImperfect vaccine●●○

For R0=4R_0 = 4 a vaccine protects a vaccinated person fully with probability 0.80.8 and not at all otherwise. What coverage vv is needed for herd immunity? What does the answer say about a vaccine that works on half of the people?

Show worked solution

The immune fraction is 0.8 v0.8\,v and must reach 1−1/R0=0.751 - 1/R_0 = 0.75, so v≥0.75/0.8=0.9375v \ge 0.75/0.8 = 0.9375. For efficacy 0.50.5 the requirement is 0.75/0.5=1.5>10.75/0.5 = 1.5 \gt 1: even vaccinating everyone cannot reach the threshold, and the disease persists at a lower level. In general vc=(1−1/R0)/efficacyv_c = (1 - 1/R_0)/\text{efficacy}, which can exceed 100%100\%.

✏️ Pen & paperFinal size with a vaccinated fraction●●○

With a fraction vv vaccinated at the start and I0→0I_0 \to 0, show that ln⁡(S0/S∞)=R0(S0−S∞)\ln(S_0/S_\infty) = R_0(S_0 - S_\infty) with S0=1−vS_0 = 1 - v, and that S∞=S0S_\infty = S_0 (no outbreak) when R0S0≤1R_0 S_0 \le 1.

Show worked solution

From dS/dR=−R0SdS/dR = -R_0 S we get S=S0e−R0(R−v)S = S_0 e^{-R_0 (R - v)}, since the vaccinated start at R=vR = v. At the end R∞=1−S∞R_\infty = 1 - S_\infty, so ln⁡(S0/S∞)=R0(1−v−S∞)=R0(S0−S∞)\ln(S_0/S_\infty) = R_0(1 - v - S_\infty) = R_0(S_0 - S_\infty). Let g(s)=ln⁡(S0/s)−R0(S0−s)g(s) = \ln(S_0/s) - R_0(S_0 - s), so g(S0)=0g(S_0) = 0 and g′(S0)=R0−1/S0g'(S_0) = R_0 - 1/S_0. If R0S0≤1R_0 S_0 \le 1, gg is convex and decreasing on (0,S0](0, S_0], so g>0g \gt 0 below S0S_0 and the only root is S0S_0 itself. If R0S0>1R_0 S_0 \gt 1, then g′>0g' \gt 0 at S0S_0, g<0g \lt 0 just to its left, and a second root S∞<S0S_\infty \lt S_0 exists: the epidemic.

✏️ Pen & paperEndemic oscillation for a faster birth rate●●●

Keep β=0.4\beta = 0.4, γ=0.2\gamma = 0.2 and take μ=0.02\mu = 0.02. Find R0R_0, the endemic point, the trace and determinant of the Jacobian, the eigenvalues and the period of the damped oscillation. Compare the period with the value for μ=0.01\mu = 0.01 (147.7147.7 days).

Show worked solution

R0=0.4/0.22=1.8182R_0 = 0.4/0.22 = 1.8182 and S∗=0.55S^* = 0.55, I∗=0.02×0.45/0.22=0.040909I^* = 0.02 \times 0.45/0.22 = 0.040909. The trace is −μR0=−0.036364-\mu R_0 = -0.036364 and the determinant is μ(β−γ−μ)=0.02×0.18=0.0036\mu(\beta - \gamma - \mu) = 0.02 \times 0.18 = 0.0036. Then τ2−4Δ=0.001322−0.0144=−0.013078<0\tau^2 - 4\Delta = 0.001322 - 0.0144 = -0.013078 \lt 0: a stable spiral with eigenvalues −0.018182±0.057179i-0.018182 \pm 0.057179i (numpy agrees). The period is 2π/0.057179=109.92\pi/0.057179 = 109.9 days, shorter than 147.7147.7 days, and the damping is nearly twice as fast: decay rate 0.01820.0182 against 0.00950.0095.

What comes next

SIR is a reaction network written as differential equations: S+I→2IS + I \to 2I at rate βSI\beta S I and I→RI \to R at rate γI\gamma I. The product S IS\,I is exactly the law of mass action of chemistry, where the rate of A+B→CA + B \to C is proportional to the product of concentrations, and 15.4 Chemical Kinetics & Stiff Systems builds on it: rate constants, equilibrium, Michaelis-Menten saturation. One honest warning. Here β\beta and γ\gamma differ by a factor of two, so RK4 at 0.050.05 days is far from its stability limit. In chemistry rate constants can differ by many orders of magnitude (the Robertson problem, from memory), a fast reaction forces tiny steps long after it has finished, and that is stiffness, see 4.5 Stability Regions & Stiffness.

Key Takeaways

  • SIR with mass action: II grows iff R0S>1R_0 S \gt 1 with R0=β/γR_0 = \beta/\gamma, and peaks when S=1/R0S = 1/R_0; there are no cycles because SS only decreases.
  • Q=I+S−(1/R0)ln⁡SQ = I + S - (1/R_0)\ln S is conserved (checked to 10−1210^{-12}), which gives the peak Imax⁡=I0+S0−(1+ln⁡(R0S0))/R0I_{\max} = I_0 + S_0 - (1 + \ln(R_0 S_0))/R_0.
  • The final size solves the transcendental equation ln⁡(S0/S∞)=R0(1−S∞)\ln(S_0/S_\infty) = R_0(1 - S_\infty), by Newton from the left or bisection: 79.7%79.7\% for R0=2R_0 = 2.
  • The final size overshoots the herd-immunity threshold 1−1/R01 - 1/R_0: infection continues after the peak.
  • Vaccination below the threshold still flattens and delays the epidemic; reducing β\beta helps only if it happens early (day 3030: 59.3%59.3\% infected; day 6060: 79.0%79.0\%).
  • SEIR has the same final size but a smaller growth rate and a lower, later peak (0.08480.0848 on day 71.171.1 for a four-day latent period).
  • With births the endemic point S∗=1/R0S^* = 1/R_0 is a spiral sink with trace −μR0-\mu R_0 and determinant μ(β−γ−μ)\mu(\beta - \gamma - \mu): a damped oscillation of period 147.7147.7 days for μ=0.01\mu = 0.01.
  • The model ignores heterogeneity, networks and chance at small II; the same S IS\,I law reappears as mass action in chemistry.
Finished this lesson?

Mark it complete to track your progress (saved in this browser). Reading every section does this for you.