Chapter 3 Numerical Integration: in This Chapter, You Will Learn
Chapter 3 Numerical Integration: in This Chapter, You Will Learn
Chapter 3 Numerical Integration: in This Chapter, You Will Learn
b
The exact value of a definite integral ∫
a
f ( x)dx can be computed only when the function
f ( x ) is integrable in finite terms.
The definite integral of a function has an interpretation as the area under a curve.
Whenever the function f ( x ) cannot be exactly integrated in finite terms or the evaluation
of its integral is complicated, we can use the numerical integration. The numerical
integrations that we are going to discuss in this chapter are Trapezoidal rule, Simpson’s
rule and Romberg algorithm.
Adapted from
Ward Cheney, David Kincaid, (2008) Numerical Mathematics and Computing, 6th Edition, 1
Brooks/Cole Cengage Learning, ISBN 0-534-8993-7
TMA1301 Computational Methods
Chapter 3: Numerical Integration
A1 A2 An
a = x1 x2 x3 xn-1 xn xn+1= b
the interval from a to b into n equal parts, so that each part is equal to h =
(b − a ) .
n
a 2
The above formula is known as the Composite Trapezoidal rule for numerical integration.
Example 3: Dividing the range into 4 equal parts, find the approximate value of
1 1
∫0 1 + x 2 dx by using Composite Trapezoidal rule.
1− 0
n = 4; f ( x ) =
1
; h= = 0.25
1+ x 2
4
AT =
0.25
{ f (0) + f (1) + 2[ f (0.25) + f (0.5) + f (0.75)]}
2
=
0.25
(6.262353)
2
= 0.782794
Adapted from
Ward Cheney, David Kincaid, (2008) Numerical Mathematics and Computing, 6th Edition, 2
Brooks/Cole Cengage Learning, ISBN 0-534-8993-7
TMA1301 Computational Methods
Chapter 3: Numerical Integration
Example 4: Compute an approximate value for integral given in Example 2 by using the
Composite Trapezoidal rule with 5 points. Then compare with the actual value of the
integral and find its absolute error.
2−0
Integral in Example 2: ∫ 3 x 2 + e x dx ; 5 points ⇒ n = 4 ; f ( x ) = 3 x 2 + e x ; h =
2
= 0.5
0 4
AT =
0.5
{ f (0) + f (2) + 2[ f (0.5) + f (1.0) + f (1.5)]}
2
=
0.5
(59.08644)
2
= 14.77161
2
Actual value, I = ∫ 3 x 2 + e x dx = __________________
0
A1 A2 An
the interval from a to b into 2n equal parts, so that each part is equal to h =
(b − a ) .
2n
Adapted from
Ward Cheney, David Kincaid, (2008) Numerical Mathematics and Computing, 6th Edition, 3
Brooks/Cole Cengage Learning, ISBN 0-534-8993-7
TMA1301 Computational Methods
Chapter 3: Numerical Integration
Total area,
h f ( x1 ) + f ( x 2 n +1 ) + 4[ f ( x 2 ) + f ( x 4 ) + ... + f ( x 2 n )]
AS = ∫ f ( x )dx ≈ where x n = a + (n − 1)h, n = 1,2,..
b
a 3 + 2[ f ( x3 ) + f ( x5 ) + ... + f ( x 2 n −1 )]
Example 5: Dividing the range into 4 equal parts, find the approximate value of
1 1
∫0 1 + x 2 dx by using Simpson’s rule.
11
AS = { f (0) + f (1) + 4[ f (0.25) + f (0.75)] + 2 f (0.5)}
3 4
= (9.42470588)
1
12
= 0.785392
Example 6: Compute an approximate value for integral given in Example 2 by using the
Simpson’s rule with 5 points. Then compare with the actual value of the integral and find
its absolute error.
2−0
+ e x dx ; 5 points ⇒ n = 4 ; f ( x ) = x 2 ; h =
2
∫ 3x = 0.5
2
Integral in Example 1:
0 4
AS =
1
(0.5){ f (0) + f (2) + 4[ f (0.5) + f (1.5)] + 2[ f (1.0)]}
3
=
0.5
(86.34726)
3
= 14.39121
2
Actual value, I = ∫ 3 x 2 + e x dx = __________________
0
Adapted from
Ward Cheney, David Kincaid, (2008) Numerical Mathematics and Computing, 6th Edition, 4
Brooks/Cole Cengage Learning, ISBN 0-534-8993-7
TMA1301 Computational Methods
Chapter 3: Numerical Integration
The Romberg algorithm produces a triangular array of numbers, all of which are
b
numerical estimates of the definite integral ∫a
f ( x)dx . The array is denoted here by the
notation
m
n 0 1 2 3 …
0 R (0,0 )
1 R (1,0 ) R (1,1)
2 R (2,0) R (2,1) R (2,2)
3 R (3,0) R (3,1) R (3,2 ) R (3,3)
M M M M M O
R (n,0 ) R (n,1) R (n,2 ) R (n,3) L R (n, m )
The first column of this table contains estimates of the integral obtained by the recursive
trapezoid formula with decreasing values of the step size. Explicitly, R(n,0 ) is the result
of applying the trapezoid rule with 2 equal subintervals. The first of them, R(0,0 ) , is
n
R (0,0 ) =
1
(b − a )[ f (a ) + f (b )]
2
n −1
R (n,0) =
1 2
R (n − 1,0) + h ∑ f [a + (2k − 1)h] ; h =
(b − a ) , n ≥ 1
2 k =1 2n
The second and successive columns in the Romberg array are generated by the
extrapolation formula
R(n, m ) = R(n, m − 1) +
1
[R(n, m − 1) − R(n − 1, m − 1)]
4 −1 m
with n ≥ 1 , m ≥ 1 and m ≤ n .
Adapted from
Ward Cheney, David Kincaid, (2008) Numerical Mathematics and Computing, 6th Edition, 5
Brooks/Cole Cengage Learning, ISBN 0-534-8993-7
TMA1301 Computational Methods
Chapter 3: Numerical Integration
R (8,3) = R (8,2) +
1
[R(8,2) − R(4,2)]
63
73
=
9
1 1
Example 8: Compute ∫ 1+ x
0 2
dx by the Romberg algorithm using 4 equal parts and show
your calculations correct to SIX decimal places. Then, compare with the values obtained
from the methods of Composite Trapezoidal rule (Example 3) and Simpson’s rule
(Example 5).
n 0 1 2 3
0 0.750000
1 0.775000 0.783333
2 0.782794
Adapted from
Ward Cheney, David Kincaid, (2008) Numerical Mathematics and Computing, 6th Edition, 6
Brooks/Cole Cengage Learning, ISBN 0-534-8993-7