0% found this document useful (0 votes)
9 views46 pages

Unit 7-Ch21&22

The document covers numerical integration methods, specifically focusing on Newton-Cotes methods including the Trapezoid and Simpson's rules. It explains how to approximate integrals using polynomials of varying orders, outlines the error estimation for these methods, and provides examples for practical application. Additionally, it discusses the advantages of using higher-order polynomials for more accurate results in numerical integration.

Uploaded by

faisalqlm02
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)
9 views46 pages

Unit 7-Ch21&22

The document covers numerical integration methods, specifically focusing on Newton-Cotes methods including the Trapezoid and Simpson's rules. It explains how to approximate integrals using polynomials of varying orders, outlines the error estimation for these methods, and provides examples for practical application. Additionally, it discusses the advantages of using higher-order polynomials for more accurate results in numerical integration.

Uploaded by

faisalqlm02
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/ 46

CHE 360: Numerical Methods in CHE

Unit 7
Numerical Integration
Chapter 21 & 22

1
The Area Under the Curve
One interpretation of the definite integral is:
Integral = area under the curve

f(x)

b
Area =  f(x)dx
a

a b
2
Newton-Cotes Methods
• In Newton-Cote Methods, the function is
approximated by a polynomial of order n.
• Computing the integral of a polynomial is easy.
b b
a
f ( x)dx  
a
f n ( x)dx

a
b
f ( x)dx  
a
b
(a 0 + a1 x + ... + a n x )
n
dx
b (b 2 − a 2 ) (b n +1 − a n +1 )
a
f ( x)dx a0 (b − a ) + a1
2
+ ... + an
n +1

3
Newton-Cotes Methods
• Trapezoid Method (First Order Polynomials are used)

(a0 + a1 x )dx
b b b
a
f ( x)dx  
a
f1 ( x)dx  
a

• Simpson 1/3 Rule (Second Order Polynomials are used)

a
b
f ( x)dx  
b

a
f 2 ( x)dx  
a
b
(a 0 + a1 x + a 2 x )
2
dx

• Simpson 3/8 Rule (Third Order Polynomials are used)

a
b
f ( x)dx  
b

a
f 3 ( x)dx  
a
b
(a 0 + a1 x + a 2 x 2
+ a3 x )
3
dx

4
The approximation of an integral
by the area under simple polynomials

straight line (1st order) parabola (2nd order)


Trapezoid Method
b
I =  f ( x)dx
f (b) − f (a) a
f (a) + ( x − a)
b−a b  f (b) − f (a ) 
I    f (a) + ( x − a ) dx
f(x)
a
 b−a 
b
 f (b) − f (a ) 
=  f (a) − a x
 b−a  a
2 b
f (b) − f (a) x
+
b−a 2 a
a b f (b) + f (a)
= (b − a )
2
6
Trapezoid Method

f(x)

f (b)

f (a )
b−a
Area = ( f (a) + f (b))
2
a b
7
Error in estimating the integral
Theorem
Assumption : f ' ' ( x) is continuous on [a,b]
Equal intervals (width = h)
Theorem : If Trapezoid Method is used to
b
approximate  a
f ( x)dx then
b − a 2 ''
Error = − h f ( ) where   [a,b]
12
b−a 2
Error  h max f ' ' ( x)
12 x[ a ,b ]

8
Error of a Single Application of the
Trapezoidal Rule
• When we employ the integral under a straight line
segment to approximate the integral under a curve,
error may be substantial:

1
Et = − f  ( )( b − a )
3

12
• where  lies somewhere in the interval from a to b.
Example - Trapezoid Method
Numerically integrate from a = 0 to b = 0.8.

Correct value for the integral is 1.640533


Sometimes the Trapezoidal Rule Can Yield
a Large Error
Trapezoid Method
Multiple Application Rule
f ( x2 ) + f ( x1 )
Area = (x2 − x1 )
f(x) 2
The interval [a, b] is
partitioned into n segments
a = x0  x1  x2  ...  xn = b
b

a
f ( x)dx = sum of the areas
of the trapezoids
x
x0 x1 x2 x3
a b
12
Trapezoid Method
General Formula and Special Case
If the interval is divided into n segments (not necessarily equal)
a = x0  x1  x2  ...  xn = b
n −1


1
(xi +1 − xi )( f ( xi +1 ) + f ( xi ) )
b
 a
f ( x)dx 
i =0 2

Special Case ( Equally spaced base points)


xi +1 − xi = h for all i
1 n −1

f ( x)dx  h   f ( x0 ) + f ( xn ) +  f ( xi ) 
b
 a
2 i =1 
13
Trapezoid Method
Multiple Application Rule
Error of Multiple Application Trapezoidal
Rule
• An error for multiple-application trapezoidal rule can
be obtained by summing the individual errors for each
segment:
 f (i )  nf 

(b − a ) 3
Ea = − f 
12n 2
• Thus, if the number of segments is doubled, the
truncation error will be quartered.
Example – Multiple Application Trapezoid Method
Use two-segment trapezoidal rule to numerically
integrate from a = 0 to b = 0.8.

Correct value for the integral is 1.640533


Example – Trapezoidal Rule
𝜋Τ2
න 8 + 4 𝑐𝑜𝑠 𝑥 𝑑𝑥
0

• Use single application of the trapezoidal rule


• Use multiple-application trapezoidal rule with n = 4
Example
Given a tabulated Time (s) 0.0 1.0 2.0 3.0
values of the velocity of
an object. Velocity (m/s) 0.0 10 12 14

Obtain an estimate of
the distance traveled in
the interval [0,3].

Distance = integral of the velocity


3
Distance =  0
V (t ) dt

18
Example 1
The interval is divided Time (s) 0.0 1.0 2.0 3.0

into 3 subintervals Velocity 0.0 10 12 14

Base points are0,1,2,3


(m/s)

Trapezoid Method
h = xi +1 − xi = 1
 n −1 
T = h  f ( xi ) + ( f ( x0 ) + f ( xn ) )
1
 i =1 2 
 1 
Distance = 1(10 + 12) + (0 + 14) = 29
 2 
19
Estimating the Error
For Trapezoid Method

How many equally spaced intervals are



needed to compute  0
sin( x)dx
to 5 decimal digit accuracy?

20
Example


1
sin( x )dx, find h so that error   10−5
2
0
b−a 2
Error  h max f ' ' ( x )
12 x[ a ,b ]
b =  ; a = 0; f ' ( x ) = cos( x ); f ' ' ( x ) = − sin( x )
1
f ' ' ( x )  1  Error  h   10−5
2
12 2
2 6
 h   10−5  h  0.00437

(b − a ) 
 n = = 719 intervals
h 0.00437
21
Example
x 1.0 1.5 2.0 2.5 3.0

f(x) 2.1 3.2 3.4 2.8 2.7

3
Use Trapezoid method to compute :  1
f ( x)dx

n −1
Trapezoid T ( f , P ) =  ( xi +1 − xi )( f ( xi +1 ) + f ( xi ) )
1
i =0 2

Special Case : h = xi +1 − xi for all i,


 n −1 
T ( f , P ) = h  f ( xi ) + ( f ( x0 ) + f ( xn ) )
1
 i =1 2 
22
Example
x 1.0 1.5 2.0 2.5 3.0

f(x) 2.1 3.2 3.4 2.8 2.7

n−1 
f ( x)dx  h  f ( xi ) + ( f ( x0 ) + f ( xn ) )
3 1
1  i =1 2 
 
= 0.5  3.2 + 3.4 + 2.8 + (2.1 + 2.7 )
1
 2 
= 5.9
23
Simpson’s Rules
• More accurate estimate of an integral is obtained if a
high-order polynomial is used to connect the points.
The formulas that result from taking the integrals under
2nd & 3rd-order polynomials are called Simpson’s rules.

• Simpson’s 1/3 Rule:

• Results when a second-order interpolating polynomial


is used.
Simpson’s Rules

Simpson’s 1/3 Rule Simpson’s 3/8 Rule


Simpson’s 1/3 Rule
b b
I=  f ( x)dx   f 2 ( x)dx
a a
where a = x0 & b = x2
x2
 ( x − x1 )( x − x2 ) ( x − x0 )( x − x2 ) ( x − x0 )( x − x1 ) 
I=  
( x − x1 )( x0 − x2 )
f ( x0 ) +
( x1 − x0 )( x1 − x2 )
f ( x1 ) +
( x2 − x0 )( x2 − x1 )
f ( x2 dx
)
x0  0 

h b−a
I  f ( x0 ) + 4 f ( x1 ) + f ( x2 ) h=
3 2

• Simpson’s 1/3 Rule


• Single segment application of Simpson’s 1/3 rule has a truncation error of:

(b − a)5 ( 4)
Et = − f ( ) a  b
2880

Simpson’s 1/3 rule is more accurate than trapezoidal rule.


Example – Simpson’s 1/3 Rule
Use Simpson’s 1/3 rule to numerically integrate
from a = 0 to b = 0.8.

Correct value for the integral is 1.640533


The Multiple-Application Simpson’s 1/3
Rule
• Just as the trapezoidal rule, Simpson’s rules can be
improved by dividing the integration interval into a
number of segments of equal width.
• Yields accurate results and considered superior to
trapezoidal rule for most applications.
• However, it is limited to cases where values are equi-
spaced.
• Further, it is limited to situations where there are an
even number of segments and odd number of points.
The Multiple-Application Simpson’s 1/3
Rule

• Can only be
used for even
number of
segments

f ( x0 ) + 4 f ( x1 ) + f ( x2 ) f ( x2 ) + 4 f ( x3 ) + f ( x4 )
I  2h + 2h
6 6
f ( xn − 2 ) + 4 f ( xn −1 ) + f ( xn )
+ + 2h
6
WEIGHTS
The Multiple-Application Simpson’s 1/3
Rule

(b − a ) 5
(4)
Ea = − 4
f
180n
Example – Multiple- Application Simpson’s 1/3 Rule
With n = 4, use Simpson’s 1/3 rule to numerically
integrate from a = 0 to b = 0.8.

Correct value for the


integral is 1.640533
Simpson’s 3/8 Rule
• An odd-segment-even-point formula used in
conjunction with the 1/3 rule to permit evaluation of
both even and odd numbers of segments.
b b
I=  f ( x)dx   f3 ( x)dx
a a

3h
I  f ( x0 ) + 3 f ( x1 ) + 3 f ( x2 ) + f ( x3 )
8

(b − a ) (b − a )5 (4)
h= Et = − f ( )
3 6480
Simpson’s 1∕3 and 3∕8 rules

• Illustration of how
Simpson’s 1∕3 and
3∕8 rules can be
applied in tandem to
handle multiple
applications with
odd numbers of
intervals.
Example – Simpson’s 3/8 Rule

(b) Use it in conjunction with Simpson’s 1/3 rule to integrate the


same function for five segments.
Solution (a): A single application of Simpson’s 3/8 rule requires four equally spaced
points
Example – Simpson’s 3/8 Rule

Correct value for the integral is 1.640533


Summary
Example
𝜋/2
න (8 + 4 cos 𝑥) 𝑑𝑥
0

a) single application of the trapezoidal rule


b) multiple-application trapezoidal rule, with n = 4
c) single application of Simpson’s 1/3 rule
d) multiple-application Simpson’s 1/3 rule, with n = 4
e) single application of Simpson’s 3/8 rule
f) multiple-application Simpson’s rule, with n = 5.
Romberg Integration
• Is based on successive application of the trapezoidal
rule to attain efficient numerical integrals of functions.

Richardson’s Extrapolation
• Uses two estimates of an integral to compute a third
and more accurate approximation.
Romberg Integration
• The estimate and error associated with a multiple-application
trapezoidal rule can be represented generally as

I = I ( h) + E (h)
I =exact value of integral
h = (b − a ) / n
I(h) =the approximation
I (h1 ) + E (h1 ) = I (h2 ) + E (h2 ) from an n segment
application of trapezoidal
n = (b − a ) / h rule with step size h
b−a 2 E(h) =the truncation error
E h f 
12 Assumed constant
regardless of step size
E (h1 ) h12
 2
E (h2 ) h2
2
h 
E (h1 )  E (h2 )  1 
 h2 
Romberg Integration
2
 h1 
I (h1 ) + E (h2 )    I (h2 ) + E (h2 )
 h2 
I (h1 ) − I (h2 )
E (h2 )  2
1 −  1 
h
 h2 

I = I (h2 ) + E (h2 )


1 
I  I (h2 ) + 2  I (h2 ) − I (h1 ) Improved estimate of the integral
 h1  − 1 
 h 
 2 
ROMBERG INTEGRATION

Error Level O(h 2 ) O(h 4 ) O(h 6 ) O(h8 )


4k −1 I j +1,k −1 − I j ,k −1
I j,K  k −1
4 −1
ROMBERG ERROR ESTIMATE
4 1
I 2 − I1
3 3

1.367467 − 1.068800
a =  100% = 21.8%
1.367467

I1,k − I 2,k −1
a =  100%
I1,k
Romberg Method
Estimates using Trapezoid method intervals of size h, h/2, h/4, h/8 ...


b
are combined to improve the approximation of f(x) dx
a

First column is obtained R(0,0)


using Trapezoid Method
R(1,0) R(1,1)

R(2,0) R(2,1) R(2,2)

R(3,0) R(3,1) R(3,2) R(3,3)


The other elements
are obtained using
the Romberg Method
44
Stopping Criteria
STOP if
R ( n, n ) − R ( n, n − 1)  
or
After a given number of steps,
for example, STOP at R(4,4)

45
Example
Use order of h8 Romberg integration to evaluate

3

2x
xe dx
0
Estimate approximate percent error.

You might also like