0% found this document useful (0 votes)
12 views17 pages

Numerical Integration

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views17 pages

Numerical Integration

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

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.

• Based on polynomial interpolation.


• Integral is approximated by integral of P(x).
• When sample points x0=a and xM=b are used, it
is called closed Newton-Cotes formula.
Newton-Cotes
Quadrature Formulas
Assume that xk=x0+kh are equally spaced
nodes of fk=f(xk). The first four closed
Newton-Cotes quadrature formulas are:

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

and the approximation using Boole’s rule is


best.
Composite Trapezoidal Rule
To approximate the integral, y
subdivide the interval [a, b]
into n subintervals [xk, xk+1]
of width h=(b-a)/n by using
the equally spaced nodes x
a b
xk=a+kh, for k=0,1,…, n.
n
b h
∫ f (x )dx ≈ ∑ ( f (xk −1 ) + f (xk ))
k =1 2
a

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

Solution: The analytical value is 8.1834792. Here,


n=10 and h=(6-1)/10=0.5. Therefore
0.5
∫[ ( )]
6
2 + sin 2 x dx ≈ ( f (1) + f (6))
1 2
+ 0.5 × [ f (1.5) + f (2) + f (2.5) + f (3) + f (3.5)
+ f (4) + f (4.5) + f (5) + f (5.5)] = 8.1938546
Composite Simpson Rule
To approximate the integral, y
subdivide the interval [a, b]
into 2n subintervals [xk, xk+1]
of width h=(b-a)/2n by using
the equally spaced nodes x
a b
xk=a+kh, for k=0,1,…, 2n.
b h n
∫a f (x )dx ≈ 3 ∑
k =1
( f (x2k −2 ) + 4 f (x2k −1 ) + f (x2k ))
h 2h n −1 4h n
≈ ( f (a ) + f (b )) + ∑ f (x2 k ) + ∑ f (x2 k −1 )
3 3 k =1 3 k =1
Example
Evaluate the definite integral using composite Simpson
rule with 11 sample points.
6
[ ( )]
I = ∫ 2 + sin 2 x dx
1

Solution: To generate 11 sample points, n=5 and


h=(6-1)/10=0.5. Therefore
0.5
I≈ ( f (1) + f (6)) + 13 × [ f (2) + f (3) + f (4) + f (5)]
3
+ 23 × [ f (1.5) + f (2.5) + f (3.5) + f (4.5) + f (5.5)]
= 8.18301550
Exercises
Approximate the integral using the composite
trapezoidal rule with n=10.
π
−x 4
∫ sin (2 x )e dx ∫
2 −x
x e dx
0 0
Approximate the same integrals using composite
Simpson rule with n=5.
n −1
h
I ≈ ( f (a ) + f (b )) + h∑ f (xk )
2 k =1

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

You might also like