Unit 7-Ch21&22
Unit 7-Ch21&22
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
a
b
f ( x)dx
b
a
f 2 ( x)dx
a
b
(a 0 + a1 x + a 2 x )
2
dx
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
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.
1
(xi +1 − xi )( f ( xi +1 ) + f ( xi ) )
b
a
f ( x)dx
i =0 2
(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.
Obtain an estimate of
the distance traveled in
the interval [0,3].
18
Example 1
The interval is divided Time (s) 0.0 1.0 2.0 3.0
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
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
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
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.
h b−a
I f ( x0 ) + 4 f ( x1 ) + f ( x2 ) h=
3 2
(b − a)5 ( 4)
Et = − f ( ) a b
2880
• 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.
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
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
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
45
Example
Use order of h8 Romberg integration to evaluate
3
2x
xe dx
0
Estimate approximate percent error.