Solving SIR Model with Euler's Method

In summary, to implement Euler's method for approximating solutions for the system of differential equations of the SIR model, we use the algorithm: \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}where $t_{n+1} = t_0 + n\cdot h$ and $h$ is the step size. We can use this algorithm in MS Excel or MATLAB by filling in the initial
  • #1
tomc612
17
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
  • #2
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)
 
  • #3
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:
  • #4
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$$
 
  • #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
 
  • #6
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$.
 
  • #7
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?
 
  • #8
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)
 

FAQ: Solving SIR Model with Euler's Method

What is the SIR model?

The SIR model is a mathematical model used to study the spread of infectious diseases in a population. It divides the population into three groups: susceptible, infected, and recovered.

What is Euler's Method?

Euler's Method is a numerical method used to approximate solutions to differential equations. It uses small time steps to calculate the next value based on the previous value and the derivative at that point.

How is Euler's Method used to solve the SIR model?

Euler's Method is used to calculate the change in the number of susceptible, infected, and recovered individuals over time in the SIR model. It uses the differential equations that describe the model to approximate the values at each time step.

What are the limitations of using Euler's Method to solve the SIR model?

Euler's Method is a simple and easy to use method, but it has limitations. It assumes a constant rate of change and does not take into account external factors that may affect the spread of the disease. It also does not account for changes in behavior or interventions that may impact the spread of the disease.

How can the accuracy of Euler's Method for solving the SIR model be improved?

The accuracy of Euler's Method can be improved by using smaller time steps and a smaller interval for the initial values. It can also be improved by using more advanced numerical methods such as the Runge-Kutta method. Additionally, incorporating real-world data and adjusting the parameters in the model can also improve its accuracy.

Similar threads

Replies
38
Views
11K
Replies
1
Views
2K
Replies
1
Views
1K
Replies
2
Views
3K
Back
Top