Exercise: the SIR model with Euler, Heun and RK4

Integration of the SIR epidemic system with the three one-step methods on the same mesh, comparing how the method's order visibly changes the results.

The model

The SIR model describes the spread of an infectious disease by splitting the population into susceptible SS, infected II and recovered RR:

{S(t)=βS(t)I(t)I(t)=βS(t)I(t)νI(t)R(t)=νI(t)β,ν>0\begin{cases} S'(t)=-\beta\,S(t)\,I(t)\\ I'(t)=\beta\,S(t)\,I(t)-\nu\,I(t)\\ R'(t)=\nu\,I(t) \end{cases}\qquad \beta,\nu>0

Take β=0.01\beta=0.01, ν=0.5\nu=0.5, initial conditions S(0)=100S(0)=100, I(0)=32I(0)=32, R(0)=5R(0)=5, and study the daily evolution over 10 days: N=10N=10 subintervals on [0,10][0,10] (h=1h=1). It is a three-component vector IVP that all three methods integrate component by component.

Results

tS (Euler)I (Euler)R (Euler)
0100.0032.005.00
235.3656.6445.00
47.9231.5997.49
64.4310.14122.43
83.762.98130.26
103.590.86132.55
Euler's method (h=1h=1).
tS (Heun)I (Heun)R (Heun)
0100.0032.005.00
242.8545.0349.12
420.3228.9787.72
613.3614.86108.78
810.887.09119.02
109.893.30123.82
Heun's method (h=1h=1).
tS (RK4)I (RK4)R (RK4)
0100.0032.005.00
242.4046.7047.89
419.2730.3987.34
612.3815.14109.48
810.026.94120.03
109.113.09124.80
Runge-Kutta 4 method (h=1h=1).