Professional Documents
Culture Documents
Numerical Integration
Numerical Integration
Numerical Integration
Analytical Integration
Numerical Integration
b
I
a
f ( x)dx
The
f(x) to be integrated is one of the following forms: A simple continuous function such as polynomial, an exponential, or a trigonometric function. b Eg. I [2 3x 2 7 x 4 ]dx [2 x x3 7 x5 ]b a
a
A tabulated function where values of x and f(x) are given at a number of discrete points, as is often the case with experimental or field data.
ii. Use numerical method to estimate the integral on the basis of the discrete points
This is the most common numerical integrations schemes. The strategy - replacing a complicated function or tabulated data simpler polynomial function for easy integration. Sampling points are equi-spaced in the domain of x Eg. Trapezoidal rule
Simpsons rule
Using
I
a
f ( x)dx
a
f1 ( x)dx
Where
Thus,
(b a)
f (a) 2
f (b)
Trapezoidal rule
(b a) average height
When we employ the integral under a straight line segment to approximate the integral under a curve, error may be substantial:
Ea
where b.
1 f ( )(b 12
a )3
f ( )
f ( x)
f dx a
Example:
Use Trapezoidal Rule to numerically integrate f ( x) 0.2 25 x 200 x 2 675 x 3 900 x 4 400 x 5 from a=0 to b=0.8. The exact value of the integral is 1.640533. Find a percent relative true error and approximate error. Solution: The function values: f (0) 0.2
f (0.8) 0.232
Percent relative true error (1.640533 0.1728) 100 89.5% t 1.640533 Approximate error
f ( x)
f ' ( x)
f ( x)
b
0.2 25 x 200 x 2
25 400x 2025x 2
0.8
675 x 3 900 x 4
3600x 3
400 x 5
2000x 4
f ( )
f ( x)
f dx a
f ( x)
Ea
1 ( 60)(0.8)3 12 2.56
In order to improve the accuracy of the trapezoidal rule, the integration interval can be divided into n segments of equal width. The areas of individual segments can then be added to yield the integral for the entire interval.
h I
x0
b n
x1
a
x2
x0
xn
xn
f ( x)dx
x1
f ( x)dx
xn
1
f ( x)dx
f ( x1 )
f ( x1 ) 2
f ( x0 ) 2
f ( x2 )
n 1
h
f ( xn )
f ( xn 1 ) f ( xn ) 2
f ( xi )
i 1
(b a)
2n
An error for multiple-application trapezoidal rule can be obtained by summing the individual errors for each segment:
f ( i) Ea nf (b a)3 f ( x) 2 12n
Thus, if the number of segments is doubled, the truncation error will be quartered.
Example:
Use two segment Trapezoidal Rule to numerically integrate f ( x) 0.2 25 x 200 x 2 675 x 3 900 x 4 400 x 5 from a=0 to b=0.8. The exact value of the integral is 1.640533. Find true error and approximate error.
Solution:
n 2 h b a 2 0.4 :
f ( x0 ) 2 I (b a)
i 1
f ( xi ) 2n
f ( xn )
f ( i) Ea
nf
0.2 2(2.456) 0.232 I 0.8 1.0688 4 Et 1.640533 1.0688 0.57173 t Ea 0.83 ( 60) 0.64 2 12(2)
f ( x) f ( x) 400 4050 x 10800 x 2 8000 x3
0.8 0
34.9%
(b a)3 f ( x) 12n 2
Another
The
strategy use (n-1) order for total n number of points including a and b.
rule results when 2nd order interpolating polynomial is used. Means 3 points including a and b.
b b
I
a
f ( x)dx
a
f 2 ( x)dx
a I
x0
x2
x2
x0
( x x0 )( x x2 ) ( x x0 )( x x1 ) ( x x1 )( x x2 ) f ( x0 ) f ( x1 ) f ( x2 ) dx ( x0 x1 )( x0 x2 ) ( x1 x0 )( x1 x2 ) ( x2 x0 )( x2 x1 ) b a 2
I I
h f ( x0 ) 4 f ( x1 ) f ( x2 ) h 3 f ( x0 ) 4 f ( x1 ) f ( x2 ) (b a) 6
Single segment application of Simpsons 1/3 rule has a truncation error of:
Ea (b a)5 (4) f ( ) 2880 a b
Example:
Use Simpsons 1/3 Rule to numerically integrate
f ( x) 0.2 25 x 200 x 2 675 x 3 900 x 4 400 x 5 from a=0 to b=0.8. The exact value of the integral is 1.640533.
Solution:
f (0) 0.2 f (0.4) 2.456 f (0.8) 0.232
0.8
Et
1.640533 1.367467
21600 48000x
0.8
0.2730667
16.6%
f '''' ( x)
( 21600 48000x)dx f 4( )
0
0.8 0
2400
Ea
Ea
0.2730667
As in previous case, it is expected that the accuracy can be improved by dividing the integration interval into equispaced number of segments, n. It is limited to situations where there are an even number of segments and odd number of points.
I
I
x2 x0
f ( x)dx
x4 x2
f ( x )dx
xn xn
2
f ( x )dx
b a n
2h
f ( x0 ) 4 f ( x1 ) f ( x2 ) f ( x2 ) 4 f ( x3 ) 2h 6 6 f ( xn 2 ) 4 f ( xn 1 ) f ( xn ) 2h 6
n 1 n 2
f ( x4 )
f ( x0 ) 4 I (b a )
i 1,3,5
f ( xi ) 2
j 2,4,6
f (x j )
f ( xn )
3n
Example:
Use Multiple-Application version of Simpsons 1/3 Rule with n = 4 to numerically integrate
f ( x) 0.2 25 x 200 x 2 675 x 3 900 x 4 400 x 5
Solution:
n 4 (h 0.2) f (0.2) 1.288 f (0.6) 3.464 2.456 f (0) 0.2 f (0.4) f (0.8) 0.232
From Multiple-Application Simpsons 1/3 Rule
n 1 n 2
f ( x0 ) 4 I (b a )
i 1,3,5
f ( xi ) 2
j 2,4,6
f (x j )
f ( xn )
3n
0.8
Et
Ea (b a) (4) f 180n4
5
1.04%
Ea
rules is resulted from integration of 3rd order Lagrange interpolating polynomial to fit 4 points including a and b An odd-segment-even-point formula.
b b
I
a
f ( x)dx
a
f 3 ( x)dx f ( x3 )
More accurate
Remarks: Simpsons 3/8 rule is used in conjunction with the 1/3 rule to permit evaluation of both even and odd numbers of segments.
f ( x)
400 x 5
from a=0 to b=0.8. b) Use Simpsons 3/8 rule in conjunction with Simpsons 1/3 rule to integrate the same function for five segments.
Solution: a) A single application of Simpsons 3/8 rule requires four equal spaced points
f (0) 0.2 f (0.5333) 3.487177
b b
f ( x)dx
f 3 ( x)dx
Ea
b)
Integral of 1st 2 segments using Simpson' s 1/3 rule, 0.2 4(1.296919) 1.743393 0.3803237 6 Last 3 segments using Simpson' s 3/8 rule, I 0.32 1.743393 3(3.186015 3.181929) 0.232 8 Total integral is obtained by summing the 2 results, I 0.48 I Et
t
1.264754
0.0045447
Strategy - positioning any two points on a curve to define a straight line that would balance the positive and negative errors. Not equi-spaced. Hence, the area evaluated under this straight line provides an improved estimate of the integral.
a) Trapezoidal rule.
c0 c1
(b a ) / 2
1 dx
(b a ) / 2
b a b a c0 c1 2 2 c0 c1 b a
x dx
(b a ) / 2
b a b a c0 c1 0 2 2 b a c0 c1 2 b a b a I f (a) f (b) 2 2
Solve simultaneously
Trapezoidal rule
c0 f ( x0 )
c1 f ( x1 )
Now, we have 4 unknowns (c0, c1, x0, x1) which require four conditions.
1
Constant
c0 f ( x0 ) c1 f ( x1 )
Linear
1
1 dx 2
1
Solved simultaneously c0 c1 1
x0
2 3
c0 f ( x0 ) c1 f ( x1 )
1
x dx 0
1
1 3 1 3 f 1 3
0.5773503 0.5773503 f 1 3
Parabolic
c0 f ( x0 ) c1 f ( x1 )
1
x dx
1
x1 I
Cubic
c0 f ( x0 ) c1 f ( x1 )
1
x 3 dx 0
Remark: Notice that the integration limits are from -1 to 1 for simplification purpose. For evaluating integral for other limits, a new variable, xd is introduced with an assumption of linear relationship with x.
a0
a1 xd
With lower limit (a) and upper limit (b) equation becomes:
x (b a) (b a) xd 2
dx
b a dxd 2
These 2 terms will be substituted to the integral eqn. The new function , f(xd) is evaluated at (-1/ 3) and (1/ 3)
Example:
Use two-point Gauss Legendre formula to numerically integrate
f ( x) 0.2 25 x 200 x 2 675 x 3 900 x 4 400 x 5
Between the limit of a=0 and b=0.8. The exact value of the integral is 1.640533.
Solution:
Before integrating the function, we must perform a change of variable so that the limits are from -1 to +1. To do this, we substitute a=0 and b=0.8 into this equation (b a) (b a) xd x 2 to yield x 0.4 0.4 xd and dx 0.4dxd Substituted both of these into original equation will give
0.8 0
[0.2 25(0.4 0.4 xd ) 200(0.4 0.4 xd ) 2 675(0.4 0.4 xd )3 900(0.4 0.4 xd ) 4 400(0.4 0.4 xd )5 ]0.4dxd
xd xd 1
1 3
f f
1 3 1 3
0.516741 1.305873
I
t
Higher-Point Formulas
General form of higher-point version is
c0 f ( x0 ) c1 f ( x1 )
cn 1 f ( xn 1 )
Function Arguments
x1 = -0.577350269 x2 = 0.577350269 x1 = -0.774596669 x2 = 0.000000000 x3 = 0.774596669 x1 = -0.861136312 x2 = -0.339981044 x3 = 0.339981044 x4 = 0.861136312
2 3
Points 5
Weighting Factors c1 = 0.236926885 c2 = 0.478628670 c3 = 0.568888889 c4 = 0.478628670 c5 = 0.236926885 c1 = 0.171324492 c2 = 0.360761573 c3 = 0.467913935 c4 = 0.467913935 c5 = 0.360761573 c6 = 0.171324492
Function Arguments x1 = -0.906179846 x2 = -0.538469310 x3 = 0.000000000 x4 = 0.538469310 x5 = 0.906179846 x1 = -0.932469514 x2 = -0.661209386 x3 = -0.2386191860 x4 = 0.2386191860 x5 = 0.661209386 x6 = 0.932469514
Example: Use the three-point Gauss Legendre formula to estimate the integral for the same function as previous example. Solution:
c0 f ( x0 ) c1 f ( x1 ) c2 f ( x2 ) 0.5555556 f ( 0.7745967) 0.8888889 f (0) 0.5555556 f (0.7745967) 0.2813013 0.8732444 0.4859876 1.640533
Provided that the higher order derivatives do not increase substantially with increasing number of points (n), Gauss quadrature is superior to Newton-Cotes formulas.
2 2 n 3[( n 1)!]4 f (2n (2n 3)[( 2n 2)!]3
2)
Ea
( )