Integration
Integration
(NUMERICAL QUADRATURE)
1 Trapezium Rule
4 Romberg Method
4 This integral (2) defines the area under the curve above the x−axis within the interval
[x 0 , x n ].
Dr. Gabby (KNUST-Maths) Numerical Integration 3 / 44
Introduction
These techniques are all based on evaluating the integrand at equally spaced
points. They are named after Isaac Newton and Roger Cotes.
Dr. Gabby (KNUST-Maths) Numerical Integration 4 / 44
Trapezium Rule Simple Trapezium Rule
Then the trapezium method uses the area under the approximate line to obtain
the formula
1 £ ¤
I = h f (a) + f (b) (3)
2
1 h i
= (b − a) f (a) + f (b) ; N =1 (4)
2
Note
The trapezium rule of integration integrates exactly polynomials of degree ≤ 1
Example
Approximate the following integrals using the simple trapezium rule
R5
1 2x 2 d x
R3 π/4
2 sin(x)d x
0
Hence determine the absolute error (AE)
Solution R
5
1. Given 3 2x 2 d x , then a = 3 and b = 5. The functional values are
f (a) = f (3) = 2(3)2 = 18
f (b) = f (5) = 2(5)2 = 50
Therefore
1 £ ¤
I = (b − a) f (a) + f (b) (5)
2
1
= (5 − 3)[18 + 50] (6)
2
= 68 (7)
5 2x 3 ¯¯5
Z ¯
2
2x d x = = 65.33 (8)
3 3 ¯3
π
R π/4
2. Given 0
sin(x)d x , then a = 0 and b = . The functional values are
4
f (a) = f (0) = sin(0) = 0
f (b) = f (π/4) = sin(π/4) = 0.707. Therefore
1 £ ¤
I = (b − a) f (a) + f (b) (9)
2
1
= (π/4 − 0)[0 + 0.707] (10)
2
π
= (0.707) (11)
8
= 15.9075 (12)
Exact solution
Z π/4
¯π/4
¯
sin(x)d x = − cos(x)¯¯ = − cos(π/4) + cos(0) = 0.293 (13)
0 0
Note
The nodal points are given by
a = x 0 , x 1 = x 0 + h, x 2 = x 0 + 2h, · · · , x N = x 0 + N h = b (15)
Example
Find the approximate solution for the following using the composite trapezium rule
with 4 equal sub-intervals.
R5
1 2x 2 d x
3
R2
2 ln(x) d x
0
Solution
b −a 5−3
For 4 sub-intervals =⇒ h = = = 0.5.
N 4
Therefore the x points are
x 0 = 3, x 1 = 3.5, x 2 = 4, x 3 = 4.5, x4 = 5
f (x 0 ) = f (3) = 18 (16)
f (x 1 ) = f (3.5) = 24.5 (17)
f (x 2 ) = f (4) = 32 (18)
f (x 3 ) = f (4.5) = 40.5 (19)
f (x 4 ) = f (5) = 50 (20)
From above the exact solution is 65.33, therefore the absolute error is
Example
Find the derivative of the following functions using the simple Simpson’s 1/3 rule
R5
1 2x 2 d x
R3 3 1
2 dx
1 1+x
b −a 5−3
For 2 sub-intervals =⇒ h = = = 1.
2 2
Therefore the x points are
[x 0 , x 1 , x 2 ] = [3, 4, 5]
The functional value are f (x 0 ) = f (3) = 18 = f (a) (26)
a +b
µ ¶
f (x 1 ) = f (4) = 32 = f (27)
2
f (x 2 ) = f (5) = 50 = f (b) (28)
Dr. Gabby (KNUST-Maths) Numerical Integration 17 / 44
Simpson’s 1/3 Rule Simple Simpson’s 1/3 Rule
4 The composite Simpson’s 1/3 rule is also of order 3, that is the composite
Simpson’s 1/3 rule produces exact results for polynomials of degree ≤ 3.
Example
Find the derivative of the following functions using the composite Simpson’s 1/3
rule using 4 sub-intervals
R5
1 2x 2 d x
R3 3 1
2 dx
1 1+x
Solution
b −a 5−3
For 4 sub-intervals =⇒ h = = = 0.5.
4 4
Therefore the x points are
x 0 = 3, x 1 = 3.5, x 2 = 4, x 3 = 4.5, x 4 = 5
f (x 0 ) = f (3) = 18 (34)
f (x 1 ) = f (3.5) = 24.5 (35)
f (x 2 ) = f (4) = 32 (36)
f (x 3 ) = f (4.5) = 40.5 (37)
f (x 4 ) = f (5) = 50 (38)
(40)
Z 5 hn h i h i o
2x 2 d x = f (x 0 ) + 4 f (x 1 ) + f (x 3 ) + 2 f (x 2 ) + f (x 4 )
3 3
0.5 n o
= 18 + 4(24.5 + 40.5) + 2(32) + 50 (41)
3
= 0.167(392) (42)
= 65.474 (43)
Example
R2 1
Using the Simpson’s 3/8 rule, evaluate 1
d x with 3 and 6 subintervals.
5 + 3x
Compare with the exact solution.
When n = 3, we have the following step lengths and nodal points.
b −a 2−1 1
h= = = (45)
n 3 3
The nodes are
x 0 = 1, x 1 = x 0 + h = 4/3, x 2 = x 1 + h = 5/3, x 2 = 2.0.
We have the following tables of values
x 1.0 4/3 5/3 2.0
f (x) 0.125 0.11111 0.10000 0.09091
Dr. Gabby (KNUST-Maths) Numerical Integration 26 / 44
Simpson’s 3/8 Rule Composite Simpson’s 3/8 Rule
n =3
Z b 3h £ ¤
f (x 0 ) + 3 f (x 1 ) + 3 f (x 2 ) + f (x 3 )
f (x)d x = (46)
a 8
Z 2
1 31
dx = [0.125 + 3(0.11111) + 3(0.10000) + 0.09091] (47)
1 5 + 3x 83
= 0.10616 (48)
Exact Solution
1
F (x) = ln(5 + 3x) (49)
3
¯2 1
F (x)¯ = [ln 11 − ln 8] = 0.10615. (50)
¯
1 3
(51)
The magnitude of the error is 0.00001
Dr. Gabby (KNUST-Maths) Numerical Integration 27 / 44
Simpson’s 3/8 Rule Composite Simpson’s 3/8 Rule
When n=6
b −a 2−1 1
h= = = (52)
6 6 6
We have the following tables of values
x 1.0 7/6 8/6 9/6 10/6 11/6 2.0
f (x) 0.125 0.11765 0.11111 0.10526 0.10000 0.09524 0.09091
Z b 3h
f (x)d x =
[ f (x 0 ) + 3 f (x 1 ) + 3 f (x 2 ) + 2 f (x 3 ) + 3 f (x 4 ) + 3 f (x 5 ) + f (x 6 )] (53)
a 8
Z 2
1 31
dx = [0.125 + 3(0.11765 + 0.11111 + 0.10000 + 0.09524) + 2(0.10526) + 0.09091]
1 5 + 3x 86
(54)
= 0.10615 (55)
Dr. Gabby (KNUST-Maths) Numerical Integration 28 / 44
Romberg Method
Romberg Method
Definition
The Richardson extrapolation is a sequence acceleration method used to improve
the rate of convergence of a sequence of estimates of some value say A .
Example
R1 1
Solve 0 d x using Romberg method with two sub-interval. Compute your
1+x
initial values using the composite trapezium method.
Perform two iterations.
Recall that the½composite
· trapezium formula is
h
¸ ¾
Rb
a f (x)d x = f (x 0 ) + 2 f (x 1 ) + f (x 2 ) + · · · + f (x N 1 ) + f (x N ) where h = (b − a)/N
2
The approximations using the trapezium rule to the integral with various values of
the step lengths were obtained as follows:
1st h: N = 2 =⇒ h0 = 1/2, =⇒ I (0) (1/2) = 0.708334 (57)
2nd h: h = h0 /2 = 1/4, =⇒ N = 4 =⇒ I (0) (1/4) = 0.697024 (58)
2 (0)
3rd h: h = h0 /2 = 1/8, =⇒ N = 8 =⇒ I (1/8) = 0.694122. (59)
Dr. Gabby (KNUST-Maths) Numerical Integration 32 / 44
Romberg Method Romberg method for the trapezium rule
When m = 1, h = 1/2
4m I (m−1) (h/2) − I (m−1) (h)
I (m) (h) = ; m = 1, 2, 3, · · · (60)
4m − 1
4I (0) (1/4) − I (0) (1/2)
I (1) (1/2) = (61)
4−1
4(0.697024) − 0.708334
= (62)
3
= 0.693254 (63)
When m = 2, h = 1/2
42 I (1) (1/4) − I (1) (1/2)
I (2) (1/2) = (64)
42 − 1
But I (1) (1/4) is not known. This should be computed with the same formula with
h = 1/4
Dr. Gabby (KNUST-Maths) Numerical Integration 33 / 44
Romberg Method Romberg method for the trapezium rule
When m = 1, h = 1/4
4I (0) (1/8) − I (0) (1/4)
I (1) (1/4) = (65)
4−1
4(0.694122) − 0.697024
= (66)
3
= 0.693155 (67)
Exact Solution
1 The Romberg extrapolation procedure for the composite Simpson’s 1/3 rule is
Example
R1 1
Solve 0
d x using Romberg method with two sub-interval. Compute your
1+x
initial values using the composite Simpson’s 1/3 method.
Perform two iterations.
The approximations using the Simpson’s 1/3 rule to the integral with various
values of the step lengths were obtained as follows:
When m = 1, h = 1/2
4m+1 I (m−1) (h/2) − I (m−1) (h)
I (m) (h) = ; m = 1, 2, 3, · · · (78)
4m+1 − 1
16I (0) (1/4) − I (0) (1/2)
I (1) (1/2) = (79)
16 − 1
16(0.693254) − 0.694444
= (80)
15
= 0.693175 (81)
When m = 2, h = 1/2
43 I (1) (1/4) − I (1) (1/2)
I (2) (1/2) = (82)
43 − 1
But I (1) (1/4) is not known. This should be computed with the same formula with
h = 1/4
Dr. Gabby (KNUST-Maths) Numerical Integration 38 / 44
Romberg Method Romberg method for the Simpson’s 1/3 rule
When m = 1, h = 1/4
16I (0) (1/8) − I (0) (1/4)
I (1) (1/4) = (83)
16 − 1
16(0.693155) − 0.693244
= (84)
15
= 0.693148 (85)
Exact Solution
Exercise
Evaluate the function Z 6 1
0 1 + x2
using
1 Simple trapezium rule
2 Composite trapezium rule with 6 sub-intervals
3 Simple Simpson’s 1/3 rule
4 Composite Simpson’s 1/3 rule with 8 sub-intervals
5 Romberg method with two sub-interval for three iterations. Compute your
initial values using the Simpson’s 1/3 method.
6 Romberg method with two sub-interval. Compute your initial values using the
Trapezium method. Take ϵ = 1−5
Dr. Gabby (KNUST-Maths) Numerical Integration 43 / 44
END OF LECTURE
THANK YOU