Вы находитесь на странице: 1из 34

Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM

Topic 6: Numerical Integration


b a dx x f
b
a
and between curve under the area ) ( =
}
}
}
b
a
dx x f
dx x f
) ( : n integratio Definite
) ( : n integratio Indefinite
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Newton-Cotes Integration Formulas
They are based on the strategy of replacing a complicated
function or tabulated data with an approximating function that
is easier to integrate:
} }
~ =
b
a
n
b
a
dx x f dx x f I ) ( ) (
where f
n
(x) is a polynomial of degree n.
f
1
(x)
f
2
(x)
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Piecewise functions can be used also to approximate the
integral.
3 piecewise
linear
functions to
approximate
f(x) between
a and b.
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Two forms of the Newton-Cotes formulas:
Closed Forms: the data points at the beginning and
end of the limits of integration are known.
Open Forms: integration limits extend beyond the
range of the data.
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
THE TRAPEZOIDAL RULE
2
) ( ) (
) (
) ( ) (
1
b f a f
a b
dx x f dx x f I
b
a
b
a
+
=
~ =
} }
The integral is approximated by a line:
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Example
Use the trapezoidal rule to estimate
( )
}
+ + +
8 . 0
0
5 4 3 2
400 900 675 200 25 2 . 0 dx x x x x x
Solution
% 5 . 89
1728 . 0
2
232 . 0 2 . 0
8 . 0
2
) 8 . 0 ( ) 0 (
) 0 8 . 0 (
2
) ( ) (
) (
=
=
+
=
+
=
+
=
t
f f
b f a f
a b I
c
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
The Multiple-Application Trapezoidal Rule
One way to improve the accuracy of the trapezoidal rule
is to divide the integration interval from a to b into a
number of segments and apply the method to each
segment.
The areas of individual segments can then be added to
yield the integral for the entire interval.
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
} } }

+ + + =
n
n
x
x
x
x
x
x
dx x f dx x f dx x f I
1
2
1
1
0
) ( ) ( ) (
2
) ( ) (
2
) ( ) (
2
) ( ) (
1 2 1 1 0 n n
x f x f
h
x f x f
h
x f x f
h I
+
+ +
+
+
+
=

The total integral is





Substituting the trapezoidal rule for each integral:


Grouping terms:
n
x f x f x f
a b x f x f x f
h
I
n
n
i
i
n
n
i
i
2
) ( ) ( 2 ) (
) ( ) ( ) ( 2 ) (
2
1
1
0
1
1
0
+ +
=
(

+ + =

=
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Example
Use the multiple-application trapezoidal rule for n = 2 to
estimate
( )
}
+ + +
8 . 0
0
5 4 3 2
400 900 675 200 25 2 . 0 dx x x x x x
Solution
% 9 . 34
0688 . 1
4
232 . 0 ) 456 . 2 ( 2 2 . 0
8 . 0
4
) 8 . 0 ( ) 4 . 0 ( 2 ) 0 (
) 0 8 . 0 (
) 2 ( 2
) ( ) ( 2 ) (
) (
2 1 0
=
=
+ +
=
+ +
=
+ +
=
t
f f f
x f x f x f
a b I
c
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Computer Algorithms for the Trapezoidal Rule
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
SIMPSONS 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
such polynomials are called Simpsons rules.
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Simpsons 1/3 Rule
This rule results when a second-order interpolating
polynomial is used.
| |
2
where ) ( ) ( 4 ) (
3
) (
) )( (
) )( (
) (
) )( (
) )( (
) (
) )( (
) )( (
, and Let
) ( ) (
2 1 0
2
1 2 0 2
1 0
1
2 1 0 1
2 0
0
2 0 1 0
2 1
2 0
2
2
0
a b
h x f x f x f
h
I
dx x f
x x x x
x x x x
x f
x x x x
x x x x
x f
x x x x
x x x x
I
x b x a
dx x f dx x f I
x
x
b
a
b
a

= + + ~
(

(


+



+


=
= = -
~ =
}
} }
After integration,
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Example
See the example and the solution in the book.
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Simpsons 3/8 Rule
This rule results when a third-order interpolating
polynomial is used.
| |
3
where ) ( ) ( 3 ) ( 3 ) (
8
3
, yields This
) ( ) (
3 2 1 0
3
a b
h x f x f x f x f
h
I
dx x f dx x f I
b
a
b
a

= + + + ~
-
~ =
} }
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Example
See the example and the solution in the book.
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Integration of Equations
Functions to be integrated numerically are in two forms:
A table of values. We are limited by the number of
points that are given.
A function. We can generate as many values of f(x)
as needed to attain acceptable accuracy.
We will focus on techniques that are designed to
analyze functions.
The first technique is based on Richardsons
extrapolation which is a method for combining 2
numerical integral estimates to obtain a third, more
accurate value.
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
The computational algorithm for implementing
Richardsons extrapolation in a highly efficient manner is
called Romberg integration.
This technique is recursive and can be used to generate
an integral estimate within a prespecified error tolerance.
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
ROMBERG INTEGRATION
It is based on successive application of the trapezoidal
rule to attain efficient numerical integrals of functions.
More accurate results are attained for less effort.
Richardsons Extrapolation
The estimate and error associated with a multiple-
application trapezoidal rule can be represented as
I = I(h) + E(h)
Where I = exact value
I(h) = approximation using n segments
E(h) = truncation error
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
If 2 estimates using h
1
and h
2
are available, then
I(h
1
) + E(h
1
) = I(h
2
) + E(h
2
)
The error from the multiple application trapezoidal rule
is

Assume the second derivative is constant,


Rearrange:
2
2
1
2 1
2
2
2
1
2
1
2
) ( ) (
) (
) (
12
|
|
.
|

\
|
~
~
' '

~
h
h
h E h E
h
h
h E
h E
f h
a b
E
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
| | ) ( ) (
1
1
) (
) ( ) (
1
) ( ) (
) (
) ( ) ( ) ( ) (
1 2
2
2
1
2
2 2
2
2
1
2 1
2
2 2
2
2
1
2 1
h I h I
h
h
h I I
h E h I I
h
h
h I h I
h E
h E h I
h
h
h E h I

|
.
|

\
|
+ ~
+ =
|
.
|

\
|

~
+ ~
|
|
.
|

\
|
+
The error of the estimate is O(h
4
).
We have combined two estimates of O(h
2
) to yield a new
estimate of O(h
4
).
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
| |
l m
I I I
h I h I
h I h I h I I
15
1
15
16
) (
3
1
) (
3
4
) ( ) (
1 2
1
) (
1 2
1 2
2
2
~
~

+ ~
For h
2
= h
1
/2,
Weighting factors
Two estimates of O(h
4
) can be combined to yield an
estimate of O(h
6
).
When two estimates of O(h
4
) are combined and the
segments are reduced by half:
I
m
= more accurate
I
l
= less accurate
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Example
See the example and the solution in the book.
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
l m
I I I
63
1
63
64
~
Two estimates of O(h
6
) can be combined to yield an
estimate of O(h
8
)
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Example
See the example and the solution in the book.
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
The Romberg Integration Algorithm
The general formula is


I
j+1,k-1
= more accurate
I
j,k-1
= less accurate
I
j,k
= improved integral
For k = 1 corresponds to O(h
2
).
For k = 2 corresponds to O(h
4
).
For k = 3 corresponds to O(h
6
).
1 4
4
1
1 , 1 , 1
1
,

~

+

k
k j k j
k
k j
I I
I
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
k 1 2 3 4
j n O(h
2
) O(h
4
) O(h
6
) O(h
8
)
1 1 I
1,1
I
1,2
I
1,3
I
1,4
2 2 I
2,1
I
2,2
I
2,3
3 4 I
3,1
I
3,2
4 8 I
4,1

We organized the computations in the table:
The computation is terminated when < c
s
.
% 100 | |
, 1
1 , 2 , 1
k
k k
a
I
I I

=
Multiple
application
trapezoidal rule
Extrapolation formula
n = 2
j-1
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Example
Use Romberg algorithm to approximate
with |c
s
| = 0.1%. Maintain 4 decimal places rounded.
0
sin xdx
t
}
k 1 2 3 4
j n I
j,1
I
j,2
c
a
I
j,3
c
a
I
j,4
c
a
1 1 0 2.0944 25 1.9985 0.3 1.9999 0.0
2 2 1.5708 2.0045 1.9999
3 4 1.8961 2.0002
4 8 1.9742
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Case Studies
Estimate the cross section area of the stream.
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Consider this example
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Trapezoidal rule (h = 4):





Trapezoidal rule (h = 2):
2
2
m 2 . 63
20
0 ) 8 . 2 4 . 3 6 . 3 4 6 4 4 2 8 . 1 ( 2 0
) 0 20 (
m 6 . 53
10
0 ) 4 . 3 4 4 2 ( 2 0
) 0 20 (
=
+ + + + + + + + + +
=
=
+ + + + +
=
I
I
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Integration with Matlab



Use quad for functions.
Use trapz for tabulated data.
See page 639 in the book on how to use these
functions.

Оценить