1
Basic Numerical Methods

1.1 Introduction

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

(1.1)equation

associated with Figure 1.1 is expressed in the form of differential equation with respect to the rate of change in time.

Schematic diagram of a mechanical system composed of a ground, spring (k), damper (c), and box labeled m.

Figure 1.1 Mechanical system.

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. [13]. 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 [48] 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).

1.2 Ordinary Differential Equation

The general form of an nth order ODE is given by

(1.2)equation

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.

1.3 Euler Method

Let us consider a first‐order ODE,

(1.3)equation

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

1.4equation

Equation (1.4) reduces to Euler's equation if we retain the first‐order approximation and neglect higher‐order terms giving

1.5equation

For discrete steps t0, t1, …, tn − 1, Eq. (1.5) may be written as

(1.6)equation

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 images 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.

Geometrical representation of the Euler method, displaying 2 ascending curves (solid, dashed) with arrows indicating slope of step 1, slope of step 2, slope of step 3, approximate solution, and exact solution (x(t)).

Figure 1.2 Geometrical representation of the Euler method.

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
Graph displaying 2 descending curves with markers for iterative approximate solution of y' +2xy = 0, y(0) = 2 using the approximate solution (asterisk markers) and comparison with exact solution (circle markers).

Figure 1.3 Approximate solution of y′ + 2xy = 0, y(0) = 2 using the Euler method and comparison with exact solution.

1.4 Improved Euler Method

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,

(1.8a)equation
(1.8b)equation

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 images 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

1.5 Runge–Kutta Methods

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.

1.5.1 Midpoint Method

The explicit midpoint method for the first‐order differential equation 1.3) is expressed as

(1.12)equation

whereas the implicit midpoint method is expressed as

(1.13)equation

It is worth mentioning that Eq. (1.12) or Eq. (1.13) computes the function at midpoints images. 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.

1.5.2 Runge–Kutta Fourth Order

The fourth‐order Runge–Kutta also known as classical Runge–Kutta or RK4 for the differential equation 1.3) is given as

(1.14)equation

where

equation

and

equation

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

1.6 Multistep Methods

Numerical method is referred to as single‐step method when yi + 1 is computed in a single step. The methods mentioned in Sections 1.31.5 are single‐step methods whereas a multistep method comprises of two or more successive steps.

1.6.1 Adams–Bashforth Method

The multistep formula for Adams–Bashforth method of fourth order is given by

(1.17)equation

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).

1.6.2 Adams–Moulton Method

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 ),

(1.18)equation

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

(1.19)equation

for i = 4, 5, …, n − 1.

Table 1.4 Approximate solution using the Adams–Moulton method.

Approximate solution Exact solution Error
i images 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
Graph of approximate solutions of y' +y +t = 1, y(0) = 1 displaying a descending curve with markers for Euler and 4 coinciding curves with markers for improved Euler, RK4, Adams-Moulton, and exact.

Figure 1.4 Approximate solutions of y′ + y + t = 1, y(0) = 1.

Error plot of Example 1.5 displaying an ascending curve with markers for Euler method, slightly ascending curve for improved Euler method, and 2 coinciding lines with markers for RK4 and Adams-Moulton methods.

Figure 1.5 Error plot of Example 1.5 using Euler, improved Euler, RK4, and Adams–Moulton methods.

1.7 Higher‐Order ODE

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 ),

equation

subject to initial conditions x(0) = x0 and images for i = 1, 2, …, n − 1. This nth order ODE may be transformed to coupled system of first‐order ODEs,

(1.23)equation

by substituting y1 = x, images for i = 2, 3, …, n and images.

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.

Exercise

  1. 1 Solve the IVPs exactly and compute the error using Euler and improved Euler methods.
    1. y′ − t2 − 1 = 0, y(0) = 1, h = 0.1, t ∈ [0, 1]
    2. y′ + 2y2 − t + 2 = 0, y(0) = 0, h = 0.25, t ∈ [0, 2]
    3. y′ − (y − 2x)2 − x3 sin(x) = 0, y(0) = 2, h = 0.2, x ∈ [0, 2]
  2. 2 Solve the initial value problem images using RK4 and Adams–Moulton methods.
  3. 3 Compute the solution of IVP y″ + 8xy′ + 5xy = 4, y(1) = 2, y′(1) =  − 1 using Euler and RK4 for step size h = 0.1 in the domain x ∈ [1, 2].
  4. 4 Evaluate u″ − u′ + u = t subject to initial conditions u(0) = 1 and u′(0) = 0 for step size h = 0.05 in the domain [0, 1] using the improved Euler method.
  5. 5 Compute the system of ODEs images and images subject to initial conditions u(0) = 0 and v(0) = 1 for step size h = 0.01 using Euler, improved Euler, RK4, and Adams–Moulton methods.

References

  1. 1 Zwilliger, D. (1998). Handbook of Differential Equations, 3e. New York: Academic Press.
  2. 2 Hartman, P. (2002). Ordinary Differential Equations, 2e. Philadelphia: SIAM.
  3. 3 Arnold, V.I. (2006). Ordinary Differential Equations, 3e. New York: Springer.
  4. 4 Atkinson, K.E. and Han, W. (1985). Elementary Numerical Analysis, 3e. New York: Wiley.
  5. 5 Gerald, C.F. and Wheatley, P.O. (2004). Applied Numerical Analysis, 7e. Boston, MA; Munich: Pearson Education India.
  6. 6 Bhat, R.B. and Chakraverty, S. (2004). Numerical Analysis in Engineering. Pangbourne: Narosa, Alpha Science International Limited.
  7. 7 Hoffman, J.D. (2001). Numerical Methods for Engineers and Scientists, 2e. New York: Taylor & Francis.
  8. 8 Milne, W.E. and Milne, W.E. (1953). Numerical Solution of Differential Equations. New York: Wiley.
  9. 9 Ganji, D.D. and Talarposhti, R.A. (2018). Numerical and Analytical Solutions for Solving Nonlinear Equations in Heat Transfer, Advances in Mechatronics and Mechanical Engineering Book Series. Hershey, PA: IGI Global.
  10. 10 Higham, N.J. (2002). Accuracy and Stability of Numerical Algorithms, 2e. Philadelphia: SIAM.
  11. 11 Kreyszig, E. (2017). Advanced Engineering Mathematics, 10e. New Delhi: Wiley.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.12.124