Chapter 3 Numerical Integration: in This Chapter, You Will Learn

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

TMA1301 Computational Methods

Chapter 3: Numerical Integration

CHAPTER 3 NUMERICAL INTEGRATION


In this Chapter, you will learn:

• the definite integral,


• three methods to do the numerical integration when the integral is complicated.

3.1. DEFINITE INTEGRAL

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.

Example 1: Find the following definite integral.


2
2 x3
∫ x dx =
2
0 3 0
3
2 03
= −
3 3
8
=
3

Example 2: Find the following definite integral.


2
∫0
3x 2 + e x dx =

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

3.2. TRAPEZOIDAL RULE

A1 A2 An

a = x1 x2 x3 xn-1 xn xn+1= b

Let CD be the curve and its equation is y = f ( x ) . To evaluate


b
∫a
f ( x)dx , we subdivide

the interval from a to b into n equal parts, so that each part is equal to h =
(b − a ) .
n

The area of the first trapezium, A1 =


h
[ f (x1 ) + f (x 2 )]
2

The area of the second trapezium, A2 =


h
[ f (x2 ) + f (x3 )]
2

And the area of nth trapezium, An =


h
[ f (xn ) + f (xn+1 )]
2
Total area,
AT = ∫ f ( x )dx ≈
h
{ f (x1 ) + f (x n+1 ) + 2[ f (x 2 ) + f (x3 ) + ... + f (x n )]} where x n = a + (n − 1)h, n = 1,2,..
b

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

Absolute Error = Actual value − Approximated value

3.3. SIMPSON’S RULE

A1 A2 An

a = x1 x2 x3 x2n-1 x2n x2n+1= b

Let CD be the curve and its equation is y = f ( x ) . To evaluate


b
∫ a
f ( x)dx , we subdivide

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

By Simpson’s parabolic rule,

the first area, A1 = h[ f ( x1 ) + 4 f ( x 2 ) + f ( x3 )]


1
3

the second area, A2 = h[ f ( x3 ) + 4 f ( x 4 ) + f ( x5 )]


1
3

and the nth area, An = h[ f ( x 2 n −1 ) + 4 f ( x 2 n ) + f ( x 2 n +1 )]


1
3

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.
11
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

Absolute Error = Actual value − Approximated value

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

3.4. ROMBERG ALGORITHM

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

obtained with just one trapezoid:

R (0,0 ) =
1
(b − a )[ f (a ) + f (b )]
2

Note that R(n,0 ) is obtained easily from R(n − 1,0 ) , that is

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

Example 7: If R (8,2 ) = 8 and R(4,2 ) = 1 , what is R (8,3) ?

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

You might also like