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 , infected and recovered :
Take , , initial conditions , , , and study the daily evolution over 10 days: subintervals on (). It is a three-component vector IVP that all three methods integrate component by component.
Results
| t | S (Euler) | I (Euler) | R (Euler) |
|---|---|---|---|
| 0 | 100.00 | 32.00 | 5.00 |
| 2 | 35.36 | 56.64 | 45.00 |
| 4 | 7.92 | 31.59 | 97.49 |
| 6 | 4.43 | 10.14 | 122.43 |
| 8 | 3.76 | 2.98 | 130.26 |
| 10 | 3.59 | 0.86 | 132.55 |
| t | S (Heun) | I (Heun) | R (Heun) |
|---|---|---|---|
| 0 | 100.00 | 32.00 | 5.00 |
| 2 | 42.85 | 45.03 | 49.12 |
| 4 | 20.32 | 28.97 | 87.72 |
| 6 | 13.36 | 14.86 | 108.78 |
| 8 | 10.88 | 7.09 | 119.02 |
| 10 | 9.89 | 3.30 | 123.82 |
| t | S (RK4) | I (RK4) | R (RK4) |
|---|---|---|---|
| 0 | 100.00 | 32.00 | 5.00 |
| 2 | 42.40 | 46.70 | 47.89 |
| 4 | 19.27 | 30.39 | 87.34 |
| 6 | 12.38 | 15.14 | 109.48 |
| 8 | 10.02 | 6.94 | 120.03 |
| 10 | 9.11 | 3.09 | 124.80 |