Chapter 5
Modeling with Differential Equations





Project 2: The SIR Model of the Spread of Disease


Euler's Method for Systems

In this section we develop a numerical method for solving the system of three equations with initial conditions just obtained.

Recall the idea of Euler's Method: If we have a "slope formula," i.e., a way to calculate \(dy/dt\) at any point \((t,y)\), then we can generate a sequence of \(y\)-values,

\(y_0, y_1, y_2, y_3, \ldots\)

by starting from a given \(y_0\), and computing each rise as slope \(\times\) run. That is,

\(y_n = y_{n-1} + \text{slope}_{n-1} \Delta t\),

where \(\Delta t\) is a suitably small step size in the time domain.

It really doesn't matter in this calculation if the slope formula happens to depend not just on \(t\) and \(y\) but on other variables, say \(x\) and \(z\) — as long as we know how \(x\) and \(z\) are related to \(t\) and \(y\). If \(x\) and \(z\) happen to be other dependent variables in a system of differential equations, we can generate values of \(x\) and \(z\) in the same way.

Of course, for the SIR model, we want the dependent variable names to be \(s\), \(i\), and \(r\). More specifically, given the differential equations,

\(\frac{ds}{dt}\) \(=-b\,s(t)\,i(t)\),
\(\frac{di}{dt}\) \(=b\,s(t)\,i(t)-k\,i(t)\),
\(\frac{dr}{dt}\) \(=k\,i(t)\),

the Euler formulas become

\(s_n=\) \(s_{n-1}-b\,s_{n-1}i_{n-1}\Delta t\),
\(i_n=\) \(i_{n-1}+\left(b\,s_{n-1}i_{n-1}-k\,i_{n-1}\right)\Delta t\),
\(r_n=\) \(r_{n-1}+k\,i_{n-1}\Delta t\).

Of course, to calculate something from these formulas, we must have explicit values for \(b\), \(k\), \(s(0)\), \(i(0)\), \(r(0)\), and \(\Delta t\). Here we explore the adequacy of these formulas for generating solutions of the SIR model. Click the button below to generate graphical solutions of the SIR equations, starting from \(s(0) = 1\), \(i(0) = 1.27 \times 10^{-6}\), and \(r(0) = 0\), with sample values of \(b\) and \(k\), which you may change.

The solid-line graphs show "exact" solutions of the SIR equations (actually, numerical solutions generated by a much more accurate method), and the dashed-line graphs show the Euler solutions for the selected \(\Delta t\), starting with the relatively coarse step size of \(\Delta t = 10\) days.

  1. Do you think the Euler solutions closely track true solutions of the system? Why or why not? What characteristic of Euler's Method causes the approximate solutions to behave the way they do?

  2. Change the step size to \(1\) day and replot the Euler solutions. Now do they closely track true solutions of the system? Why or why not?

  3. Find a step size for which the Euler solutions appear to closely track true solutions of the system.

On the next page we will experiment with changes in the parameters \(b\) and \(k\).

Go Back One Page Go Forward One Page

Go to Contents for Chapter 2Contents for Chapter 5