0% found this document useful (0 votes)
8 views

Math 23 Module 5

Uploaded by

202140397
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Math 23 Module 5

Uploaded by

202140397
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Advanced Mathematics

Module 5: Numerical
Differentiation and Integration

Prepared by:

ENGR. MICHAEL ERNIE F. RODRIGUEZ


Instructor, Department of Electrical Engineering
College of Engineering, Architecture and Technology
Palawan State University
Module 5
NUMERICAL DIFFERENTIATION AND INTEGRATION

Overview
In this module, we will discuss numerical differentiation and integration. Although differentiation is
taught before integration in calculus, we reverse their order in this module. We do this because
integration represents a more highly developed area of numerical methods. While numerical
differentiation is not as widely employed, it does have great significance for the solution of differential
equations. Hence, it makes sense to cover it as the last topic prior to describing differential equations
in Module 6.
The first part of the module is devoted to the most common approaches for numerical integration—
the Newton-Cotes formulas. These relationships are based on replacing a complicated function or
tabulated data with a simple polynomial that is easy to integrate. Three of the most widely used
Newton-Cotes formulas are discussed in detail: the trapezoidal rule, Simpson’s 1∕3 rule, and
Simpson’s 3∕8 rule. All these formulas are designed for cases where the data to be integrated are
evenly spaced.
In the last part of the module, we will discuss numerical differentiation. Topics include finite-
divided difference formulas, and Richardson’s extrapolation.

Learning Outcomes
At the end of this module, you should be able to:
1. Solve integration problems using Newton-Cotes formulas.
2. Use finite-difference formulas in solving derivatives.

5.1 INTRODUCTION
The function to be differentiated or integrated will typically be in one of the following three forms:
1. A simple continuous function such as a polynomial, an exponential, or a trigonometric function.
2. A complicated continuous function that is difficult or impossible to differentiate or integrate
directly.
3. A tabulated function, where values of 𝑥 and 𝑓(𝑥) are given at a number of discrete points, as
is often the case with experimental or field data.
In the first case, the derivative or integral of a simple function may be evaluated analytically using
calculus. For the second case, analytical solutions are often impractical, and sometimes impossible,
to obtain. In these instances, as well as in the third case of discrete data, approximate methods must
be employed.

5.2 NEWTON-COTES INTEGRATION FORMULAS


The Newton-Cotes formulas are the most common numerical integration schemes. They are based
on the strategy of replacing a complicated function or tabulated data with an approximating function
that is easy to integrate:
𝑏 𝑏
𝐼 = ∫ 𝑓(𝑥)𝑑𝑥 ≅ ∫ 𝑓𝑛 (𝑥)𝑑𝑥 (5.1)
𝑎 𝑎
where 𝑓𝑛 (𝑥) = a polynomial of the form
𝑓𝑛 (𝑥) = 𝑎0 + 𝑎1 𝑥 + ⋯ + 𝑎𝑛−1 𝑥 𝑛−1 + 𝑎𝑛 𝑥 𝑛

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 1


where 𝑛 is the order of the polynomial. For example, in Fig. 5.1a, a first-order polynomial (a straight
line) is used as an approximation. In Fig. 5.1b, a parabola is employed for the same purpose.

Figure 5.1 The Approximation of an Integral by the Area Under


(a) a Single Straight Line and (b) a Single Parabola

In this module, we will cover the Newton-Cotes closed integration formulas such as trapezoidal
rule, Simpson’s 1/3 rule, and Simpson’s 3/8 rule. The closed forms are those where the data points
at the beginning and end of the limits of integration are known.

5.3 TRAPEZOIDAL RULE


The trapezoidal rule is the first of the Newton-Cotes closed integration formulas. It corresponds to the
case where the polynomial in Eq. (5.1) is first order:
𝑏 𝑏
𝐼 = ∫ 𝑓(𝑥)𝑑𝑥 ≅ ∫ 𝑓1 (𝑥)𝑑𝑥
𝑎 𝑎
Recall from Module 4 that a straight line can be represented as
𝑓(𝑏) − 𝑓(𝑎)
𝑓1 (𝑥) = 𝑓(𝑎) + (𝑥 − 𝑎) (5.2)
(𝑏 − 𝑎)
The area under this straight line is an estimate of the integral of 𝑓(𝑥) between the limits 𝑎 and 𝑏:
𝑏 𝑏
𝐼 = ∫ 𝑓(𝑥)𝑑𝑥 ≅ ∫ 𝑓1 (𝑥)𝑑𝑥
𝑎 𝑎
The result of the integration is
𝑓(𝑎) + 𝑓(𝑏)
𝐼 = (𝑏 − 𝑎) (5.3)
2
If 𝑎 and 𝑏 are designated as 𝑥0 and 𝑥1 , the simplified formula is

𝐼 ≅ [𝑓(𝑥0 ) + 𝑓(𝑥1 )] (5.4)
2
where, for this case, ℎ = (𝑏 − 𝑎)⁄2. This equation is known as the trapezoidal rule.
Geometrically, the trapezoidal rule is equivalent to approximating the area of the trapezoid under
the straight line connecting 𝑓(𝑎) and 𝑓(𝑏) in Fig. 5.2.

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 2


Figure 5.2 Graphical Depiction of the Trapezoidal Rule

Example 5.1
Estimate the integral of
𝑓(𝑥) = 0.2 + 25𝑥 − 200𝑥 2 + 675𝑥 3 − 900𝑥 4 + 400𝑥 5
from 𝑎 = 0 to 𝑏 = 0.8 using trapezoidal rule.

Solution
The data needed for this example are
𝑥0 = 0, 𝑓(𝑥0 ) = 0.2
𝑥1 = 0.8, 𝑓(𝑥1 ) = 0.232
The integral estimate using Eq. (5.3) is
0.2 + 0.232
𝐼 = (0.8 − 0) [ ] = 0.1728
2
Note that the actual integral value is 1.6405.

Multiple-Application Trapezoidal Rule


One way to further increase the accuracy of the trapezoidal rule is to divide the integration interval
from 𝑎 to 𝑏 into a number of segments and apply the approximation method to each segment (Fig.
5.3). The areas of individual segments can then be added to yield the integral for the entire interval.
The resulting equations are called multiple-application, or composite integration formulas.

Figure 5.3 Illustration of the Multiple-Application Trapezoidal Rule


(a) Two Segments, and (b) Three Segments

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 3


In using multiple application trapezoidal rule there are 𝑛 + 1 equally spaced base points and
consequently there are 𝑛 segments of equal width given by the formula:
𝑏−𝑎
ℎ= (5.5)
𝑛
If 𝑎 and 𝑏 are designated as 𝑥0 and 𝑥𝑛 , respectively, the total integral can be represented as
𝑥1 𝑥2 𝑥𝑛
𝐼 = ∫ 𝑓(𝑥)𝑑𝑥 + ∫ 𝑓(𝑥)𝑑𝑥 + ⋯ + ∫ 𝑓(𝑥)𝑑𝑥
𝑥0 𝑥1 𝑥𝑛−1
Substituting the trapezoidal rule for each integral yields
𝑓(𝑥0 ) + 𝑓(𝑥1 ) 𝑓(𝑥1 ) + 𝑓(𝑥2 ) 𝑓(𝑥𝑛−1 ) + 𝑓(𝑥𝑛 )
𝐼=ℎ +ℎ + ⋯+ℎ (5.6)
2 2 2
or, grouping terms,
𝑛−1

𝐼 = [𝑓(𝑥0 ) + 2 ∑ 𝑓(𝑥𝑖 ) + 𝑓(𝑥𝑛 )] (5.7)
2
𝑖=1
or Eq. (5.7) can be expressed as
𝑓(𝑥0 ) + 2 ∑𝑛−1
𝑖=1 𝑓(𝑥𝑖 ) + 𝑓(𝑥𝑛 )
𝐼 = (𝑏 − 𝑎) (5.8)
2𝑛

Example 5.2
Estimate the integral of
𝑓(𝑥) = 0.2 + 25𝑥 − 200𝑥 2 + 675𝑥 3 − 900𝑥 4 + 400𝑥 5
from 𝑎 = 0 to 𝑏 = 0.8 using multiple-application trapezoidal rule for 𝑛 = 8 segments.

Solution
Using trapezoidal rule 𝑛 = 8, the step size is
𝑏 − 𝑎 0.8 − 0
ℎ= = = 0.1
𝑛 8
The calculations for the function values 𝑓(𝑥𝑖 ) and Σ𝑤𝑓(𝑥𝑖 ) is shown in Table 5.1.

Table 5.1 Tabulated Solution for Example 5.2


𝑖 𝑥𝑖 𝑓(𝑥𝑖 ) 𝑤 𝑤𝑓(𝑥𝑖 )
0 0 0.2 1 0.2
1 0.1 1.289 2 2.578
2 0.2 1.288 2 2.576
3 0.3 1.607 2 3.214
4 0.4 2.456 2 4.912
5 0.5 3.325 2 6.65
6 0.6 3.464 2 6.928
7 0.7 2.363 2 4.726
8 0.8 0.232 1 0.232
Σ𝑤𝑓(𝑥𝑖 ) 32.016

Therefore, the integral estimate using trapezoidal rule with 𝑛 = 8 segments is


𝑛−1
ℎ 0.1
𝐼 = [𝑓(𝑥0 ) + 2 ∑ 𝑓(𝑥𝑖 ) + 𝑓(𝑥𝑛 )] = [32.016] = 1.6008
2 2
𝑖=1

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 4


5.4 SIMPSON’S 1/3 RULE
Another way to obtain a more accurate estimate of an integral is to use higher-order polynomials to
connect the points. If there is an extra point midway between 𝑓(𝑎) and 𝑓(𝑏), the three points can be
connected with a parabola (Fig. 5.4). Simpson’s 1/3 rule results when a second-order interpolating
polynomial is substituted into Eq. (5.1):
𝑏 𝑏
𝐼 = ∫ 𝑓(𝑥)𝑑𝑥 ≅ ∫ 𝑓2 (𝑥)𝑑𝑥
𝑎 𝑎

Figure 5.4 Graphical Depiction of Simpson’s 1/3 Rule

If 𝑎 and 𝑏 are designated as 𝑥0 and 𝑥2 and 𝑓2 (𝑥) is represented by a second-order Lagrange


polynomial [Eq. (4.42)], the integral becomes
𝑥2 (𝑥
− 𝑥1 )(𝑥 − 𝑥2 ) (𝑥 − 𝑥0 )(𝑥 − 𝑥2 ) (𝑥 − 𝑥0 )(𝑥 − 𝑥1 )
𝐼=∫ [ 𝑓(𝑥0 ) + 𝑓(𝑥1 ) + 𝑓(𝑥2 )] 𝑑𝑥
𝑥0 (𝑥0 − 𝑥1 )(𝑥0 − 𝑥2 ) (𝑥1 − 𝑥0 )(𝑥1 − 𝑥2 ) (𝑥2 − 𝑥0 )(𝑥2 − 𝑥1 )
After integration and algebraic manipulation, the following formula results:

𝐼 ≅ [𝑓(𝑥0 ) + 4𝑓(𝑥1 ) + 𝑓(𝑥2 )] (5.9)
3
where, for this case, ℎ = (𝑏 − 𝑎)⁄2. This equation is known as Simpson’s 1/3 rule. It is the second
Newton-Cotes closed integration formula. The label “1/3” stems from the fact that ℎ is divided by 3 in
Eq. (5.9).
Simpson’s 1/3 rule can also be expressed as:
𝑓(𝑥0 ) + 4𝑓(𝑥1 ) + 𝑓(𝑥2 )
𝐼 ≅ (𝑏 − 𝑎) (5.10)
6

Example 5.3
Estimate the integral of
𝑓(𝑥) = 0.2 + 25𝑥 − 200𝑥 2 + 675𝑥 3 − 900𝑥 4 + 400𝑥 5
from 𝑎 = 0 to 𝑏 = 0.8 using Simpson’s 1/3 rule.

Solution
For single application of Simpson’s 3/8 rule, 𝑛 = 3 (minimum) and ℎ = 0.4.
𝑥0 = 0, 𝑓(𝑥0 ) = 0.2
𝑥1 = 0.4, 𝑓(𝑥1 ) = 2.456
𝑥2 = 0.8, 𝑓(𝑥2 ) = 0.232

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 5


The integral estimate using Eq. (5.10) is
0.2 + 4(2.456) + 0.232
𝐼 = (0.8 − 0) [ ] = 1.3675
6
Note that the actual integral value is 1.6405.

Multiple-Application Simpson’s 1/3 Rule


Just like the trapezoidal rule, Simpson’s 1/3 rule can be improved by dividing the integration interval
into a number of segments of equal width:
𝑏−𝑎
ℎ= (5.11)
𝑛
The total integral can be represented as
𝑥2 𝑥4 𝑥𝑛
𝐼 = ∫ 𝑓(𝑥)𝑑𝑥 + ∫ 𝑓(𝑥)𝑑𝑥 + ⋯ + ∫ 𝑓(𝑥)𝑑𝑥
𝑥0 𝑥2 𝑥𝑛−2
Substituting Simpson’s 1/3 rule for the individual integral yields
𝑓(𝑥0 ) + 4𝑓(𝑥1 ) + 𝑓(𝑥2 ) 𝑓(𝑥2 ) + 4𝑓(𝑥3 ) + 𝑓(𝑥4 ) 𝑓(𝑥𝑛−2 ) + 𝑓(𝑥𝑛−1 ) + 𝑓(𝑥𝑛 )
𝐼 ≅ 2ℎ + 2ℎ + ⋯ + 2ℎ
6 6 6
or, combining terms and using Eq. (5.11),
𝑓(𝑥0 ) + 4 ∑𝑛−1 𝑛−2
𝑖=1,3,5 𝑓(𝑥𝑖 ) + 2 ∑𝑗=2,4,6 𝑓(𝑥𝑗 ) + 𝑓(𝑥𝑛 )
𝐼 ≅ (𝑏 − 𝑎) (5.12)
3𝑛
or, Eq. (5.12) can be written as
𝑛−1 𝑛−2

𝐼 = [𝑓(𝑥0 ) + 4 ∑ 𝑓(𝑥𝑖 ) + 2 ∑ 𝑓(𝑥𝑗 ) + 𝑓(𝑥𝑛 )] (5.13)
3
𝑖=odd 𝑗=even

Example 5.4
Estimate the integral of
𝑓(𝑥) = 0.2 + 25𝑥 − 200𝑥 2 + 675𝑥 3 − 900𝑥 4 + 400𝑥 5
from 𝑎 = 0 to 𝑏 = 0.8 using multiple-application Simpson’s 1/3 rule for 𝑛 = 6 segments.

Solution
Using Simpson’s 1/3 rule 𝑛 = 6, the step size is
𝑏 − 𝑎 0.8 − 0
ℎ= = = 0.13333
𝑛 6
The calculations for the function values 𝑓(𝑥𝑖 ) and Σ𝑤𝑓(𝑥𝑖 ) is shown in Table 5.2.

Table 5.2 Tabulated Solution for Example 5.4


𝑖 𝑥𝑖 𝑓(𝑥𝑖 ) 𝑤 𝑤𝑓(𝑥𝑖 )
0 0 0.2 1 0.2
1 0.13333 1.31019 4 5.24076
2 0.26667 1.43272 2 2.86545
3 0.4 2.456 4 9.824
4 0.53333 3.48718 2 6.97435
5 0.66667 2.87490 4 11.49959
6 0.8 0.232 1 0.232
Σ𝑤𝑓(𝑥𝑖 ) 36.83615

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 6


Therefore, the integral estimate using Simpson’s 1/3 rule with 𝑛 = 6 segments is
𝑛−1 𝑛−2
ℎ 0.13333
𝐼 = [𝑓(𝑥0 ) + 4 ∑ 𝑓(𝑥𝑖 ) + 2 ∑ 𝑓(𝑥𝑗 ) + 𝑓(𝑥𝑛 )] = [36.83615] = 1.63716
3 3
𝑖=odd 𝑗=even

Example 5.5
Estimate the integral of
𝑓(𝑥) = 0.2 + 25𝑥 − 200𝑥 2 + 675𝑥 3 − 900𝑥 4 + 400𝑥 5
from 𝑎 = 0 to 𝑏 = 0.8 using multiple-application Simpson’s 1/3 rule for 𝑛 = 8 segments.

Solution
Using Simpson’s 1/3 rule 𝑛 = 8, the step size is
𝑏 − 𝑎 0.8 − 0
ℎ= = = 0.1
𝑛 8
The calculations for the function values 𝑓(𝑥𝑖 ) and Σ𝑤𝑓(𝑥𝑖 ) is shown in Table 5.3.

Table 5.3 Tabulated Solution for Example 5.5


𝑖 𝑥𝑖 𝑓(𝑥𝑖 ) 𝑤 𝑤𝑓(𝑥𝑖 )
0 0 0.2 1 0.2
1 0.1 1.289 4 5.156
2 0.2 1.288 2 2.576
3 0.3 1.607 4 6.428
4 0.4 2.456 2 4.912
5 0.5 3.325 4 13.3
6 0.6 3.464 2 6.928
7 0.7 2.363 4 9.452
8 0.8 0.232 1 0.232
Σ𝑤𝑓(𝑥𝑖 ) 49.184

Therefore, the integral estimate using Simpson’s 1/3 rule with 𝑛 = 8 segments is
𝑛−1 𝑛−2
ℎ 0.1
𝐼 = [𝑓(𝑥0 ) + 4 ∑ 𝑓(𝑥𝑖 ) + 2 ∑ 𝑓(𝑥𝑗 ) + 𝑓(𝑥𝑛 )] = [49.184] = 1.63947
3 3
𝑖=odd 𝑗=even

5.5 SIMPSON’S 3/8 RULE


In a similar manner to the derivation of the trapezoidal and Simpson’s 1/3 rule, a third-order Lagrange
polynomial can be fit to four points (Fig. 5.5) and integrated:
𝑏 𝑏
𝐼 = ∫ 𝑓(𝑥)𝑑𝑥 ≅ ∫ 𝑓3 (𝑥)𝑑𝑥
𝑎 𝑎
to yield
3ℎ
𝐼≅ [𝑓(𝑥0 ) + 3𝑓(𝑥1 ) + 3𝑓(𝑥2 ) + 𝑓(𝑥3 )] (5.14)
8
where ℎ = (𝑏 − 𝑎)⁄3. This equation is known as Simpson’s 3/8 rule because ℎ is multiplied by 3/8. It
is the third Newton-Cotes closed integration formula.

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 7


Figure 5.5 Graphical Depiction of Simpson’s 3/8 Rule

The Simpson’s 3/8 rule can also be expressed as:


𝑓(𝑥0 ) + 3𝑓(𝑥1 ) + 3𝑓(𝑥2 ) + 𝑓(𝑥3 )
𝐼 ≅ (𝑏 − 𝑎) (5.15)
8

Example 5.6
Estimate the integral of
𝑓(𝑥) = 0.2 + 25𝑥 − 200𝑥 2 + 675𝑥 3 − 900𝑥 4 + 400𝑥 5
from 𝑎 = 0 to 𝑏 = 0.8 using Simpson’s 3/8 rule.

Solution
The single application of Simpson’s 3/8 rule requires four equally spaced points (𝑛 = 3, ℎ = 0.26667):
𝑥0 = 0, 𝑓(𝑥0 ) = 0.2
𝑥1 = 0.26667, 𝑓(𝑥1 ) = 1.43272
𝑥2 = 0.53333, 𝑓(𝑥2 ) = 3.48718
𝑥3 = 0.8, 𝑓(𝑥3 ) = 0.232
The integral estimate using Eq. (5.15) is
0.2 + 3(1.43272 + 3.48718) + 0.232
𝐼 = (0.8 − 0) [ ] = 1.51917
6
Note that the actual integral value is 1.6405.

Multiple-Application Simpson’s 3/8 Rule


Just like the trapezoidal and Simpson’s 1/3 rule, the Simpson’s 3/8 rule can also be improved by
dividing the integration interval into three segments of equal width. The integral estimate using the
multiple-application Simpson’s 3/8 rule is
𝑛−1 𝑛−3
3ℎ
𝐼= [𝑓(𝑥0 ) + 3 ∑ 𝑓(𝑥𝑖 ) + 2 ∑ 𝑓(𝑥𝑗 ) + 𝑓(𝑥𝑛 )] (5.16)
8
𝑖=1,𝑖≠𝑗 𝑗=3𝑛
Note that in Eq. (5.16), 𝑛 must be multiples of 3.

Example 5.7
Estimate the integral of
𝑓(𝑥) = 0.2 + 25𝑥 − 200𝑥 2 + 675𝑥 3 − 900𝑥 4 + 400𝑥 5
from 𝑎 = 0 to 𝑏 = 0.8 using multiple-application Simpson’s 3/8 rule for 𝑛 = 6 segments.

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 8


Solution
Using Simpson’s 3/8 rule 𝑛 = 6, the step size is
𝑏 − 𝑎 0.8 − 0
ℎ= = = 0.13333
𝑛 6
The calculations for the function values 𝑓(𝑥𝑖 ) and Σ𝑤𝑓(𝑥𝑖 ) is shown in Table 5.2.

Table 5.4 Tabulated Solution for Example 5.7


𝑖 𝑥𝑖 𝑓(𝑥𝑖 ) 𝑤 𝑤𝑓(𝑥𝑖 )
0 0 0.2 1 0.2
1 0.13333 1.31019 3 3.93057
2 0.26667 1.43272 3 4.29817
3 0.4 2.456 2 4.912
4 0.53333 3.48718 3 10.46153
5 0.66667 2.87490 3 8.62469
6 0.8 0.232 1 0.232
Σ𝑤𝑓(𝑥𝑖 ) 32.65896

Therefore, the integral estimate using Simpson’s 3/8 rule with 𝑛 = 6 segments is
𝑛−1 𝑛−3
3ℎ 3(0.13333)
𝐼= [𝑓(𝑥0 ) + 3 ∑ 𝑓(𝑥𝑖 ) + 2 ∑ 𝑓(𝑥𝑗 ) + 𝑓(𝑥𝑛 )] = [32.65896] = 1.63295
8 8
𝑖=1,𝑖≠𝑗 𝑗=3𝑛

5.6 FINITE-DIVIDED DIFFERENCE FORMULAS


In this part of the module, we will cover the finite-divided difference formulas used for numerical
differentiation.

Forward Finite-Divided Difference

Figure 5.6 Graphical Depiction of Forward Finite-Divided Difference

First Derivative
The slope is derived as
𝑓(𝑥𝑖+1 ) − 𝑓(𝑥𝑖 )
𝑓 ′ (𝑥𝑖 ) = 𝑚(𝑠𝑙𝑜𝑝𝑒) =
𝑥𝑖+1 − 𝑥𝑖

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 9


Thus, the truncated derivative version is
𝑓(𝑥𝑖+1 ) − 𝑓(𝑥𝑖 )
𝑓 ′ (𝑥𝑖 ) = (5.17)

and the more accurate derivative version is
−𝑓(𝑥𝑖+2 ) + 4𝑓(𝑥𝑖+1 ) − 3𝑓(𝑥𝑖 )
𝑓 ′ (𝑥𝑖 ) = (5.18)
2ℎ

Second Derivative
The truncated derivative version is
𝑓(𝑥𝑖+2 ) − 2𝑓(𝑥𝑖+1 ) + 𝑓(𝑥𝑖 )
𝑓 ′′ (𝑥𝑖 ) = (5.19)
ℎ2
and the more accurate derivative version is
−𝑓(𝑥𝑖+3 ) + 4𝑓(𝑥𝑖+2 ) − 5𝑓(𝑥𝑖+1 ) + 2𝑓(𝑥𝑖 )
𝑓 ′′ (𝑥𝑖 ) = (5.20)
ℎ2

Backward Finite-Divided Difference

Figure 5.7 Graphical Depiction of Backward Finite-Divided Difference

First Derivative
The slope is derived as
𝑓(𝑥𝑖 ) − 𝑓(𝑥𝑖−1 )
𝑓 ′ (𝑥𝑖 ) = 𝑚(𝑠𝑙𝑜𝑝𝑒) =
𝑥𝑖 − 𝑥𝑖−1
Thus, the truncated derivative version is
𝑓(𝑥𝑖 ) − 𝑓(𝑥𝑖−1 )
𝑓 ′ (𝑥𝑖 ) = (5.21)

and the more accurate derivative version is
3𝑓(𝑥𝑖 ) − 4𝑓(𝑥𝑖−1 ) + 𝑓(𝑥𝑖−2 )
𝑓 ′ (𝑥𝑖 ) = (5.22)
2ℎ

Second Derivative
The truncated derivative version is
𝑓(𝑥𝑖 ) − 2𝑓(𝑥𝑖−1 ) + 𝑓(𝑥𝑖−2 )
𝑓 ′′ (𝑥𝑖 ) = (5.23)
ℎ2
and the more accurate derivative version is
2𝑓(𝑥𝑖 ) − 5𝑓(𝑥𝑖−1 ) + 4𝑓(𝑥𝑖−2 ) − 𝑓(𝑥𝑖−3 )
𝑓 ′′ (𝑥𝑖 ) = (5.24)
ℎ2

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 10


Centered Finite-Divided Difference

Figure 5.8 Graphical Depiction of Centered Finite-Divided Difference

First Derivative
The slope is derived as
𝑓(𝑥𝑖+1 ) − 𝑓(𝑥𝑖−1 )
𝑓 ′ (𝑥𝑖 ) = 𝑚(𝑠𝑙𝑜𝑝𝑒) =
𝑥𝑖+1 − 𝑥𝑖−1
Thus, the truncated derivative version is
𝑓(𝑥𝑖+1 ) − 𝑓(𝑥𝑖−1 )
𝑓 ′ (𝑥𝑖 ) = (5.25)
2ℎ
and the more accurate derivative version is
−𝑓(𝑥𝑖+2 ) + 8𝑓(𝑥𝑖+1 ) − 8𝑓(𝑥𝑖−1 ) + 𝑓(𝑥𝑖−2 )
𝑓 ′ (𝑥𝑖 ) = (5.26)
12ℎ

Second Derivative
The truncated derivative version is
𝑓(𝑥𝑖+1 ) − 2𝑓(𝑥𝑖 ) + 𝑓(𝑥𝑖−1 )
𝑓 ′′ (𝑥𝑖 ) = (5.27)
ℎ2
and the more accurate derivative version is
−𝑓(𝑥𝑖+2 ) + 16𝑓(𝑥𝑖+1 ) − 30𝑓(𝑥𝑖 ) + 16𝑓(𝑥𝑖−1 ) − 𝑓(𝑥𝑖−2 )
𝑓 ′′ (𝑥𝑖 ) = (5.28)
12ℎ2

Example 5.8
Use forward, backward, and centered finite-divided difference truncated formula to estimate the first
derivative of
𝑓(𝑥) = −0.1𝑥 4 − 0.15𝑥 3 − 0.5𝑥 2 − 0.25𝑥 + 1.2
at 𝑥 = 0.5 using a step size ℎ = 0.5. Repeat the computation using ℎ = 0.25. Note that the actual
derivative values can be calculated directly as
𝑓 ′ (𝑥) = −0.4𝑥 3 − 0.45𝑥 2 − 𝑥 − 0.25
and can be used to compute the actual derivative value of −0.9125.

Solution
For ℎ = 0.5, the function can be employed to determine
𝑥𝑖−1 = 0, 𝑓(𝑥𝑖−1 ) = 1.2
𝑥𝑖 = 0.5, 𝑓(𝑥𝑖 ) = 0.925
𝑥𝑖+1 = 1, 𝑓(𝑥𝑖+1 ) = 0.2

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 11


These values can be used to compute the forward finite-divided difference [Eq. (5.17)],
0.2 − 0.925
𝑓 ′ (𝑥𝑖 ) = = −1.45
0.5
the backward finite-divided difference [Eq. (5.21)],
0.925 − 1.2
𝑓 ′ (𝑥𝑖 ) = = −0.55
0.5
the centered finite-divided difference [Eq. (5.25)],
0.2 − 1.2
𝑓 ′ (𝑥𝑖 ) = = −1
2(0.5)
For ℎ = 0.25,
𝑥𝑖−1 = 0.25, 𝑓(𝑥𝑖−1 ) = 1.1035
𝑥𝑖 = 0.5, 𝑓(𝑥𝑖 ) = 0.925
𝑥𝑖+1 = 0.75, 𝑓(𝑥𝑖+1 ) = 0.6363
which can be used to compute the forward finite-divided difference,
0.6363 − 0.925
𝑓 ′ (𝑥𝑖 ) = = −1.1548
0.25
the backward finite-divided difference,
0.925 − 1.1035
𝑓 ′ (𝑥𝑖 ) = = −0.7140
0.25
and the centered finite-divided difference,
0.6363 − 1.1035
𝑓 ′ (𝑥𝑖 ) = = −0.9344
2(0.25)

Example 5.9
Use forward, backward, and centered finite-divided difference more accurate formula to estimate the
first derivative of
𝑓(𝑥) = −0.1𝑥 4 − 0.15𝑥 3 − 0.5𝑥 2 − 0.25𝑥 + 1.2
at 𝑥 = 0.5 using a step size ℎ = 0.25.

Solution
For ℎ = 0.25,
𝑥𝑖−2 = 0, 𝑓(𝑥𝑖−2 ) = 1.2
𝑥𝑖−1 = 0.25, 𝑓(𝑥𝑖−1 ) = 1.1035
𝑥𝑖 = 0.5, 𝑓(𝑥𝑖 ) = 0.925
𝑥𝑖+1 = 0.75, 𝑓(𝑥𝑖+1 ) = 0.6363
𝑥𝑖+2 = 1, 𝑓(𝑥𝑖+2 ) = 0.2
Using forward finite-divided difference more accurate formula [Eq. (5.18)],
−0.2 + 4(0.6363) − 3(0.925)
𝑓 ′ (𝑥𝑖 ) = = −0.8596
2(0.25)
Using backward finite-divided difference more accurate formula [Eq. (5.22)],
3(0.925) − 4(1.1035) + 1.2
𝑓 ′ (𝑥𝑖 ) = = −0.8780
2(0.25)
Using centered finite-divided difference more accurate formula [Eq. (5.26)],
−0.2 + 8(0.6363) − 8(1.1035) + 1.2
𝑓 ′ (𝑥𝑖 ) = = −0.9125
12(0.25)

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 12


5.7 RICHARDSON EXTRAPOLATION
To this point, we have seen that there are two ways to improve derivative estimates when employing
finite divided differences: (1) decrease the step size or (2) use a higher-order formula that employs
more points. A third approach, based on Richardson extrapolation, uses two derivative estimates to
compute a third, more accurate approximation.
The Richardson extrapolation provides a means to obtain an improved integral estimate 𝐼 by the
formula
1
𝐼 ≅ 𝐼(ℎ2 ) + [𝐼(ℎ2 ) − 𝐼(ℎ1 )] (5.29)
(ℎ1 ⁄ℎ2 )2 − 1
where 𝐼(ℎ1 ) and 𝐼(ℎ2 ) are integral estimates using two step sizes ℎ1 and ℎ2 . This formula is usually
written for the case where ℎ2 = ℎ1 ⁄2, as in
4 1
𝐼 ≅ 𝐼(ℎ2 ) − 𝐼(ℎ1 ) (5.30)
3 3
In a similar fashion, Eq. (5.30) can be written for derivatives as
4 1
𝐷 ≅ 𝐷(ℎ2 ) − 𝐷(ℎ1 ) (5.31)
3 3

Example 5.10
Estimate the first derivative of
𝑓(𝑥) = −0.1𝑥 4 − 0.15𝑥 3 − 0.5𝑥 2 − 0.25𝑥 + 1.2
at 𝑥 = 0.5 employing step sizes of ℎ1 = 0.5 and ℎ2 = 0.25. Then use Eq. (5.31) to compute an
improved estimate for the centered finite-divided difference using Richardson extrapolation. Recall
that the true value is -0.9125.

Solution
The first-derivative estimates can be computed with centered differences as
0.2 − 1.2
𝐷(ℎ1 ) = = −1
2(0.5)
and
0.6363 − 1.1035
𝐷(ℎ2 ) = = −0.9344
2(0.25)
The improved estimate can be determined by applying Eq. (5.31) to give
4 1
𝐷 = (−0.9344) − (−1) = −0.9125
3 3

EXERCISE SET

Answer the following problems using the specified method.

1. Evaluate the following integral:


𝜋⁄2
∫ (6 + 3 cos 𝑥) 𝑑𝑥
0
(a) analytically; (b) single application of the trapezoidal rule; (c) multiple-application trapezoidal
rule, with 𝑛 = 2 and 4; (d) single application of Simpson’s 1/3 rule; (e) multiple-application
Simpson’s 1/3 rule, with 𝑛 = 4; (f) single application of Simpson’s 3/8 rule; and (g) multiple-
application Simpson’s 3/8 rule with 𝑛 = 6.

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 13


2. Evaluate the following integral:
4
∫ (1 − 𝑥 − 4𝑥 3 + 2𝑥 5 ) 𝑑𝑥
−2
(a) analytically; (b) single application of the trapezoidal rule; (c) multiple-application trapezoidal
rule, with 𝑛 = 2 and 4; (d) single application of Simpson’s 1/3 rule; (e) single application of
Simpson’s 3/8 rule.
3. Evaluate the integral of the following tabular data with (a) the trapezoidal rule, (b) Simpson’s 1/3
rule, and (c) Simpson’s 3/8 rule.
𝑥 -2 0 2 4 6 8 10
𝑓(𝑥) 35 5 -10 2 5 3 20
4. The force on a sailboat mast can be represented by the following function:
𝑧
𝑓(𝑧) = 200 ( ) 𝑒 −2𝑧⁄𝐻
5+𝑧
where 𝑧 = the elevation above the deck and 𝐻 = the height of the mast. The total force 𝐹 exerted
on the mast can be determined by integrating this function over the height of the mast:
𝐻
𝐹 = ∫ 𝑓(𝑧)𝑑𝑧
0
The line of action can also be determined by integration:
𝐻
∫0 𝑧𝑓(𝑧) 𝑑𝑧
𝑑= 𝐻
∫0 𝑓(𝑧) 𝑑𝑧
(a) Use the composite trapezoidal rule to compute 𝐹 and 𝑑 for the case where 𝐻 = 30 (𝑛 = 6).
(b) Repeat (a) but use multiple-application Simpson’s 1/3 rule.
(c) Repeat (a) but use multiple-application Simpson’s 3/8 rule.
5. Given the data below, find the isothermal work done on the gas as it is compressed from 23 L to
𝑉
3 L (remember that 𝑊 = − ∫𝑉 2 𝑃 𝑑𝑉).
1

𝑉, L 3 8 13 18 23
𝑃, atm 12.5 3.5 1.8 1.4 1.2
(a) Find the work performed on the gas numerically, using the 1-, 2-, and 4-segment trapezoidal
rule.
(b) Repeat (a) using the 1-, 2-, and 4-segment Simpson’s 1/3 rule.
6. Compute the first derivative of the following functions at the specified location and for the specified
step size using forward, backward, and centered finite-divided difference more accurate formula.
(a) 𝑦 = 𝑥 3 + 4𝑥 − 15 at 𝑥 = 0, ℎ = 0.25
(b) 𝑦 = 𝑥 2 cos 𝑥 at 𝑥 = 0.4, ℎ = 0.1
(c) 𝑦 = tan(𝑥/3) at 𝑥 = 3, ℎ = 0.5
(d) 𝑦 = sin(0.5√𝑥) /𝑥 at 𝑥 = 1, ℎ = 0.2
𝑥
(e) 𝑦 = 𝑒 + 𝑥 at 𝑥 = 2, ℎ = 0.2
7. Use Richardson extrapolation to estimate the first derivative of 𝑦 = cos 𝑥 at 𝑥 = 𝜋/4 using step
sizes of ℎ1 = 𝜋/3 and ℎ2 = 𝜋/6. Employ centered finite-divided difference truncated formula for
the initial estimates.
8. The following data were collected for the distance traveled versus time for a rocket:
𝑡, s 0 25 50 75 100 125
𝑦, km 0 32 58 78 92 100

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 14


Use numerical differentiation to estimate the rocket’s velocity and acceleration at each time. Use
centered finite-divided difference truncated formula.
9. The following
𝑡, s 0 4 8 12 16 20 24 28 32 36
𝑣, m/s 0 34.7 61.8 82.8 99.2 112.0 121.9 129.7 135.7 140.4
(a) Using the best numerical method available, how far does the object travel from 𝑡 = 0 to 28 s?
(b) Using the best numerical method available, what is the object’s acceleration at 𝑡 = 28 s?
(c) Using the best numerical method available, what is the object’s acceleration at 𝑡 = 0 s?
10. The velocity (m/s) of an object at time 𝑡 seconds is given by
2𝑡
𝑣=
√1 + 𝑡 2
(a) Use forward, backward, and centered finite divided difference truncated formula to find the
acceleration of the particle at time 𝑡 = 5 s using ℎ = 0.5.
(b) Repeat (a) using ℎ = 0.25.
(c) Employ compute an improved estimate for the centered finite-divided difference using
Richardson’s extrapolation.

SUPPLEMENTARY READING
Read Chapter 24: Case Studies for Numerical Integration and Differentiation on the book
Numerical Methods for Engineers (7th ed.) by Chapra and Canale. The purpose of this supplementary
reading is for you to apply the methods of numerical integration and differentiation discussed in this
module to practical engineering problems.
Two situations are most frequently encountered. In the first case, the function under study can
be expressed in analytic form but is too complicated to be readily evaluated using the methods of
calculus. Numerical methods are applied to situations of this type by using the analytic expression to
generate a table of arguments and function values. In the second case, the function to be evaluated
is inherently tabular in nature. This type of function usually represents a series of measurements,
observations, or some other empirical information.

REFERENCES
1. Chapra, S. C., Canale, R. P. (2015). Numerical Methods for Engineers (7th ed.). The McGraw-Hill
Companies, Inc.
2. Chapra, S. C. (2018). Applied Numerical Methods with MATLAB® for Engineers and Scientists
(4th ed.). The McGraw-Hill Companies, Inc.

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 15

You might also like