Numerical Integration
Numerical Integration
Introduction
• Numerical integration is a primary tool
used by engineers and scientist
• To obtain approximate answers for definite
integrals that cannot be solved analytically.
b
I = ∫ f (x )dx
a
Quadrature Formulas
b M
I = ∫ f (x )dx ≈ ∑ wk f (xk )
a
k =0
where xk are called nodes and wk are weights.
b
1. Trapezoidal Rule I = ∫ f (x )dx
y a
2. Simpson’s Rule
3. Simpson’s 3/8 Rule
4. Boole’s Rule a b
x
Trapezoidal Rule
• The first of the Newton-Cotes closed
integration formula
b f ( a ) + f (b )
I = ∫ f ( x ) dx ≅ (b − a )
a 2
• Geometrically, the integral is equivalent to
approximating the area of the trapezoid
under the straight line connecting f(a) and
f(b).
Trapezoidal Rule
• Approximates integral using y = P1(x)
b h
∫ f (x )dx ≈ ( f a + f b )
a 2
y
x
a b
Simpson’s Rule
• Approximates integral using y = P2(x)
c h
∫ f (x )dx ≈ ( f a + 4 f b + f c )
a 3
y
h h x
a b c
Simpson’s 3/8 Rule
• Approximates integral using y = P3(x)
d 3h
∫ f (x )dx ≈ ( f a + 3 f b + 3 f c + f d )
a
y
8
h h h x
a b c d
Boole’s Rule
• Approximates integral using y = P4(x)
d 2h
∫ f (x )dx ≈ (7 f a + 32 f b + 12 f c + 32 f d + 7 f e )
a 45
y
h h h h x
a b c
Example
Evaluate the definite
f (x ) = 1 + e − x sin (4 x )
integral using the first
four Newton-Cotes
quadrature formulas.
1
∫0
[
1 + e −x
]
sin (4 x ) dx
Solution
Trapezoidal Rule (h = 1)
1 1 1
∫ f (x ) dx ≈ ( f (0) + f (1)) = (1.00 + 0.72159 ) = 0.86079
0 2 2
Simpson’s Rule (h = 1/2)
1 12
∫ f (x ) dx ≈ ( f (0) + 4 f (12 ) + f (1)) = 1.32128
0 3
Simpson’s 3/8 Rule (h = 1/3)
1 3(1 3)
∫ f (x ) dx ≈ ( f (0) + 3 f (13 ) + 3 f (23 ) + f (1)) = 1.31440
0 8
Boole’s Rule (h = 1/4)
1 2(1 4)
∫ f (x ) dx ≈ (7 f (0) + 12 f (14 ) + 12 f (12 ) + 32 f (34 ) + 7 f (1))
0 45 = 1.30859
Solution
The analytical solution is
1 21e − 4 cos(4) − sin (4)
∫ f (x ) dx = = 1.3082506046426
0 17e
n −1
h
≈ ( f (a ) + f (b )) + h∑ f (xk )
2 k =1
Example
Evaluate the definite integral using composite
trapezoidal rule with 11 sample points.
∫ [2 + sin (2 x )]dx
6
h 2h n −1 4h n
I ≈ ( f (a ) + f (b )) + ∑ f (x2 k ) + ∑ f (x2 k −1 )
3 3 k =1 3 k =1