Numerical Integration PDF
Numerical Integration PDF
Integration
ò f (x) dx
b x is called variable of
I= a the integration
Integrand
" -&'
!" - $" = ++
5+1
"B
= ++
6
Numerical Integration
ò
Example: 2
sin( x )dx
The solution of this integral equation with Matlab is
1/2*2^(1/2)*pi^(1/2)*FresnelS(2^(1/2)/pi^(1/2)*x)
we cannot find this solution analytically by techniques in calculus.
Newton-Cotes Formulas
• The integral can be approximated in one step or
in a series of steps to improve accuracy.
Newton-Cotes Formulas
The Trapezoidal Rule
The trapezoidal rule is the first of the Newton-Cotes closed integration
formulas; it uses a straight-line approximation for the function:
I = ò f n ( x ) dx
b
é f (b ) - f (a ) ù
(x - a )ú dx
b
I = ò ê f (a) +
a
ë b-a û
f (a ) + f (b )
I = (b - a )
2
Numerical Integration Methods
Error of the trapezoidal rule
12
where x is somewhere between a and
b.
• This formula indicates that the error is
dependent upon the curvature of the
actual function as well as the distance
between the points.
• Error can thus be reduced by breaking
the curve into parts.
Single Application of the Trapezoidal Rule
Example 1.
Problem Statement. Use trapezoidal rule to numerically integrate
2
ò x dx
0
Solution:
The integrand function is f (x ) = x
from a = 0 to b = 0.8. The exact value of the integral can be determined analytically
to be 1.640533.
f (a ) + f (b )
I = (b - a )
2
Single Application of the Trapezoidal Rule
Example (Cont...)
Estimated
Error:
Multiple-Application Trapezoidal Rule
Example 3.
Problem Statement. Use the two-segment trapezoidal rule to estimate the integral of
from a = 0 to b = 0.8. The exact value of the integral can be determined analytically
to be 1.640533.
Multiple-Application Trapezoidal Rule
Example 4.
Problem Statement. For growth rates as given below
=10 + 173.5
= 183.5 » 183 Number of cells cannot be a fraction, hence
should be rounded to the nearest lesser integer.
Numerical Integration Methods
Simpson’s Rules
• One drawback of the trapezoidal rule is that the error is related to the second
derivative of the function.
• More complicated approximation formulas can improve the accuracy for
curves - these include using (a) 2nd and (b) 3rd order polynomials.
• The formulas that result from taking the integrals under these polynomials are
called Simpson’s rules.
Numerical Integration Methods
Simpson’s 1/3rd Rule
fn (x) =
(x - x1 ) (x - x2 ) f x + (x - x0 ) (x - x2 ) f x + (x - x0 ) (x - x1 ) f x
( 0) ( 1) ( 2)
( 0 1) ( 0 2 )
x - x x - x ( 1 0) ( 1 2)
x - x x - x ( 2 0 ) ( 2 1)
x - x x - x
I = ò f n ( x ) dx
x2
x0
h
I= [ f (x0 ) + 4 f (x1 ) + f (x2 )]
3
Numerical Integration Methods
Error of Simpson’s 1/3 Rule
• An estimate for the local truncation error of a single application of
Simpson’s 1/3 rule is:
1
f (4 ) (x )(b - a)
5
Et = -
2880
where again x is somewhere between a and b.
• This formula indicates that the error is dependent upon the fourth-derivative
of the actual function as well as the distance between the points.
• Note that the error is dependent on the fifth power of the step size (rather
than the third for the trapezoidal rule).
• Error can thus be reduced by breaking the curve into parts.
Single Application of Simpson’s 1/3 Rule
Example 5.
Problem Statement. Use Simpson’s 1/3 rule to numerically integrate
2
ò x dx
0
Solution:
The integrand function is f (x ) = x
from a = 0 to b = 0.8. The exact value of the integral can be determined analytically
to be 1.640533.
h
I= [ f (x0 ) + 4 f (x1 ) + f (x2 )]
3
Composite Simpson’s 1/3 rule (Multiple-Application)
• Simpson’s 1/3 rule can be used on a
set of subintervals in much the same
way the trapezoidal rule was, except
there must be an odd number of
points.
• Because of the heavy weighting of the
internal points, the formula is a little
more complicated than for the
trapezoidal rule:
h h h
I=
3
[ f ( 0)
x + 4 f ( 1 ) ( 2 )] [ ( 2 )
x + f x +
3
f x + 4 f ( 3 ) ( 4 )]
x + f x +"+
3
[ f (xn-2 ) + 4 f (xn-1 ) + f (xn )]
é ù Estimated Error:
hê ú
n-1 n-2
I = ê f (x0 ) + 4 å f (xi ) + 2 å f (xi ) + f (xn )ú
3
êë i=1 j=2
úû
!! i, odd j, even
Numerical Integration Methods
Simpson’s 3/8 rule
• Simpson’s 3/8 rule corresponds to using
third-order polynomials to fit four points.
Integration over the four points simplifies
to:
I = ò f n ( x ) dx
x3
x0
3h
I= [ f (x0 ) + 3 f (x1 ) + 3 f (x2 ) + f (x3 )]
8
Estimated Error:
Simpson’s 3/8th Rule
Example 9.
Problem Statement.
3h
I= [ f (x0 ) + 3 f (x1 ) + 3 f (x2 ) + f (x3 )]
8
Simpson’s 3/8th Rule
Example 9. (cont…)
Simpson’s 3/8th Rule
Example 9. (cont…)
Numerical Integration Methods
Basis of the Gauss–Legendre Method
(Gaussian Quadrature)
Previously, the Trapezoidal Rule was developed by the method of
undetermined coefficients. The result of that development is summarized
below
b
ò f ( x)dx » c f (a) + c
a
1 2 f (b)
b-a b-a
= f (a) + f (b)
2 2
The two-point Gauss Quadrature Rule is an extension of the Trapezoidal
Rule approximation where the arguments of the function are not
predetermined as a and b but as unknowns x1 and x2. In the two-point
Gauss Quadrature Rule, the integral is approximated as
b
I = ò f ( x )dx » c1 f ( x1 ) + c 2 f ( x 2 )
a
Numerical Integration Methods
Basis of the Gauss–Legendre Method
(Gaussian Quadrature)
The four unknowns x1, x2, c1 and c2 are found by assuming that the formula
gives exact results for integrating a general third order polynomial,
f ( x ) = a0 + a1 x + a2 x 2 + a3 x 3 .
Hence
( )dx
b b
2 3
ò f ( x )dx = a +
ò 0 1 a x + a 2 x + a 3 x
a a
b
é x x2
x ù 3 4
= êa0 x + a1 + a2 + a3 ú
ë 2 3 4 ûa
æ b2 - a2 ö æ b3 - a3 ö æ b4 - a4 ö
= a0 (b - a ) + a1 çç ÷÷ + a 2 çç ÷÷ + a3 çç ÷÷
è 2 ø è 3 ø è 4 ø
Numerical Integration Methods
Basis of the Gauss–Legendre Method
(Gaussian Quadrature)
It follows that
( ) ( )
b
2 3 2 3
ò f ( x )dx = c1 a0 + a1 x1 + a 2 x1 + a3 x1 + c2 a0 + a1 x2 + a 2 x2 + a3 x2
a
æ b2 - a2 ö æ b3 - a3 ö æ b4 - a4 ö
a0 (b - a ) + a1 çç ÷÷ + a 2 çç ÷÷ + a3 çç ÷÷
è 2 ø è 3 ø è 4 ø
( ) (
2 3
= c1 a0 + a1 x1 + a2 x1 + a3 x1 + c2 a0 + a1 x2 + a2 x2 + a3 x2
2 3
)
= a (c + c ) + a (c x + c x ) + a (c x ) ( )
2 2 3 3
0 1 2 1 1 1 2 2 2 1 1 + c2 x2 + a3 c1 x1 + c2 x2
Numerical Integration Methods
Basis of the Gauss–Legendre Method
(Gaussian Quadrature)
Since the constants a0, a1, a2, a3 are arbitrary
b - a = c1 + c2 b2 - a2
= c1 x1 + c2 x2
2
b3 - a3 2 2 b4 - a4 3 3
= c1 x1 + c2 x2 = c1 x1 + c2 x2
3 4
The previous four simultaneous nonlinear Equations have only one
acceptable solution,
æ b - a öæ 1 ö b + a æ b - a öæ 1 ö b + a
x1 = ç ÷ç - ÷ + x2 = ç ÷ç ÷ +
è 2 øè 3ø 2 è 2 øè 3 ø 2
b-a b-a
c1 = c2 =
2 2
Numerical Integration Methods
Basis of the Gauss–Legendre Method
(Gaussian Quadrature)
ò f ( x)dx » c f ( x ) + c
a
1 1 2 f ( x2 ) + c3 f ( x3 )
ò (a + a1 x + a 2 x 2 + a3 x 3 + a 4 x 4 + a5 x 5 )dx
b
0
a
5 c1 = 0.236926885 x1 = -0.906179846
c2 = 0.478628670 x2 = -0.538469310
c3 = 0.568888889 x3 = 0.000000000
c4 = 0.478628670 x4 = 0.538469310
c5 = 0.236926885 x5 = 0.906179846
6 c1 = 0.171324492 x1 = -0.932469514
c2 = 0.360761573 x2 = -0.661209386
c3 = 0.467913935 x3 = -0.2386191860
c4 = 0.467913935 x4 = 0.2386191860
c5 = 0.360761573 x5 = 0.661209386
c6 = 0.171324492 x6 = 0.932469514
Arguments and Weighing Factors for n-point
Gauss Quadrature Formulas
1
So if the table is given for ò g( x )dx integrals, how does one solve
b -1
x = mt + c
If x = a , then t = -1
Such that:
If x = b , then t= 1
b-a
m=
2
Arguments and Weighing Factors for n-point
Gauss Quadrature Formulas
b 1
æb-a b+aöb-a
ò
a
f ( x )dx = ò f ç
-1 è
2
t+ ÷
2 ø 2
dt
Numerical Integration Methods
Gauss–Legendre Method (Gaussian Quadrature)
Example 10.
30
æ é 140000 ù ö
x = ò ç 2000 ln ê ú - 9.8t ÷dt
8è ë140000 - 2100t û ø
c) Also, find the absolute relative true error, Îa for part (a).
Gauss–Legendre Method (Gaussian Quadrature)
Problem 10 (Cont…)
Solution
First, change the limits of integration from [8,30] to [-1,1]
by previous relations as follows
30
30 - 8 1 æ 30 - 8 30 + 8 ö
ò f ( t )dt = ò fç x+ ÷dx
8 2 -1 è 2 2 ø
1
= 11 ò f (11x + 19)dx
-1
Next, get weighting factors and function argument values from Table 1
for the two point rule, c1 = 1.000000000
x1 = -0.577350269
c 2 = 1.000000000
x 2 = 0.577350269
Gauss–Legendre Method (Gaussian Quadrature)
Problem 10 (Cont…)
ò f ( x)dx = ò (a
a a
0 + a1 x )dx
b
é x ù 2
æ b2 - a 2 ö
= êa0 x + a1 ú = a0 (b - a ) + a1 çç ÷÷
ë 2 ûa è 2 ø
Gauss–Legendre Method (Gaussian Quadrature)
Problem 11 (Cont…)
It follows that b
ò f ( x)dx = c (a
a
1 0 + a1 x1 )
Equating Equations, the two previous two expressions yield
æ b2 - a 2 ö
a0 (b - a ) + a1 çç ÷÷ = c1 (a0 + a1 x1 ) = a0 (c1 ) + a1 (c1 x1 )
è 2 ø
Since the constants a0, and a1 are arbitrary
b - a = c1
b2 - a 2
= c1 x1
2
b+a
giving c1 = b - a and x1 =
2
Gauss–Legendre Method (Gaussian Quadrature)
Problem 11 (Cont…)
b
æb+aö
ò f ( x )dx » c1 f (x1 ) = (b - a ) f ç ÷
a è 2 ø
Problems Set:
Example 1
Problems Set:
Example 1 (Cont…)
Problems Set:
Example 1
Problems Set:
Example 2.
Figure given below shows data traffic on the link from the United States to SWITCH, the
Swiss academic and research network, on February 10, 1998. D(t) is the data throughput,
measured in megabits per second Mb/s. Use Simpson’s Rule to estimate the total amount of
data transmitted on the link from midnight to noon on that day.
Solution Because we want the units to be consistent and D(t) is measured in megabits
per second, we convert the units for t from hours to seconds. If we let Astd be the
amount of data (in megabits) transmitted by time t, where t is measured in seconds,
Then
Problems Set:
Example 2 (Cont….)
the total amount of data transmitted by noon
Problems Set:
Example 2 (Cont….)
Problems Set:
Example 3.
Solution.
Trapezoidal rule
f (a ) + f (b ) f (- 1) + f (1)
T ( f ,2) = (b - a ) = [1 - (-1)]
2 2
Problems Set:
Example 3 (Cont….)
Simpson’s rule
Problems Set:
Example 4.
Solution.
Using three-point Gauss Legendre rule
b
ò f ( x)dx » c f ( x ) + c
a
1 1 2 f ( x2 ) + c3 f ( x3 )
Exercise:
1.
2.
4.
5.
Exercise:
6.
7.
Exercise:
7.
Exercise:
8.