Solving SIR Model with Euler's Method

Click For Summary
SUMMARY

The discussion focuses on implementing Euler's method to approximate solutions for the SIR model, represented by the differential equations: dS/dt = -βSI, dI/dt = -βSI - γI, and dR/dt = γI. Users are guided to use initial conditions S(0) = 249995/250000 and I(0) = 5/250000, with parameters β = 2 and γ = 0.5, and a time step of 0.25. The conversation emphasizes the sequential calculation of S, I, and R values using Euler's method, ensuring that each subsequent value relies on the previously calculated results.

PREREQUISITES
  • Understanding of the SIR model in epidemiology
  • Familiarity with Euler's method for numerical approximation
  • Basic knowledge of differential equations
  • Proficiency in using MS Excel or MATLAB for simulations
NEXT STEPS
  • Implement Euler's method in MS Excel for the SIR model
  • Explore MATLAB's ode45 function for solving differential equations
  • Research stability analysis of numerical methods in differential equations
  • Learn about the impact of varying time steps on simulation accuracy
USEFUL FOR

Mathematicians, epidemiologists, data scientists, and anyone interested in modeling infectious diseases using numerical methods.

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