Professional Documents
Culture Documents
13
6
NUMERICAL INTEGRATION*)
Numerical integration methods are classified by taking into
account both the integrand function's type and the values for the
integration's limits of integration.
If the integration function is a function with only one argument
(single integrals) then we deal with quadrature formulae. If the
function to be integrated has two arguments (double integrals), then
we deal with cubature formulae.
I.
The first group of methods refers to the continuous
functions and with finite limits of integration. These
methods are divided in two subgroups according to the
dividing module of the interval of integration:
a) Methods that divide the integration interval into
subintervals of the same length, the number of the
subintervals being imposed by the operator. Among
these methods include: the rectangle method, the
trapezoidal
method,
Simpson's
method
and
Richardson's method;
b) Methods that divide the integration interval so that the
error of calculation to be minimal. Among these
methods remember and study the Gaussian quadrature
formula.
II.
III.
13
6.1.
rule)
This method of calculation has big errors for functions that are
not constant. We can use this technique in cases in which there are
no precision requirements in evaluating an integral. It is common
sense to say that, if the number of subintervals of the integration
interval increases then the error of calculation decreases.
This increase in the number of subintervals is done taking in
consideration that the time of calculation will be worse. It is
considered:
b
I= f ( x )dx
(6.1)
n 1
i 0
i= 0
si=h f ( xi )
(6.4)
where xi a h i
Formula (6.4) represents
the integration formula
based on rectangular small
areas.
Numerical Integration
13
6.1.1.1.
Variables
(
ls:left limit of the integration interval, real;
ld: right limit of the integration interval, real;
n: number of subintervals, integer;
sum: value of the integral, real;
)
{
sum=0;
compute h=(ld-ls)/nrpas;
for i=0,,n-1 compute sum =sum +h* f(ls+i*h);
print the integration values as sum;
}
6.1.1.2.
13
rule)
f ( x )dx
a ,b and a , b
are
finite.
The function is represented through the area of the dotted line in
fig. 6.2, and the integral I represents the area of that dotted area.
The a ,b interval is divided into n equal parts, having a spacing
of:
hi = (xn-x0)/n, for i=0,1,...,n-1, x0=a and xn=b
Every small area Ii is approximated with the area of some
trapezoid having for its vertex the following coordinates:
( xi , xi 1, f ( xi ), f ( xi 1 ))
That is why every such small area is:
(6.5)
Therefore, the entire area - that is our integral I - will be:
(6.6)
This expression shows the formula of numeric integration
through the trapezoidal method and has zero cropping error for
functions approximated by
polynomials with degree
up to one.
The trapezoidal method
is superior in terms of
cropping errors compared
to the rectangular formula,
without
major
gain
regarding the calculation
time for the same number
of steps of integration.
Its simplicity makes it
usable in many cases, its
accuracy depends on the
chosen
number
of
subintervals. The higher
this
number
is
the
accuracy is better, but the calculation time increases. This integral
represents the fundamental for the Richardsons method.
6.1.2.1. Truncation error for trapezoidal formula
Numerical Integration
13
We will calculate the truncation error for Ii (6.5). For this we will
expand the function f ( x ) around the points xi and xi 1 :
( x xi )
( x-xi ) 2
f ( xi )+
f ( xi ) ...
1!
2!
( x xi 1 )
( x xi 1 ) 2
f(x) f ( xi 1 )
f ( xi 1 )
f ( xi 1 ) ...
1!
2!
f ( x )=( xi )
(6.7)
(6.8)
With these two expansions (6.7) and (6.8) we will build a new
function, the average of these functions that best approximates f(x)
in the range ( xi , xi 1 ) . Considering xi 1 xi h we can write the new
function like this:
f ( xi+1 ) f ( xi )
f ( xi ) f ( xi 1 )
( x xi )
h f ( xi 1 )
2
2
f ( xi ) f ( xi 1 )
f ( xi 1 ) h 2
( x xi ) 2
h ( x xi )
f ( xi 1 ) ...
4
2
4
f ( x )=
(6.9)
xi
f ( x )dx
f ( xi 1 ) f ( xi )
f ( xi 1 ) f ( xi ) 2 f ( xi 1 ) 2
h
h
h
2
4
2
f ( xi+1 ) f ( xi ) 3 f ( xi 1 ) 3 f ( xi 1 ) 3
h
h
h ...
12
4
4
f ( xi 1 ) f ( xi )
f ( xi 1 ) f ( xi ) 2 f ( xi 1 ) f ( xi ) 3
h
h
h ...
2
4
12
(6.10)
eTi
f ( xi 1 ) f ( xi ) 2 f ( xi 1 ) f ( xi ) 3
h
h ...
4
12
(6.11)
eTi k h 2 f ( xi 1 ) f ( xi )
(6.12)
x3
x dx 3
xi
2
xi 1
xi
xi33 xi3
h3
2
2
xi h h xi
3
3
(6.13)
14
xi 1
xi
( xi+2 1 xi2 )
h2
2
2
x dx
h eTi xi h xi h eTi
2
2
2
(6.14)
3
From (6.13) and (6.14) we have: eTi h / 6
(6.15)
By applying (6.12) for f ( x ) x 2 we have:
eTi k h 2 ( 2 xi 1 2 xi ) 2 k h 3
(6.16)
1
12
The truncation error for the small trapezoidal area limited by
( xi , xi 1 , f ( xi ), f ( xi 1 )) is:
1
eTi h 2 f ( xi 1 ) f ( xi )
(6.17)
12
Consequently, for the whole integral on the interval a ,b we
have the following approximate truncation error:
(6.18)
eT ( 1 / 2 ) h 2 f ' ( b ) f ' ( a )
This error represents the approximate sum of the areas between
the curve and the spring through the points ( xi , f ( xi )),( xi 1 , f ( xi 1 )) ,
i = 0,1,...,n-1.
From relations (6.16) and (6.15) we have: k=-
E I ((( ...((( 1
f ( x1 )
f ( x2 )
f ( x1 ) f ( x 2 )
2
r1 )
f ( x1 ) f ( x 2 )
f ( x1 ) f ( x2 )
f ( x1 ) f ( x 2 ) f ( x3 )
+ 3
f ( x3 )
f ( x1 ) f ( x 2 ) ... f ( x n 2 )
r2 )... rn3 )
f ( x1 ) f ( x 2 ) f ( x3 )
f ( x1 ) f(x 2 ) ... f(x n 2 ) f ( x n1 )
n 1
f ( x n 1 )
2 f ( x1 ) 2 f ( x 2 ) ... 2( x n 1 )
rn 2 rn 1 )
f ( x1 ) f ( x 2 ) ... f ( x n 1 )
f ( x0 ) 2 f ( x1 ) ... 2 f ( x n 1 ) f ( x n )
(0
f ( x0 )
f ( xn )
f ( x0 ) f ( x n )
n
rn )
f ( x 0 ) f ( x1 )
f ( x0 ) f ( xn )
f ( x 0 ) 2 f ( x1 ) ... 2 f ( x n 1 ) f ( x n )
Numerical Integration
14
rn 1 h rn 2 rn 1 h rn 2 rn
0
f ( x0
f ( x0
) 2 f ( x1 )
f ( x0 )
f ( xn )
n
f ( x 0 ) 2 f ( x1 ) ... 2 f ( x n 1 ) f ( x n )
f ( x 0 ) 2 f ( x1 ) ... 2 f ( x n 1 ) f ( x n )
( rn 2 rn 1 )
2 f ( x1 )+2 f ( x 2 ) ... 2 f ( x n 1 )
2 f ( x n 1 )
n 1
f ( x 0 ) 2 f ( x1 ) ... 2 f ( x n 1 ) f ( x n )
f ( x 0 ) 2 f ( x1 ) ... 2 f ( x n 1 ) f ( x n )
+rn-3
2 f ( x1 )+f ( x 2 ) ... f ( x n 2 )
2 f ( x n2 )
n -2
f ( x 0 ) 2 f ( x1 ) ... 2 f ( x n 1 ) f ( x n )
f ( x 0 ) 2 f ( x1 ) ... 2 f ( x n 1 ) f ( x n )
+ rn- 4
2 f ( x1 )+f ( x2 ) ... f ( xn 3 )
2 f ( x2 )
... 2
f ( x0 ) 2 f ( x1 ) ... 2 f ( xn 1 ) f ( xn )
f ( x0 ) 2 f ( x1 ) ... 2 f ( xn 1 ) f ( xn )
(6.19)
e
Considering that some relative error is I I , where eI is the
I
absolute error, then we can calculate the absolute error:
eI ( rn 1 h n 2 ) I rn
h f ( x0 ) f ( xn )
h f ( x0 )
0
2
2
14
2 ( n 1 ) ( n
2
( n 3 ) ( n 4 ) ... 2 )]
5 10 t [ 3nh 5 h / 2 h ( n 2 3 n 8 ) / 2 ]
5 10 t h. ( n 2 9 n 3 ) / 2
eI 5 10 t h ( n 2 9 n 3 ) / 2
(6.21)
Numerical Integration
14
C=
I h -I k
k 2 h2
14
ba
ba
, h
(6.25)
m
n
We write the formula for trapezoidal method, for each division:
h
I h f ( x0 ) 2 f ( x1 ) 2 f ( x 2 )+2 f ( x3 )+... 2 f ( x n1 ) f ( x n )
2
(6.26)
k 2h , k
I k h f ( x0 ) 2 f ( x2 ) 2 f ( x4 )+2 f ( x6 )+... 2 f ( xn 2 ) f ( xn )
(6.27)
Then we apply RICHARDSONs formula (6.23):
f ( xn )
f ( x0 )
f ( x1 ) f ( x2 )+f ( x3 )+f ( x 4 )+... f ( xn 1 )
2
2
I h
f ( xn )
1
1
1
1
f ( x0 ) 1
f ( x1 ) f ( x2 )+ f ( x3 )+ f ( x4 )+... f ( xn1 )
3
3
3
3
3
6
6
2
2
2
1
1
h - f ( x0 )- f ( x 2 )- f ( x 4 )-... f ( x n 2 ) f ( x n
3
3
3
3
3
(6.28)
The expression above represents the numeric calculation formula
of the integral according to SIMPSONs method.
6.2. INTEGRATION
OF
SINGLE-VARIABLE
FUNCTIONS
USING
VARIABLEPARTITIONING SCHEMA
Numerical Integration
14
we have y=1.
(6.30)
(6.31)
f ( x )dx
variable y, as follows:
+1
+1
1
1
1
( b a ) y ( b a ) ( b a )dy ( y )dy
2
2
2
1
(6.32)
14
z a 0 a1 y
z ( y)
dividing the range [-1.1] is done in such a way that between areas
S1, S2, S3 to have the relationship:
S1 = S2 + S3
(6.33)
The formula for calculating the integral is proven for the case of
two points in the integration interval, points that are determined in
such a way for the integral I
( y )dy
polynomial cubic inclusive. Choosing points of dividing the range [1.1] is done in such a way that between areas S1, S2, S3 to have the
relationship
S1=S2+S3
(6.33)
until a function ( y) of third degree.
The integral through the quadrature method is computed using
the following formula:
I=k 0(y0)+k1(y1)
where y 0 i y1 are points for dividing the interval, and k0 , k1 are
some weights, all unknown which we will determine.
1
( y )dy
taking
+1
-1
-1
I= ( y )dy= ( a 0 a1 y )dy
(6.34)
Numerical Integration
14
+1
( a0 a1 y )dy
a1 y ( y y 0 )( y-y1 )( 0 1 y )dy
(6.37)
0 and 1 , the
+1
( y y
)( y y1 )dy 0
(6.38)
+1
y( y y
and
)( y y1 )dy 0
(6.39)
1
+1
or
+1
( y0 y1 ) y y0 y1 dy 0
(6.40)
( y0 y1 ) y y0 y1 y dy 0
2
1
0
3
y0 y1 0
y 0 y1
1
3
(6.41)
and y1
1
3
(6.42)
To calculate k0, k1 we use the equality:
+1
+1
-1
-1
I = ( y )dy = ( a0 a1 y )dy k 0 (
1
1
) k1 (
)
3
3
(6.43)
14
+1
( a
a1 y )dy ( a0 y
a1 2
y )
2
+1
1
2a0
(6.44)
(6.45)
k 0 k1 2
k 0 k1 0
(6.46)
I f ( x )dx ( y )dy (
( y )
where:
1
1
) (
)
3
3
(6.48)
1
(b a )f ( y )
2
(6.49)
6.2.1.1. The truncation error of the GAUSS' quadrature
formula using two points
The integral from polynomials with degree at most three gives no
truncation errors, since we used LEGENDRE's polynomials of degree 3.
For such a case, assuming the given functions are polynomials with
a degree higher than three, we have some truncation error, as
follows:
(6.50)
eT k (IV ) ( ) , -1 1
To determine k we consider ( y ) y 4
1
( y )dy
( y )dy y
4
y dy
dy (
y5
5
1
3
1
1
) (
2
5
1
3
(6.51)
) eT
2
eT
9
(6.52)
Numerical Integration
14
that means
1
135
( ) , -11
(6.53)
135
6.2.2.GAUSS' quadrature formula using more than two
points of division
In this case
b
n 1
i 0
f ( x )dx ( u )du k i ( yi )
(6.54)
( 1 y ) Pn ( yi )
2
i
(656)
15
2n
( y )dy y dy
( y )dy
y 2 n1
( 2n 1 )
n 1
y 2 n dy k i y i
2n
i 0
1
1
2
2n 1
eT
(6.58)
(6.59)
eT
n 1
2
k i yi2 n
2n 1 i 0
(6.60)
n 1
1 2
ki ui2 n
( 2n )! 2n 1 i 0
(6.61)
eT
ki ui2 n
( 2n )! 2n 1 i 0
(6.62)
6.3.
COMPARISON OF THE INTEGRATION
METHODS
FOR SINGLE VARIABLE FUNCTIONS
Numerical Integration
15
6.4.
f ( x ) dx
f ( x )dx
f ( x ) dx
(6.63)
f ( x ) dx
(6.64)
lim f ( x )dx k
(6.65)
then
f ( x )dx k
a
(6.66)
15
f ( x ) dx
(6.67)
f ( x ) dx
f ( x ) dx
(6.68)
f (c 0) lim f (x)
f (c 0) lim f (x)
and
x c
x c
x c
x c
and
f ( x ) dx f 1 ( x ) dx f 2 ( x ) d x
(6.69)
f ( c ) f ( c 0)
or
(6.70)
where
f (x) pentru a x c
f1 ( x )
f (c 0) pentru x c
f (x) pentru c x b
f 2 (x)
f (x c) pentru x c
If the integral (6.70) exists, we can say that the improper integral
is convergent and that its value can be calculated with a method
studied in paragraph 5.1.
Function f ( x) has a point of discontinuity of second case c a,b
if at least one of the limits (6.69) has infinite value. In that case:
Numerical Integration
15
c e
f ( x ) dx
f ( x )dx
f ( x ) dx
(6.71)
ce
f (x )dx
1 , 1 0
6.5.
NUMERIC
CALCULATION
DOUBLE
INTEGRALS
OF
THE
f ( x,y)dx f ( x,y)dxdy
D
a c
(6.72)
Trapezoidal
cubature method
The interval a , b i c, d split into subintervals of equal lengths:
ba
dc
h
k
,
(6.73)
n
m
15
x i , yi ,
x i1 , y i , x i1 , y i1 , x i , y i1 , where
x i a i h , (yj+1= ?)
For the rectangle that contains the vertices x i , y i the integral Iij
is calculated by applying the trapezoidal formula:
y j 1
xi 1
I ij
xi
dx
xi 1
f ( x,y )dxdy
yj
k
2
xi
f ( x,y j ) f ( x,y j 1 ) dx
xi 1
xi 1
xi
xi
f ( x , y j )dx f ( x , y j 1 )dx
kh
f ( x i ,y j ) f ( x i ,y j1 ) f ( x i 1,y j ) f ( x i 1,y j1 ) (6.74)
4
Integral on the entire domain a , b, c, d is:
n 1 m 1
I I ij
i 0 j 0
kh n 1 m 1
f ( x i ,y j ) f ( x i ,y j1 ) f (x i 1,y j ) f ( x i 1,y j1 )
4 i 0 j 0
(6.75)
expression that is known as the formula of the trapezoidal
cubature.
x i , y i1
I I ij
i 0 j 0
kh n 1 m 1
f ( x i 1,y j1 ) f ( x i1,y j1 ) f ( x i 1,y j1 ) f (x i 1,y j1 )
9 i 0 j 0
(6.77)
Numerical Integration
15
6.6. APPLICATIONS
2
x3
.e x .(1 sin x 2 )
1 cos(1 x )
for which we want the integral from 0 to 3.
R: The value of the integral is given in the table 6.1.
Table 6.1
Method
Number of subintervals
Rectangle
Trapeze
Richardson
Simpson
Gauss'
Cuadrature
10000
10000
5000 and 10000
10000
Legendre pol degree
n=15
Value of the
integral
1394.642843
1395.704297
1395.703984
1395.703984
1395.7031
x2 y2
. exp(1 x ).sin( x y 2)
1 2.x.y
Number of
points
on Ox
100
Number of
points
on Oy
100
-24.730047
100
100
-24.733155
Value of the
integral