Solving SIR Model with Euler's Method

Click For Summary

Discussion Overview

The discussion revolves around implementing Euler's method to approximate solutions for the SIR model, which consists of a system of ordinary differential equations (ODEs). Participants explore how to apply this numerical method in software like Excel or MATLAB, given specific initial conditions and parameters.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Homework-related

Main Points Raised

  • One participant asks whether matrix/linear algebra is necessary to produce a generic solution for the SIR model equations before applying Euler's method.
  • Another participant explains the form of Euler's method and provides the algorithm for approximating the system of equations.
  • A participant shares specific initial values for S and I, along with values for β and γ, and attempts to calculate S using Euler's method.
  • There is a clarification regarding the calculation of the next time step and the need to update all variables (S, I, R) sequentially.
  • Participants discuss how to handle the dependencies between S, I, and R when calculating subsequent values.

Areas of Agreement / Disagreement

Participants generally agree on the application of Euler's method and the sequential calculation of values, but there are uncertainties regarding the initial conditions and how to handle the dependencies between the variables.

Contextual Notes

Some participants express confusion about the need for linear algebra and how to manage the dependencies between the variables in the SIR model equations. The discussion does not resolve these uncertainties.

tomc612
Messages
17
Reaction score
0
Question on SIR Model and using Eulers method for approximating a solution.

Given the 3 ODEs of the SIR model

dS/dt = -\betaSI

dI/dt= -\betaSI - \gammaI

dR/dt = \gammaI

Ive been asked to produce in excel Eulers method for axproximate solutions. Given some initial values for S(0) and I(0) as well values for the constants for \beta and \gamma, and increments of time (t)

What I would like to know, is do I need to use Matrix/Linear Algebra to produce a generic solution for the system of equations? is this then used with Eulers method?

If not how do I use Eulers method when the equations have a product if S and I

See below for the actual questionImplement Euler's method in MS Excel or MATLAB to produce approximate solutions
for the system of di erential equations of the SIR model. Use initial conditions of S(0) =
S0 = 249995=250000 and I(0) = I0 = 5=250000, with = 2 and
= 0:5. Use a time
step of 0.25 to ensure the graphs display a smooth curve. Iterate Euler's method for the
duration of the epidemic (halt the simulation when In approaches zero). Plot S; I and R
against time.

any help appreciated
 
Physics news on Phys.org
tomc612 said:
Question on SIR Model and using Eulers method for approximating a solution.

Given the 3 ODEs of the SIR model

dS/dt = -\betaSI

dI/dt= -\betaSI - \gammaI

dR/dt = \gammaI

Ive been asked to produce in excel Eulers method for axproximate solutions. Given some initial values for S(0) and I(0) as well values for the constants for \beta and \gamma, and increments of time (t)

What I would like to know, is do I need to use Matrix/Linear Algebra to produce a generic solution for the system of equations? is this then used with Eulers method?

If not how do I use Eulers method when the equations have a product if S and I

See below for the actual questionImplement Euler's method in MS Excel or MATLAB to produce approximate solutions
for the system of di erential equations of the SIR model. Use initial conditions of S(0) =
S0 = 249995=250000 and I(0) = I0 = 5=250000, with = 2 and
= 0:5. Use a time
step of 0.25 to ensure the graphs display a smooth curve. Iterate Euler's method for the
duration of the epidemic (halt the simulation when In approaches zero). Plot S; I and R
against time.

any help appreciated

Hi tomc612,

Euler's method is to approximate an equation of the form:
$$\mathbf y'(t) = \mathbf f(t, \mathbf y(t))$$
with the algorithm:
$$\mathbf y_{n+1} = \mathbf y_n + h \mathbf f(t_n, \mathbf y_n)$$
where $t_n = t_0 + nh$, and $h$ is the step size.

In your case we have:
$$\mathbf y(t) = \begin{pmatrix}S(t)\\I(t)\\R(t)\end{pmatrix}
$$
so
$$\mathbf y'(t) = \mathbf f(t, \mathbf y(t)) = \begin{pmatrix}-\beta S(t)I(t)\\-\beta S(t)I(t) - \gamma I(t) \\ -\gamma I(t)\end{pmatrix}
$$
In this case Euler's method is:
\begin{cases}
S_{n+1} = S_n + h \cdot -\beta S_n I_n \\
I_{n+1} = I_n + h \cdot (-\beta S_n I_n - \gamma I_n) \\
R_{n+1} = R_n + h \cdot -\gamma I_n
\end{cases}
When we fill in the initial conditions, and perhaps some arbitrary values for $\beta$ and $\gamma$, then we can calculate a number of iterations. (Thinking)
 
Hi,
thanks for the info.

To input values to the formulas.. with the example of S..

S(0)= {S}_{0} = 3
I(0) = I{S}_{0}= 5
h= 0.5
\beta=1
\gamma=2

Sn+1 = Sn +(h.-\betaSnIn)

Sn+1 = 3 +(0.5.-1.3.5)

Sn+1 = -4.5

Is that right? Thanks
 
Last edited:
Yep, although it should be $S_1=-4.5$.

And we have:
$$t_{n+1} = t_0 + n\cdot h \\
t_1 = 0 + 1\cdot 0.5 = 0.5$$
 
Thanks..

So to graph that function, you would then input the {S}_{1} result back into the formula. How do we produce the result when the formula requires the subsequent I value? Or does n value for I remain at a constant?

Thanks
 
tomc612 said:
Thanks..

So to graph that function, you would then input the {S}_{1} result back into the formula. How do we produce the result when the formula requires the subsequent I value? Or does n value for I remain at a constant?

Thanks

Similar to calculating $S_1$, we should calculate $I_1$ and $R_1$.
After that we can use them to calculate $S_2$.
 
And that's calculated by using the {I}_{n+1} formula with to obtain that result?

and then the results for S and I are inputted to each of the formulas sequentially? And then the same for the R formula?
 
tomc612 said:
And that's calculated by using the {I}_{n+1} formula with to obtain that result?

and then the results for S and I are inputted to each of the formulas sequentially? And then the same for the R formula?

Exactly! (Nod)
 

Similar threads

  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 5 ·
Replies
5
Views
10K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 16 ·
Replies
16
Views
3K
  • · Replies 38 ·
2
Replies
38
Views
11K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 15 ·
Replies
15
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K