The Stiffness Phenomena for the Epidemiological SIR Model: a Numerical Approach
Latin-American Journal of Computing, vol. 10, no. 2, 2023
Escuela Politécnica Nacional

Latin-American Journal of Computing
Escuela Politécnica Nacional, Ecuador
ISSN: 1390-9266
ISSN-e: 1390-9134
Periodicity: Semestral
vol. 10, no. 2, 2023

Received: 20 January 2023

Accepted: 12 May 2023

Abstract: Mathematical models are among the most successful strategies for predicting the dynamics of a disease spreading in a population. Among them, the so-called compartmental models, where the total population is proportionally divided into compartments, are widely used. The SIR model (Susceptible-Infected-Recovered) is one of them, where the dynamics between the compartments follows a system of nonlinear differential equations. As a result of the non-linearity of the dynamics, it has no analytical solution. Therefore, some numerical methods must be used to obtain an approximate solution. In this contribution, we present simulated scenarios for the SIR model showing its stiffness, a phenomenon that implies the necessity of a small step size choice in the numerical approximation. The numerical results show that the stiffness phenomenon increases with higher transmission rates β and lower birth and mortality rates μ . We compare the numerical solutions and errors for the SIR model using explicit Euler, Runge Kutta, and the semi-implicit Rosenbrock methods and analyze the numerical implications of the stiffness on them. We conclude that any accurate numerical solution of the SIR model will depend on an appropriately chosen numerical method and the time step, in terms of the values of the parameters β , μ .

Keywords: Stiffness, , SIR model, , Numerical Methods.

I. Introduction

Since the pioneering work of Bernoulli [1], mathematical models have proved to be a fundamental tool for predicting the dynamics of infectious diseases. In particular, the recent changes in the UK’s strategies regarding the COVID-19 pandemic [2] strongly collaborate to reaffirm such a claim. It turns out that an enormous number of mathematical models and simulating scenarios were recently proposed and analyzed for the COVID-19 outbreak, making it hard to attempt a complete literature overview. Nevertheless, at the heart of many of these proposed models are SIR-like compartmental models, originally proposed by Kermack & Mckendrick [3]. In other words, unless some compartment clustering (summarizing individuals in distinct compartments) is used, such proposed models assume that at any time t ≥0 of the underlying diseases, the total population N ( t ) = S (t) + I (t) + R (t) is divided into compartments of susceptible S (t) ,infected or infectious I (t) and recovered or removed R (t) .

Using the law of mass action, Kermack & Mckendrick [3] concludes that the diseases must follow the SIR nonlinear dynamics:


where ' : = d d t , β is a disease transmission rate, μ is a birth and mortality rates (that for simplicity we assume to be the same), γ is the inverse of the mean infectious period. We assume that all parameters are time-independent.

In the dynamics (1), the following initial conditions are considered (IC)

S (0) = 1 I(0) , I(0) 0 , R(0) = 0 , (2)

characterizing the model as initial value problems (IVP) for nonlinear systems of ordinary differential equations (ODE’s).

Given the non-linearity, SIR model (1) - (2) does not have an explicit solution. As a result, any attempt to predict disease dynamics must be obtained from some approximation of the solution provided by numerical methods [4]. This necessity of using numerical methods drives the main question of this contribution: Are there some parameter choice scenarios that characterizes the SIR model to be stiff?

The phenomenon of stiffness in a (IVP) means that the numerical solutions are unstable and/or its accuracy is largely affected using any explicit numerical methods. It imposes the need for a very small time step to approximate the solution and, consequently, becomes computationally expensive.

In Section II, we revisit some well-known properties of the solution of the (IVP) of the SIR model. Such properties will help to justify the numerical analysis that follows. In Section III, we present a definition of stiffness. Moreover, we present and compare the obtained results for distinct scenarios of parameter choices for the model. In Section IV, we show the consequences of the stiffness phenomena in the numerical solution of the SIR model using explicit and implicit numerical approximations. The main contribution of this manuscript is the conclusion that the SIR model is indeed stiff, for large transmission rates β . The analysis of the error in the numericla solutions allows us to recommend the use of appropriate numerical methods as well as the time-step size. In Section V, we formulate the final conclusions.

II. Some sir model properties

In this section, we revisit some of the well-known SIR model properties reformulated from [5], that will be used to justify the numerical analysis that follows.

Theorem 1. Let the assumptions for the SIR model (1) with initial conditions (2) hold true. Then, the (IVP) (1) - (2) corresponding to the SIR model have a unique differentiable solution Y(t)= (S(t),I(t),R(t)) t

Since the initial conditions (2) for are non-negative, each of the coordinates of the solution Y(t) remains non-negative for all t ≥ 0

Note that, summing all the equations in models (1), we conclude that the total population is constant. To keep things simple, we will assume that Importar imagen is normalized so that Importar imagen , for all

It follows from the first equation in that is decreasing. Furthermore, we get from Theorem 1 that


As we will see in Section IV, the stiffness phenomena present in the SIR model imply that numerical solutions obtained from an explicit numerical scheme might not satisfy Theorem 1 and equation (3) in particular.

Note that, summing all the equations in models (1), we conclude that the total population is constant. To keep things simple, we will assume that N is normalized so that N(t) = 1 , for all t ≥0 .

It follows from the first equation in that Importar imagen is decreasing. Furthermore, we get from Theorem 1 that


As we will see in Section IV, the stiffness phenomena present in the SIR model imply that numerical solutions obtained from an explicit numerical scheme might not satisfy Theorem 1 and equation (3) in particular.

III. Numerical Methods And Stiffness Phenomena For Sir Model

Let Y(t) be the unique solution of the SIR model (1) - (2) as shown in Theorem 1, whose coordinates will be denoted by Y i (t) for i =1,2,3 respectively. According to [4], the step of a numerical method to obtain the approximation Y n i for the exact solution Y i ( t n ) of the (IVP), for t n = [0,T] , can be written, in general, as follows

where k ≥ 1 is the number of preview steps used to compute Y n i . The values α j , for j =0 , . . ,k are numerical method-specific constants, Importar imagen is the method step-size. The function Importar imagen is defined in terms of evaluating the right-hand side Importar imagen of the system of differential equations (1).

In general terms, we can classify the numerical methods as: Single-step if k=1 , or multi-step if k >1 . Linear if ψ F is linear in the evaluation of F(t,Y(t)) and non-linear otherwise. Implicit if ψ f depends on Y n and explicit otherwise.

In the numerical simulations for the SIR model (1) - (2) that follows, we will adopt the following methods: A) the explicit, single-step Euler method; B) the explicit, single-step Runge-Kutta method; C) the semi-implicit, fourth order, four-stage Rosenbrock method, e.g, [4].

A. The stiffness phenomena

The phenomena of stiffness in solving (IVP) appeared at the beginning of the 20th century. It was [6] one of the first to notice some implicit numerical methods perform better than explicit ones for stiff (IVP). This is because the implicit methods have an unlimited stability region that covers the entire half-plane complex with a negative real part or at least an unlimited part of it, e.g. [4].

A well-accepted definition of the phenomena of stiffness follows:

Definition 1. Let λ j ( t ) , for j = 1,...,n the eigenvalues of the Jacobian matrix J(F(t,Y(t))) , where F ( t , Y ( t ) ) is the right-hand side of the (IVP).

The (IVP) is called stiff in some interval I of the real line if Re( λ j ) < 0 for all j=1,...,n and stiffness ratio

If the (IVP) is stiff, then certain numerical methods for solving the equation become numerically unstable unless the step size is taken to be extremely small. This is the case for most explicit numerical schemes. See [4] for some examples.

B. The stiffness phenomena for SIR model

The Jacobian matrix for model (1) for an arbitrary point is given by

Then, the eigenvalues λ j , j=1,2,3 of the Jacobian matrix are given by

Below, the stiffness ratio for the (IVP) SIR model (1) - (2) is numerically investigated. Table I displays various values of the stiffness ratio ξ (see Definition 1) as a function of β and μ . The numerical results presented in Table I suggest that the SIR model’s rigidity becomes increasingly greater as we increase the β and/or decrease the μ .


Stiffness ratio ξ for SIR model, as a function of β and μ

Before delving into the effect of the stiffness ratio on numerical simulations of the SIR model (1), we should consider the epidemiological implications of the parameters μ and β as shown in Table I.

Remark 1. Small values of μ mean that the birth and mortality rates are very low, in proportion to the total population, during the disease duration. It is a typical effect for a short time simulation. Large values of the transmission rate β have a more debatable epidemiological meaning. However, there are highly contagious diseases such as measles, pertussis, and tuberculosis that are already documented in the literature [7, 8]. Furthermore, many diseases transmission depends on population density (high for high-density populations) and environment (for example, for respiratory transmitted diseases, a crowded and closed environment implies higher transmission rates) [9]. To put it another way, a disease that has not yet been reported may have a higher transmission rate than those already reported.

IV. Numerical Results

In this section, we present numerical simulated results and show the implications of the stiffness ratio (see the stiff ration in Table I on the numerical approximated solutions for the SIR model. We present the simulations using e explicit Euler method, the two-stage and second-order Runge-Kutta method (RK22), the four-stage and fourth-order Runge-Kutta method (RK44) and Rosenbrock method [4]. In the simulation, the step-size h=0.1 is used for all the methods except for the Rosenbrock method, for which the adaptive step-size is used [4]. The inicial conditions S o = 0.9 , I 0 = 0.1 and R o = 0 are used and the parameter γ =0.35 is keeped fixed. The above mentioned methods are implemented in Fortran 90 with a double precision, GNU Fortran Compiler (Ubuntu 18.04.5 LTS operational systema 64 bits) and running in a processor IntelR Core (TM)i5-5200U CPU@2.20GHzx4

Fig. 1. Simulated scenarios for the infected populations I(t)
(a) Simulated scenarios using the Euler method.

Simulated scenarios using the RK22 method.

Simulated scenarios using the RK44 method.

Simulated scenarios using the Rosenbrock method

In Fig. 1, we show the simulated scenarios of the infected population, for choices of β and values of β = 0.5, 1.5, 5.0, 10, 12, 18, 25, respectively. In the simulation with the Rosenbrock method, the adaptive step-size, typically of the method, is used. The simulations for the remaining methods use the step-size h=0.1.

For the simulated scenario with β = 25 , the first and most obvious consequences of the stiffness phenomenon can be seen. In this particular scenario, the approximate solution using the Euler method oscillates as shown in Fig. 1(a). The oscillations disappear in the numerical solutions using the RK22, RK44 and Rosenbrock methods, as can be observed in Fig. 1(b), Fig. 1(c) and Fig. 1(d).

Fig. 2.
Simulated scenarios using the numerical methods for B=25.
(a) Susceptible population S(t).

(b) Infected population I(t)

A zoom on the numerically simulated scenario for β = 25 of the susceptible and infected is depicted in Fig. 2 (a) and Fig. 2(b), respectively, using all the numerical methods under investigation. It turns out that the oscillations of the numerical solutions obtained by the explicit Euler method produce negative values for the susceptible (see Fig. 2 (a)) and values larger than 1 for the infected population (see Fig. 2 (b)), which contradicts Theorem 1. Moreover, the simulated scenarios using the RK22 and RK44 methods present non-smooth solutions and hence also contradict Theorem 1. It can be observed in the simulated results that only the Rosenbrock method, the method designed for stiff problems [4], presents an approximate solution that satisfies Theorem 1.

The remaining question addressed in this contribution is whether the stiffness phenomenon for the SIR model appears only for very large β

The simulated solution for the susceptible and infected population, with the choice of β = 12 ,is depicted in Fig.3(a) and Fig. 3(b, using the Euler method with step-size h = 0.1 (see Fig. 3(a)).

Fig. 3. Simulated scenarios using the numerical methods of Euler and Rosenbrock for B=12.
(a) Susceptible population.

(b) Infected population.

In Fig. 4(a), we show the values for the step-sizes used by the Rosenbrock method with adaptive step for the simulated scenarios with β = 12 . It is worth mentioning that a small step-size is needed in the regions close to the peak of infection; that coincides with the region of the large discrepancies between the two methods presented in (see Fig. 3). In Fig. 4(b), we depicted the numerical solutions for the susceptible and infected populations using the Euler and Rosenbrock methods with the smallest step-size h = 0.0027 adopted by the Rosenbrock method. As a result of using a very small step-size, the Euler method shows a more accurate numerical solution. Indeed, it is a consequence of the stiffness of the SIR model.

Fig. 4. h variable (a); Simulated solutions of S(t) and I(t) using the Euler method with h = 0.0027 and Rosenbrock method (b).
(a) Adaptive step-size h used by the Rosenbrock method.

(b) Numerical solutions obtained for of S(t) and I(t) by the Euler and Rosenbrock methods using the step-size h = 0.0027 for β = 12.

Table II and Table III show the difference in the maximum and quadratic norm of the simulated infected population using the methods discussed in this contribution for different scenarios of β .

The difference between the numerical solutions of the infected population using the Euler and Rosenbrock methods with step-size h = 0.1 is depicted in Fig. 5 for some scenarios of choice for β . The absolute value of the difference is monotonically increases with β , as shown in the second column of Table II. The difference is approximately 10% n in absolute value for β = 10 , 20% in absolute values for β = 18 , and 40% in absolute values for β =25 .

The difference between the numerical solutions of the infected population using the RK44 and Rosenbrock methods with step-size h = 0.1 is depicted in Fig. 6 for some scenarios of choices of β . As it can be seen from the results in the fourth column of Table II, the difference is significant only for β = 25 (see also Fig. 5(d)).

Based on the results in Fig. 5, Fig. 6 and the one in the Table II and Table III, we can conclude that as the stiffness of the SIR model increases (as β increases), the absolute difference between the Euler or RK44 and Rosenbrock methods becomes concentrated near the infection’s peak. The results show that the stiffness of the SIR model suggests using a small numerical step-size or a method designed for solving stiff problems, such as the Rosenbrock method.



Fig. 6.
Difference between the numerical solution of the infected population using RK44 and Rosenbrock methods with step-size h = 0.1. Simulated scenarios with distinct choices of β.

(a) β = 0.5

(b) β = 1.5

(c) β = 18

(d) β = 25
(d) β = 25


In this work, we numerically investigate the stiffness phenomena for the epidemiological SIR model. The simulated scenarios presented show that the stiffness ratio of the SIR model becomes more pronounced as the disease contagion rate increases or the rate of birth/mortality approaches zero. However, the numerical findings indicate that the explicit numerical method have more difficulties to obtain a numerical solution satisfying Theorem 1 as β increases. In particular, the stiffness phenomena imply that the numerical solution using explicit methods, such as Euler and the RK, does not agree with the theoretical results on Theorem 1, while the semi-implicit Rosenbrock method does agree with the theoretical results. The analysis of the maximum and quadratic difference between the analyzed explicit methods and the Rosenbrock method becomes large near the peak of the infection. As a result, the explicit methods overestimate the peak of infection.

We also demonstrate how to use the Rosenbrock method to determine an optimal step-size in terms of β to use in the explicit numerical method, resulting in a more accurate numerical solution for the SIR model. This step-size can be used in explicit methods, e.g., the Euler’s method, which is a good alternative to reduce the computational cost.

The results obtained in this contribution collaborate with the following conjecture regarding the use of explicit numerical methods for the SIR model: For a given β choose h such that β h < 0.1 . It will be investigated in detail in future contributions.


[1] D. Bernoulli, “Essai D’une Nouvelle Analyse de la Mortalité Causée par la Petite Vérole, et Désavantages de L’inoculation Pour la Prévenir, Histoire de l’Acad., Roy. Sci., Paris, pp. 1-45, 1760.

[2] N. M. Ferguson, D. Laydon, G. Nedjati-Gilani and et al., “Impact of Non-pharmaceutical Interventions (NPIs) to Reduce COVID-19 Mortality and Healthcare Demand”, Imperial College COVID-19 Response Team, London, pp. 1-20, 2020.

[3] W.O. Kermack, and A. G. Mckendrick, “A Contribution to the Mathematical Theory of Epidemics”, Proceedings of the Royal Society of London, London, vol. 115, pp. 700-721, 1927.

[4] J. D. Lambert, “Numerical Methods for Ordinary Differential Systems: The Initial Value Problem”, 1st ed., New York: Wiley, 1991.

[5] H. W. Hethcote, “The Mathematics of Infectious Diseases”, SIAM review, vol. 42, pp. 599-653, 2000.

[6] C. F. Curtiss, and J. O. Hirschfelder, “Integration of Stiff Equations”, Proceedings of the National Academy of Sciences of the United States of America, vol. 38, pp. 235–243, 1952.

[7] J. Kumate, “Infectious Diseases in the 21st Century”, Archives of Medical Research, vol. 28, pp. 155-161, 1997.

[8] I. F. Souza, “Queda nas Taxas de Cobertura Vacinal e Recrudescimento do Sarampo no Brasil: Revisão de Literatura. 2021”, Anais. Bauru: Faculdade de Odontologia de Bauru, Universidade de São Paulo. Available: [Accessed: Aug. 05, 2022], 2021.

[9] J. C. Marques, A. De Cezaro, and M. J. Lazo, “A SIR Model with Spatially Distributed Multiple Populations Interactions for Disease Dissemination”. Trends in Computational and Applied Mathematics - SBMAC, vol. 23, pp. 143-154, 2022.

Ir a la Página
Non-profit publishing model to preserve the academic and open nature of scientific communication
Scientific article viewer generated from XML JATS4R