MHB Solving SIR Model with Euler's Method

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
 
Mathematics 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)
 
Back
Top