Differentialequations form the backbone of various science and engineering problems viz. structural mechanics, image processing, control theory, stationary analysis of circuits, etc. Generally, engineering problems are modeled in terms of mathematical functions or using relationships between the function and its derivatives. For instance, in structural mechanics the governing equation of motion
associated with Figure 1.1 is expressed in the form of differential equation with respect to the rate of change in time.
Here m, c, and k are mass, damping, stiffness parameters, respectively, and f(t) is the external force applied on the mechanical system.
There exist various techniques for solving simple differential equations analytically. Modeling of differential equations to compute exact solutions may be found in Refs. [1–3]. But, due to complexity of problems in nature, the existing differential equations are rather cumbersome or complex (nonlinear) in nature. Generally, computation of exact or analytical solutions is quite difficult and in such cases, numerical methods [4–8] and semi‐analytical methods [9] are proved to be better. In this regard, the numerical and semi‐analytic techniques comprising series or closed‐form solutions will be discussed in subsequent chapters. Readers interested with respect to accuracy and stability for various numerical methods may study Higham [10]. With the advancement in numerical computing, various software and programming techniques have also been developed that provide efficient platform for solving differential equations numerically viz. MATLAB, Maple, Mathematica, etc.
This chapter presents the recapitulation of basic numerical techniques for solving ordinary differential equations. Few unsolved problems have also been included at the end for self‐validation of the topics. However, before we start with numerical methods, we briefly recapitulate the concepts of differential equations.
A differential equation is a mathematical relation formulated among function, variables over which it is dependent, and its derivatives. If a function depends on a single variable, then such a differential equation is referred to as ordinary differential equation (ODE), while a function depending on multiple variables result in occurrence of partial differential equation (PDE).
The general form of an nth order ODE is given by
subject to initial or boundary conditions. The differential equations subject to initial conditions are generally referred to as initial value problems whereas differential equations subject to boundary conditions over a domain Ω where t ∈ [t0, T] forms boundary value problems. A detailed discussion on existence and uniqueness of the solution of ODE may be found in Refs. [1 – 3] .
If Gn(t, x) is a linear function of x and its derivatives, then Eq. (1.2) is considered as a linear ODE, otherwise nonlinear. Generally, a nonlinear differential equation consists of product of the dependent variable x with itself or its derivatives. This chapter is evenly divided by focusing on solving ordinary differential equations using Euler, improved Euler, Runge–Kutta, and multistep methods [5,7]. Laplace and Fourier transform methods for solving differential equations are included in Chapter 2 and numerical solutions of ODE and PDE using difference schemes over grids have been discussed in Chapter 5.
Let us consider a first‐order ODE,
subject to initial condition x(t0) = x0.
The numerical methods for solving differential equations are generally obtained initially by partitioning the independent variable t ∈ [t0, T] into n finite subintervals at steps t0, t1, …, tn − 1, tn = T having equal step size h = Δt = ti − ti − 1 for i = 1, 2, …, n − 1.
In terms of Taylor's series expansion, the solution function x(t) of Eq. (1.3) is obtained using
Equation (1.4) reduces to Euler's equation if we retain the first‐order approximation and neglect higher‐order terms giving
For discrete steps t0, t1, …, tn − 1, Eq. (1.5) may be written as
for i = 0, 1, …, n − 1. Here, Eq. (1.6) is known as the Euler method or Euler–Cauchy method. Geometrically, the Euler method at each step ti results in an approximation of in terms of tangent to curve at ti where i = 0, 1, …, n − 1. The geometrical representation of the Euler method is depicted in Figure 1.2.
The error at each step from Figure 1.2 is obtained using ∣x(ti) − xi∣ for i = 0, 1, …, n. Also, the local truncation error [ 5 ,11] at each step is proportional to h2 having O(h2) whereas the global error is of O(h), where “O” stands for order. The algorithm for the Euler method is formulated in Algorithm 1.1.
Table 1.1 Approximate solution at xi using the Euler method.
Exact solution | Error | ||
i | Approximate solution yi | y(xi) | ∣y(xi) − yi∣ |
1 | y1 = y0 − 0.2x0y0 = 2 | 1.9801 | 0.0199 |
2 | y2 = y1 − 0.2x1y1 = 1.96 | 1.9216 | 0.0384 |
3 | y3 = y2 − 0.2x2y2 = 1.8816 | 1.8279 | 0.0537 |
4 | y4 = y3 − 0.2x3y3 = 1.7687 | 1.7043 | 0.0644 |
5 | y5 = y4 − 0.2x4y4 = 1.6272 | 1.5576 | 0.0696 |
6 | y6 = y5 − 0.2x5y5 = 1.4645 | 1.3954 | 0.0691 |
7 | y7 = y6 − 0.2x6y6 = 1.2887 | 1.2253 | 0.0635 |
8 | y8 = y7 − 0.2x7y7 = 1.1083 | 1.0546 | 0.0537 |
9 | y9 = y8 − 0.2x8y8 = 0.931 | 0.8897 | 0.0413 |
10 | y10 = y9 − 0.2x9y9 = 0.7634 | 0.7358 | 0.0277 |
Let us again consider the first‐order differential equation given in Eq. ( 1.3 ). The improved Euler method for solution of Eq. ( 1.3 ) is a two‐step procedure,
In few literature studies, improved Euler method is also termed as modified Euler method or Heun's method. Improved Euler method is also considered as a predictor–corrector method where Eq. (1.8a) acts as the predictor and Eq. (1.8b) acts as the corrector. Eventually, at each step we predict the function value using Eq. (1.8a) and the predicted value is then corrected using Eq. (1.8b). Corresponding algorithm for improved Euler method is formulated in Algorithm 1.2.
The efficiency of Algorithm 1.2 is verified using Example 1.2.
Table 1.2 Approximate solution at ti using improved Euler method.
Approximate solution | Exact solution | Error | ||
i | yi | y(ti) | ∣y(ti) − yi∣ | |
1 | 0.8 | 0.864 | 0.8587 | 0.0053 |
2 | 0.7792 | 0.8397 | 0.8303 | 0.0094 |
3 | 0.8637 | 0.9213 | 0.9088 | 0.0125 |
4 | 1.0491 | 1.1043 | 1.0893 | 0.015 |
5 | 1.1043 | 1.3847 | 1.3679 | 0.0168 |
The Taylor series expansion in the Euler method is truncated till first derivative whereas the Runge–Kutta method retains truncated terms till second‐order derivative. As such, the higher‐order term improves the accuracy in Runge–Kutta compared to the Euler method. In this regard, we discuss Runge–Kutta second‐ (midpoint method) and fourth‐order methods in Sections 1.5.1 and 1.5.2, respectively.
The explicit midpoint method for the first‐order differential equation 1.3) is expressed as
whereas the implicit midpoint method is expressed as
It is worth mentioning that Eq. (1.12) or Eq. (1.13) computes the function at midpoints . As such, the Runge–Kutta second‐order method is also referred to as the midpoint method. Also, the explicit second‐order Runge–Kutta method is equivalent to improved Euler method.
The fourth‐order Runge–Kutta also known as classical Runge–Kutta or RK4 for the differential equation 1.3) is given as
where
and
Corresponding steps for RK4 are given in Algorithm 1.3.
Table 1.3 Approximate solution at ti using RK4 method.
Approximate solution | Exact solution | Error | |
i | yi | y(ti) | ∣y(ti) − yi∣ |
1 | 1.2242 | 1.2242 | 0 |
2 | 1.5151 | 1.5151 | 0 |
3 | 1.9035 | 1.9035 | 0 |
4 | 2.4243 | 2.4243 | 0 |
5 | 3.1163 | 3.1164 | 0.0001 |
Numerical method is referred to as single‐step method when yi + 1 is computed in a single step. The methods mentioned in Sections 1.3–1.5 are single‐step methods whereas a multistep method comprises of two or more successive steps.
The multistep formula for Adams–Bashforth method of fourth order is given by
Gerald and Wheatley [5] may be referred for the derivation of Eq. (1.17). Further, the local error for the Adams–Bashforth method is of O(h5) and the global error is of O(h4).
Adams–Moulton method is a predictor–corrector method where we may predict the value of x(t) for the differential equation 1.3) using Eq. ( 1.17 ),
Then the value of x*(t) is corrected using the Adams–Moulton method. The multistep formula of the Adams–Moulton method of fourth order may be obtained as
for i = 4, 5, …, n − 1.
Table 1.4 Approximate solution using the Adams–Moulton method.
Approximate solution | Exact solution | Error | ||
i | yi | y(xi) | ∣y(xi) − yi∣ | |
4 | 7.3164 | 7.0061 | 7.1933 | 0.1872 |
5 | 10.859 | 9.1517 | 8.9634 | 0.1883 |
6 | 9.2127 | 10.803 | 10.7311 | 0.0719 |
7 | 12.857 | 12.439 | 12.3437 | 0.0953 |
8 | 13.802 | 13.751 | 13.6419 | 0.4073 |
9 | 14.581 | 14.601 | 14.4855 | 0.1155 |
10 | 14.889 | 14.897 | 14.7781 | 0.1189 |
Table 1.5 Approximate solution at ti using the Euler, improved Euler, RK4, and Adams-Moulton methods.
Approximate solution yi | |||||
i | Euler | Improved Euler | RK4 | Adams–Moulton | Exact solution y(ti) |
1 | 1 | 0.98 | 0.98127 | 0.98127 | 0.98127 |
2 | 0.96 | 0.9276 | 0.92968 | 0.92968 | 0.92968 |
3 | 0.888 | 0.84863 | 0.85118 | 0.85118 | 0.85119 |
4 | 0.7904 | 0.74788 | 0.75067 | 0.75068 | 0.75067 |
5 | 0.67232 | 0.62926 | 0.63211 | 0.63213 | 0.63212 |
Higher‐order ODEs may easily be converted to system of first‐order ODEs. For instance, consider the nth order ODE given in Eq. ( 1.2 ),
subject to initial conditions x(0) = x0 and for i = 1, 2, …, n − 1. This nth order ODE may be transformed to coupled system of first‐order ODEs,
by substituting y1 = x, for i = 2, 3, …, n and .
Let us now illustrate the numerical methodology for solving higher‐order ODE by converting it to system of first‐order ODEs through an example problem.
3.15.12.124