Lecture09 - Numerical Integration (I)
Embed Size (px)
Transcript of Lecture09 - Numerical Integration (I)

Numerical Differentiation and Integration
Lecture 9:Numerical Integration (I)
MTH2212 – Computational Methods and Statistics

Dr. M. HrairiDr. M. Hrairi MTH2212 - Computational Methods and StatisticsMTH2212 - Computational Methods and Statistics 22
Objectives
Introduction Trapezoidal Rule Multiple-Application Trapezoidal Rule Simpson’s 1/3 Rule Multiple-Application Simpson’s 1/3 Rule

Dr. M. HrairiDr. M. Hrairi MTH2212 - Computational Methods and StatisticsMTH2212 - Computational Methods and Statistics 33
Integration – Graphical representation
The integral is the area under the curve

Dr. M. HrairiDr. M. Hrairi MTH2212 - Computational Methods and StatisticsMTH2212 - Computational Methods and Statistics 44
Integration – Engineering applications
How to take complicated integrals and approximate the area under the curve
Integration needed for analyzing irregularly shaped lines, areas, volumes
Examples:

Dr. M. HrairiDr. M. Hrairi MTH2212 - Computational Methods and StatisticsMTH2212 - Computational Methods and Statistics 55
Newton-Cotes Integration Formulas
The Newton-Cotes formulas are the most common numerical integration schemes.
This involves the replacement of a complicated function or tabulated data with an approximating function that is easy to integrate.
Where fn(x) is a polynomial of order n
b
a nb
adxxfdxxfI )()(
nn
nnn xaxaxaxaaxf
11
2210 ...)(

Dr. M. HrairiDr. M. Hrairi MTH2212 - Computational Methods and StatisticsMTH2212 - Computational Methods and Statistics 66
Newton-Cotes Integration Formulas
Closed and open forms Closed: data points at the beginning and end of the limits of integration are
known Open: integration limits that extend beyond the range of data

Dr. M. HrairiDr. M. Hrairi MTH2212 - Computational Methods and StatisticsMTH2212 - Computational Methods and Statistics 77
Trapezoidal Rule
The Trapezoidal rule is the first of the Newton-Cotes closed integration formulas, corresponding to the case where the polynomial is first order i.e. n = 1
f1(x) is expressed using linear interpolation formula
The area under the straight line is an estimate of the integral of f1(x):
b
a
b
adxxfdxxfI )()( 1
)()()(
)()(1 axab
afbfafxf
dxaxab
afbfafI
b
a
)()()(
)(

Dr. M. HrairiDr. M. Hrairi MTH2212 - Computational Methods and StatisticsMTH2212 - Computational Methods and Statistics 88
Trapezoidal Rule
The result of this integration is
2
)()()(
bfafabI
Trapezoidal rule

Dr. M. HrairiDr. M. Hrairi MTH2212 - Computational Methods and StatisticsMTH2212 - Computational Methods and Statistics 99
Trapezoidal Rule
2
)()()(
bfafabI
Area of a trapezoid = Width X Average Height

Dr. M. HrairiDr. M. Hrairi MTH2212 - Computational Methods and StatisticsMTH2212 - Computational Methods and Statistics 1010
Error of the Trapezoidal Rule
Truncation error is expressed as:
An approximation of the second derivative is given by
Approximate error estimate is then:
)('')(12
1 3 fabEt
ab
dxxfff
b
a
)(''
'')(''
'')(12
1 3 fabEa

Dr. M. HrairiDr. M. Hrairi MTH2212 - Computational Methods and StatisticsMTH2212 - Computational Methods and Statistics 1111
Example 1
Use Trapezoidal Rule to integrate numerically the
following function:
from a = 0 to b = 0.8
5432 400900675200252.0)( xxxxxxf

Dr. M. HrairiDr. M. Hrairi MTH2212 - Computational Methods and StatisticsMTH2212 - Computational Methods and Statistics 1212
Example 1 - Solution
Evaluate f(a) and f(b)
Evaluate the integral
Approximate error estimate
2.0)0( f
232.0)8.0( f
1728.02
232.02.0)08.0(
I
56.2)08.0)(60(12
1))((''
12
1 33 abxfEa
6008.0
)8000108004050400()(''
8.0
0
32
dxxxx
xf

Dr. M. HrairiDr. M. Hrairi MTH2212 - Computational Methods and StatisticsMTH2212 - Computational Methods and Statistics 1313
Example 1 - Solution
True value of the integral is 1.640533
Et = 1.640533 – 0.1728
= 1.467733 εt = 89.5%
Ea = 2.56
Discrepancy between Et and Ea due to the fact that f >’’(x) is not an accurate approximation of f’’(ξ) for an interval of this size.

Dr. M. HrairiDr. M. Hrairi MTH2212 - Computational Methods and StatisticsMTH2212 - Computational Methods and Statistics 1414
Multiple-Application or Composite Trapezoidal Rule
Divide integration interval from a to b into n segments of equal width improve the accuracy of the trapezoidal rule
The total integral can be represented as
Substituting the trapezoidal rule for each integral, we get
By grouping terms, we have
n
n
x
x
x
x
x
xdxxfdxxfdxxfI
1
2
1
1
0
)(...)()(
2
)()(...
2
)()(
2
)()( 12110 nn xfxfh
xfxfh
xfxfhI
)()(2)(
2
1
10 n
n
ii xfxfxf
hI

Dr. M. HrairiDr. M. Hrairi MTH2212 - Computational Methods and StatisticsMTH2212 - Computational Methods and Statistics 1515
Multiple-Application Trapezoidal Rule

Dr. M. HrairiDr. M. Hrairi MTH2212 - Computational Methods and StatisticsMTH2212 - Computational Methods and Statistics 1616
Error of Multiple-Application Trapezoidal Rule
Truncation error is obtained by summing the individual error for each segment
By estimating the average value of f> ’’(x) for the entire interval
Approximate error estimate for multiple-application of trapezoidal rule is then:
As you double the number of segments error is quartered
n
it f
n
abE
13
3
)(''12
)(
n
ff
n
i
1
)(''''
'')(''1
fnfn
i
''12
)(2
3
fn
abEa

Dr. M. HrairiDr. M. Hrairi MTH2212 - Computational Methods and StatisticsMTH2212 - Computational Methods and Statistics 1717
Example 2
Apply two segments in the trapezoidal rule to estimate the integral of:
from a = 0 to b = 0.8
5432 400900675200252.0)( xxxxxxf

Dr. M. HrairiDr. M. Hrairi MTH2212 - Computational Methods and StatisticsMTH2212 - Computational Methods and Statistics 1818
Example 2 - Solution
We have n = 2
Evaluate the integral
True and Approximate error estimate
4.02
08.0
h
2.0)0( f 456.2)4.0( f 232.0)8.0( f
0688.14
232.0)456.2(22.08.0
I
64.0)60()2(12
)08.0(2
3
aE
Et = 1.640533 – 1.0688 = 0.571733

Dr. M. HrairiDr. M. Hrairi MTH2212 - Computational Methods and StatisticsMTH2212 - Computational Methods and Statistics 1919
Simpson’s 1/3 Rule
It corresponds to the case where n = 2 i.e. a polynomial of second order:
Let a = x0 and b = x2 and f2(x) a second order Lagrange polynomial, then
b
a
b
adxxfdxxfI )()( 2
dxxfxxxx
xxxx
xfxxxx
xxxxxf
xxxx
xxxxI
x
x
)())((
))((
)())((
))(()(
))((
))((
21202
10
12101
200
2010
212
0

Dr. M. HrairiDr. M. Hrairi MTH2212 - Computational Methods and StatisticsMTH2212 - Computational Methods and Statistics 2020
Simpson’s 1/3 Rule
After integration, we have:
Estimated truncation error
)()(4)(3 210 xfxfxfh
I 2
abh
where
)4(5
2880
)(f
abEa
ab
dxxfff
b
a
)(
)()4(
)4()4(

Dr. M. HrairiDr. M. Hrairi MTH2212 - Computational Methods and StatisticsMTH2212 - Computational Methods and Statistics 2121
Example 3
Evaluate the integral of:
from a = 0 to b = 0.8 using Simpson’s 1/3 rule. Compute the truncation errors Et and Ea
5432 400900675200252.0)( xxxxxxf

Dr. M. HrairiDr. M. Hrairi MTH2212 - Computational Methods and StatisticsMTH2212 - Computational Methods and Statistics 2222
Example 3 - Solution
Evaluate the integral with h = (b-a)/2 = 0.4
True truncation error
Et = 1.640533 – 1.367467 = 0.2730667 εt =
16.6%
Approximate truncation error
3674671232045624203
40)()(4)( 210 ..).(.
.xfxfxf
3
hI
240008.0
)()( 4800021600)(
8.0
0
)4()4()4(
dxxf
xfxxf
2730667.0)2400(2880
)8.0()(
2880
)( 5)4(
5
xfab
Ea

Dr. M. HrairiDr. M. Hrairi MTH2212 - Computational Methods and StatisticsMTH2212 - Computational Methods and Statistics 2323
Multiple-Application of Simpson’s 1/3 Rule
Just as the trapezoidal rule, Simpson’s 1/3 rule can be improved by dividing the integration interval into n segments of equal width
The total integral can then be represented by
)()(2)(4)(
3
2
,...6,4,2
1
,...5,3,10 n
n
ji
n
ii xfxfxfxf
hI )4(
4
5
180
)(f
n
abEa

Dr. M. HrairiDr. M. Hrairi MTH2212 - Computational Methods and StatisticsMTH2212 - Computational Methods and Statistics 2424
Example 4
Use n = 4 to evaluate the integral of:
from a = 0 to b = 0.8 using Simpson’s 1/3 rule. Compute the truncation errors Et and Ea
5432 400900675200252.0)( xxxxxxf

Dr. M. HrairiDr. M. Hrairi MTH2212 - Computational Methods and StatisticsMTH2212 - Computational Methods and Statistics 2525
Example 4 – Solution
The integral using composite simpson’s 1/3 rule
h = (0.8-0)/4 = 0.2
f(0)=0.2 f(0.2)=1.288 f(0.4)=2.456
f(0.6)=3.464 f(0.8)=0.232
εt = 1.0%
Approximate truncation error
623466.1
232.0)464.3(4456.23
2.0456.2)288.1(42.0
3
2.0
I
017067.0)2400()4(180
)8.0(
180
)(4
5)4(
4
5
fn
abEa
Et = 1.640533 – 1.623466 = 0.017067