# A Quantitative Comparison of Numerical Method for Solving Stiff Ordinary Differential Equations

Authors: S. A. M. Yatim; Z. B.  Ibrahim; K. I. Othman; M. B. Suleiman
Journal: Mathematical Problems in Engineering
 (2011)

---

## Abstract

We derive a variable step of the implicit block methods based on the backward differentiation formulae (BDF) for solving stiff initial value problems (IVPs). A simplified strategy in controlling the step size is proposed with the aim of optimizing the performance in terms of precision and computation time. The numerical results obtained support the enhancement of the method proposed as compared to MATLAB's suite of ordinary differential equations (ODEs) solvers, namely, ode15s and ode23s.


---

## Body

## 1. Introduction

Consider the first-order ordinary differential equations in the form of(1.1)y′=f(x,y)
with given initial values y(a)=y0 in the given interval x∈[a,b]. The system of (1.1) is said to be stiff if the eigenvalues of the matrix ∂f(x,y)/∂y have negative real parts at every time x and varies greatly in magnitude. Solving stiff ODEs which aroused from mainly applied problems, for example, from physical, chemical, and biological phenomena is made easy with several methods of interest appeared in subroutine libraries [1]. Some examples can be seen in [2–4].  From the code pioneered by Gear called DIFSUB, the wide interest in stiff ODEs has caused many other codes evolved to meet the same objective of finding the most accurate approximation for IVPs [5]. Some renowned codes are EPISODE and LSODE [5]. With the advancements of the existing methods of solving ODEs, many of these codes are preinstalled in MATLAB to work as numerical solvers. An overview of MATLAB’s numerical solvers presented in [2] shows a wide choice of solvers according to the problem type, step, and order to deal with stiff and nonstiff problems. Since then, several measures have been brought up by many researchers to evaluate which method turns out to be the most efficient method [6]. Despite that there exist some limitations in each method, these methods proven to have their own strength in solving certain initial value problems [1].The need to solve large systems of stiff IVPs has also influenced the development of other existing method. These include iterative linear equation solvers and sparse direct linear equation solvers. Further discussion and additional references on this method are discussed in more detail in [2]. The method that incorporated with BDF proposed by Gear has been expanded gradually to become an improved method [7].  The study on producing block approximations yn+1,yn+2,yn+3,…,yn+k also known as block backward differentiation formulae (BBDF) [7] was inspired by Gear’s method. BBDF method in [7] has verified the competency of computing concurrent solution values at different points. Apart from that, block approximations have been used in different methods to improve the methods to give a better accuracy and computation time. Consequently, the study by Ibrahim et al. in [8] is extended in a way that the accuracy is improved with reduction of total steps and lesser computational time.In the next section, we discuss the derivation of the 5th-order variable step block backward differentiation formulae (5oBBDF). The strategies and implementations are presented next, followed by the results and discussion. It is also one of the main aims of this paper to prove that the method proposed acts as an alternative way in solving IVPs which arise in engineering and applied sciences. We are interested to compare the numerical results obtained with stiff ODEs solvers provided by MATLAB, namely, ode15s and ode23s.


## 2. General 5oBBDF Formulation

The ratio distance between current(xn) and previous step (xn-1) is represented as q in Figure 1. In this paper, the step size is given selection to decrease to half of the previous steps or increase up to a factor of 1.9. For simplicity, q is assigned as 1,2 and 10/19 for the case of constant, halving, and increasing the step size, respectively. The zero stability is achieved for each of these cases and explained in the next section.Figure 1
5th order block method of variable step size.We find approximating polynomialsPk(x) by means of a k-degree polynomial interpolating the values of y at given points are (xn-2,yn-2),(xn-1,yn-1),…,(xn+2,yn+2),
(2.1)Pk=∑j=0ky(xn+1-j)⋅Lk,j(x),
where
(2.2)Lk,j(x)=∏i=0i≠jk(x-xn+1-i)(xn+1-j-xn+1-i)foreachj=0,1,…,k.
Define s=(x-xn+1)/h to find the 4th-order interpolating polynomial for (2.1),
(2.3)P(x)=P(xn+1+sh)=(2q+1+s)(q+1+s)(1+s)(s)4(q+1)(q+2)yn+2+(2q+1+s)(q+1+s)(1+s)(s-1)-(q+1)(2q+1)yn+1+(2q+1+s)(q+1+s)(s)(s-1)4q2yn+(2q+1+s)(1+s)(s)(s-1)-q2(q+1)(q+2)yn-1+(q+1+s)(1+s)(s)(s-1)4q2(2q+1)(q+1)yn-2s is equated to 0 and 1 after the polynomial is differentiated with respect to s, when x=xn+1andx=xn+2, respectively,
(2.4)hfn+1=1+2q2+3q4(q+1)(q+2)yn+2+2+3q(q+1)(2q+1)yn+1+-1-2q2-3q4q2yn+1+2qq2(q+1)(q+2)yn-1+-1-q4q2(2q+1)(q+1)yn-2,hfn+2=10+3q2+12q2(q+1)(q+2)yn+2+-4q2-12q-8(q+1)(2q+1)yn+1+2+q2+3q2q2yn+-4q-4q2(q+1)(q+2)yn-1+q+22q2(2q+1)(q+1)yn-2.
Upon substituting q=1,2 and 10/19 into P′(xn+1) and P′(xn+2), we obtained the coefficients for points yn+1 and yn+2 as follows:
(2.5)forq=1,yn+1=65hfn+1-310yn+2+95yn-35yn-1+110yn-2,yn+2=1225hfn+1+4825yn+2-3625yn+1625yn-1-325yn-2,forq=2,yn+1=158hfn+1-75128yn+2+225128yn-25128yn-1+3128yn-2,yn+2=1223hfn+2+192115yn+1-1823yn+323yn-1-2115yn-2,forq=10/19,yn+1=11311292hfn+1-1470382688yn+2+1279161516800yn-183027108800yn-1+1046927200yn-2,yn+2=13923095hfn+2+8908840235yn+1-24220877375yn+19891177375yn-1-6584641005875yn-2.


## 3. Implementation of 5oBBDF Method

It is commonly known that stiff ODEs codes must solve both nonlinear and linear systems at each step of differentiation. This is due to implicity of the formulae for solving stiff IVPs. Throughout this section, we illustrate the effect of Newton-type scheme to find the approximation solutions ofyn+1 and yn+2  simultaneously in every step. The general forms of the 5th-order BBDF method are
(3.1)yn+1=α1hfn+1+θ1yn+2+ψ1,yn+2=α1hfn+2+θ1yn+1+ψ2
with ψ1 and ψ2 are the back values. Equation (3.1) in matrix-vector form is equivalent to
(3.2)(I-A)Yn+1,n+2=hBFn+1,n+2+ξn+1,n+2.
By setting  I=[1001], Yn+1,n+2=[yn+1yn+2], A=[0θ1θ20], B=[α100α2], Fn+1,n+2=[fn+1fn+2], and ξn+1,n+2=[ψ1ψ2], (3.1) is simplified as
(3.3)f̂n+1,n+2=(I-A)Yn+1,n+2-hBFn+1,n+2-ξn+1,n+2=0.
Newton iteration is performed to the system f̂n+1,n+2=0, by taking the analogous form
(3.4)Yn+1,n+2(i+1)-Yn+1,n+2(i)=-[(I-A)-hB∂F∂Y(Yn+1,n+2(i))]-1(I-A)Yn+1,n+2(i)-hBF(Yn+1,n+2(i))-ξn+1,n+2,
where Jn+1,n+2=(∂F/∂Y)(Yn+1,n+2(i)) is the Jacobian matrix of F with respect to Y. Equation (3.4) is separated to three different matrices denoted as
(3.5)E1,2(i+1)=Yn+1,n+2(i+1)-Yn+1,n+2(i),(3.6)Â=(I-A)-hB∂F∂Y(Yn+1,n+2(i)),(3.7)B̂=(I-A)Yn+1,n+2(i)-hBF(Yn+1,n+2(i))-ξn+1,n+2.Two-stage Newton iteration is now introduced in order to find the approximate solution to (1.1). Thus, the corresponding linear system to be solved is ÂE1,2(i+1)=B̂. According to Jackson in [9], evaluating the Jacobian Jn+1,n+2 and LU factorization of Â require the most computation time during the operations. As a result, two strategies which are based on the step size are applied to ensure the efficiency of the method:(i)
no calculation of new matricesÂ and B̂ if the step size h remains as previous step size. Hence, there is no new calculation of the Jacobian matrix Jn+1,n+2,(ii)
the matricesÂ and B̂ are updated with new evaluation of the Jacobian matrix Jn+1,n+2 for every occurrence of changing step size.As a result, this paper agrees with [10] that this method has a higher tendency in saving computational time. Unlike most modern solvers that incorporated full Newton iterations, 5oBBDF method offers refined strategy for reevaluating the Jacobian matrix Jn+1,n+2.


### 3.1. Stability Conditions for 5oBBDF

In this section, we provide the conditions for the stability of 5oBBDF method as in (2.5). To begin with, we include some definitions to support the practical criterion for a method to be useful in solving ODEs.Definition 3.1.
A method is said to be zero stable if the roots of the polynomialρ(z)=π(z,0) satisfy the condition z1=1≤|z2|,z2≠1.Definition 3.2.
A method is said to be absolute stable in a regionR for a given hλ if for that hλ, all the roots rs of the stability polynomial π(r,hλ)=ρ(r)-hλσ(r)=0 satisfy |rs|<1, s=1,2,…,k.The stability polynomial,R(t,ĥ), associated with the method of (2.5) is given by det(At2-Bt-C), while the absolute stability region of this method in the hλ plane is determined by solving det(At2-Bt-C=0). Below are the absolute stability regions in the method of (2.5) for different step size selections: (q=1)(q=2) and (q=10/19), respectively,
(3.8)R(t,ĥ)=197125t4-4225t4h-153125t3-925t2+72125t4h2-252125t3h-18125t2h+1125t=0,R(t,ĥ)=9146t4-441184t4h-17392t3-2892944t2+4546t4h2-1155736t3h-392t2h+12944t=0,R(t,ĥ)=1393273999685t4-52989093998740t4h-42149421199937000t3-544951521420920000t2+393588999685t4h2-1398292623399874000t3h-7537681315375t2h+47045881420920000t=0.
To determine for zero stable, we substitute ĥ=hλ=0 to (3.8). We will have the following equations for each step size selection mentioned previously:
(3.9)197125t4-153125t3-925t2+1125t=0,9146t4-17392t3-2892944t2+12944t=0,1393273999685t4-42149421199937000t3-544951521420920000t2+47045881420920000t=0.
Hence, the roots for three different step size selections obtained by using Maple are listed below(1)
t=-.24414201370,t=0.02079175991, and t=1,(2)
t=-0.052708171410,t=0.003257621961, and t=1,(3)
t=-0.93455113330,t=0.08581158625, and t=1.Since all of the roots have modulus less than or equal to 1, the method (2.5) when (q=1)(q=2) and (q=10/19) is zero stable.The stability region was given by the set of points determined by the boundaryt=eiθ,0≤θ≤2π. The stability region is obtained by finding the region for which |t|<1. Figure 2 shows the stability for the cases (q=1)(q=2) and (q=10/19), respectively. The stability regions lie outside the closed region for each case.Figure 2
Stability regions whenq=1, q=2, and q=10/19.Based on Figure2, the 5th-order BBDF possesses the region absolute stability, which contains almost whole of the half-plane Re(hλ)<0.


### 3.2. Choosing Step Size

The importance in choosing the step size is to achieve reduction in computation time and number of iterations. Therefore, this paper proposed three basic strategies for the step size selections. For each successful step, the step size remains constant(q=1) or increased by a factor of 1.9 (q=10/19). Inversely, when a fail step occurs, the next step size will be halved of the previous step size (q=2). The user initially will have to provide an error tolerance limit, TOL on any given step, and obtain the local truncation error (LTE) for each iteration.  The LTE is obtained from
(3.10)LTE=yn+2(k+1)-yn+2(k),k=4,
where yn+2(k+1) is the (k+1)th order method, and yn+2(k) is the kth order method.The successful step is dependent on the conditionLTE<TOL. If this condition fails, the values of yn+1, yn+2 are rejected, and the current step is reiterated with step size selection (q=2). On the contrary, the step size increment for each successful step is defined as
(3.11)hnew=c×hold×(TOLLTE)1/p.And ifhnew>1.9×hold, then hnew=1.9×hold. Where c is the safety factor, p is the order of the method, while hold and hnew are the step size from previous and current blocks, respectively. In this paper,c is set to be 0.8.


## 3.1. Stability Conditions for 5oBBDF

In this section, we provide the conditions for the stability of 5oBBDF method as in (2.5). To begin with, we include some definitions to support the practical criterion for a method to be useful in solving ODEs.Definition 3.1.
A method is said to be zero stable if the roots of the polynomialρ(z)=π(z,0) satisfy the condition z1=1≤|z2|,z2≠1.Definition 3.2.
A method is said to be absolute stable in a regionR for a given hλ if for that hλ, all the roots rs of the stability polynomial π(r,hλ)=ρ(r)-hλσ(r)=0 satisfy |rs|<1, s=1,2,…,k.The stability polynomial,R(t,ĥ), associated with the method of (2.5) is given by det(At2-Bt-C), while the absolute stability region of this method in the hλ plane is determined by solving det(At2-Bt-C=0). Below are the absolute stability regions in the method of (2.5) for different step size selections: (q=1)(q=2) and (q=10/19), respectively,
(3.8)R(t,ĥ)=197125t4-4225t4h-153125t3-925t2+72125t4h2-252125t3h-18125t2h+1125t=0,R(t,ĥ)=9146t4-441184t4h-17392t3-2892944t2+4546t4h2-1155736t3h-392t2h+12944t=0,R(t,ĥ)=1393273999685t4-52989093998740t4h-42149421199937000t3-544951521420920000t2+393588999685t4h2-1398292623399874000t3h-7537681315375t2h+47045881420920000t=0.
To determine for zero stable, we substitute ĥ=hλ=0 to (3.8). We will have the following equations for each step size selection mentioned previously:
(3.9)197125t4-153125t3-925t2+1125t=0,9146t4-17392t3-2892944t2+12944t=0,1393273999685t4-42149421199937000t3-544951521420920000t2+47045881420920000t=0.
Hence, the roots for three different step size selections obtained by using Maple are listed below(1)
t=-.24414201370,t=0.02079175991, and t=1,(2)
t=-0.052708171410,t=0.003257621961, and t=1,(3)
t=-0.93455113330,t=0.08581158625, and t=1.Since all of the roots have modulus less than or equal to 1, the method (2.5) when (q=1)(q=2) and (q=10/19) is zero stable.The stability region was given by the set of points determined by the boundaryt=eiθ,0≤θ≤2π. The stability region is obtained by finding the region for which |t|<1. Figure 2 shows the stability for the cases (q=1)(q=2) and (q=10/19), respectively. The stability regions lie outside the closed region for each case.Figure 2
Stability regions whenq=1, q=2, and q=10/19.Based on Figure2, the 5th-order BBDF possesses the region absolute stability, which contains almost whole of the half-plane Re(hλ)<0.


## 3.2. Choosing Step Size

The importance in choosing the step size is to achieve reduction in computation time and number of iterations. Therefore, this paper proposed three basic strategies for the step size selections. For each successful step, the step size remains constant(q=1) or increased by a factor of 1.9 (q=10/19). Inversely, when a fail step occurs, the next step size will be halved of the previous step size (q=2). The user initially will have to provide an error tolerance limit, TOL on any given step, and obtain the local truncation error (LTE) for each iteration.  The LTE is obtained from
(3.10)LTE=yn+2(k+1)-yn+2(k),k=4,
where yn+2(k+1) is the (k+1)th order method, and yn+2(k) is the kth order method.The successful step is dependent on the conditionLTE<TOL. If this condition fails, the values of yn+1, yn+2 are rejected, and the current step is reiterated with step size selection (q=2). On the contrary, the step size increment for each successful step is defined as
(3.11)hnew=c×hold×(TOLLTE)1/p.And ifhnew>1.9×hold, then hnew=1.9×hold. Where c is the safety factor, p is the order of the method, while hold and hnew are the step size from previous and current blocks, respectively. In this paper,c is set to be 0.8.


## 4. MATLAB’s Stiff Numerical Solvers

MATLAB offers several numerical solvers to solve either stiff or nonstiff ordinary differential equations. These built-in numerical solvers are capable in approximating solutions to almost any system of differential equations [2]. As far as this paper is concerned, we are interested in solving stiff ODEs. For comparison purposes, this paper considers only ode15s and ode23s. This is because both of the methods deal with stiff differential equations based on backward differentiation formulas (BDFs) and on a modified Rosenbrock formula of order 2, respectively.  Therefore, a fair comparison is obtained, and the discussions are made easy.


## 5. Numerical Results

We carry out numerical experiments to compare the performance of the 5th-order BBDF method with stiff ODE solvers in MATLAB mentioned above. Three sets of stiff test problems aroused from problems in physics are tested for the purpose of elucidating the difference in numerical results obtained. These test problems are performed under different conditions of error tolerances—(a) 10−2, (b) 10−4, and (c) 10−6, and the error trend is defined by
(5.1)Error=|yapproximate-yactual|.
The test problems and solution are listed below (1)
basic circuit problem is(5.2)y′=-20y+24,y(0)=0,0≤x≤10,
with solution  y(x)=6/5-(6/5)e-20x,(2)
oscillatory problems in physics: Torsion spring oscillator with dry and viscous friction [7]
(5.3)y1′=998y1+1998y2,y1(0)=1,0≤x≤10,y2′=-999y1-1999y2,y2(0)=2,
with solution
(5.4)y1(x)=2e-x-e-1000x,y2(x)=-e-x+e-1000x,
eigenvalues, λ=-1,-1000,(3)
Physical problem [11] is
(5.5)y1′=-20y1-0.25y2-19.75y3,y1(0)=1,0≤x≤10,y2′=20y1-20.25y2+0.25y3,y2(0)=0,y3′=20y1-19.75y2-0.25y3,y3(0)=-1,
with solution
(5.6)y1(x)=0.5[e-0.5x+e-20x(cos⁡20x+sin20x)],y2(x)=0.5[e-0.5x-e-20x(cos⁡20x-sin20x)],y3(x)=-0.5[e-0.5x+e-20x(cos⁡20x-sin20x)],
eigenvalues, λ=-0.5,-20±20i.From Table1, among the three methods tested, our method, 5oBBDF, requires the shortest execution time for each given tolerance level. On top of that, this method also gives the smallest maximum error and average error. From Figure 3, we can see that 5oBBDF gives the lowest maximum error for every tolerance level. When we look at the convergence of the methods compared in Figure 3, our method comparably converges faster with minimum number of steps taken.Table 1
Numerical results for problem (1.1).
TOLMethodTSAVEEMAXETime10−25oBBDF211.09720e-0057.3154e-0050.01067ode15s291.400e-0038.700e-0030.0313ode23s191.200e-0034.800e-0030.281310−45oBBDF371.88948e-0079.1173e-0070.02234ode15s613.4444e-0051.7046e-0040.0313ode23s431.2509e-0042.7400e-0040.015610−65oBBDF791.72338e-0098.8279e-0090.009139ode15s969.0543e-0072.7175e-0060.0469ode23s1488.0523e-0061.3309e-0050.0313Efficiency curves for problem (1.1).
(a)(b)From Table2, once again, 5oBBDF requires the shortest execution time for each given tolerance level. From the error trends described in Figure 4, we can see that the maximum errors for 5oBBDF are the smallest for each TOL as compared to ode15s and ode23s.  So the convergence of the method, 5oBBDF is found to converge fastest among the methods tested.Table 2
Numerical results for problem (2.1).
TOLMethodSTsAVEEMAXETime10−25oBBDF273.02605e-0051.0244e-0040.011902ode15s383.100e-0031.760e-0020.0469ode23s232.300e-0037.300e-0030.140610−45oBBDF573.15965e-0071.0632e-0060.064613ode15s904.3445e-0051.8659e-0040.0156ode23s681.9392e-0043.6837e-0040.062510−65oBBDF1472.10931e-0091.0440e-0080.009559ode15s1628.3966e-0073.9569e-0060.0625ode23s2889.9147e-0061.7039e-0050.0781Efficiency curves for problem (2.1).
(a)(b)From Table3, similarly, 5oBBDF gives the shortest execution time for each given tolerance level. This method is also completed with lesser total steps except when TOL is 10−2. The error trends for all of the methods tested are depicted in Figure 5. The error trend shows that 5oBBDF converged fastest with smallest maximum error for each TOL as compared to ode15s and ode23s.Table 3
Numerical results for problem (2.2).
TOLMethodTSsAverage errorMAXETime10−25oBBDF243.16762e-0052.1568e-0040.01150ode15s341.090e-0021.090e-0020.0313ode23s211.004e-0036.400e-0030.031310−45oBBDF484.39634e-0071.8652e-0060.033346ode15s715.7501e-0052.0274e-0040.0469ode23s551.3953e-0043.5375e-0040.015610−65oBBDF1271.41711e-0082.0629e-0090.009460ode15s1408.3688e-0074.0059e-0060.0469ode23s2337.2824e-0061.7023e-0050.1250Efficiency curves for problem (2.2).
(a)(b)


## 6. Conclusion

For all problems tested, it is proven that, the 5th-order variable step BBDF has outperformed the ode15s and ode23s in terms of average errors as well as maximum errors. It also managed to reduce the number of total steps taken in most of the cases especially when TOL is less than 10−2. When we tested the convergence of the methods compared in this paper, the error trend worked as the identifier for the fastest error of the method approaches zero.  Figures 3, 4, and 5 illustrate how fast the error of 5th-order variable step BBDF converged as compared to the other two methods used. As a result, we found that this method converges fastest for all problems tested.  In terms of computation timewise, it gave lesser values for all of the test problems. Therefore, we can conclude that the 5th-order variable step BBDF is one compatible alternative solver for solving stiff ordinary differential equations which mostly arise in engineering and applied sciences.



---

*Source: 193691-2011-09-04.xml*