0% found this document useful (0 votes)
557 views26 pages

Numerical Methods: Integration Techniques

Uploaded by

thaer syam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
557 views26 pages

Numerical Methods: Integration Techniques

Uploaded by

thaer syam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

GENG 300 NUMERICAL METHODS

Dr. Mohammad Aman Ullah


Numerical
Differentiation &
Integration

Topic 5
TOPICS COVERED: NUMERICAL

6/27/2016
INTEGRATION
1. Newton-Cotes Formulas
a) The Trapezoidal Rule
b) Composite Trapezoidal Rule

Numerical Methods
c) Simpson’s 1/3 Rule
d) Composite Simpson’s 1/3 Rule
e) Simpson’s 3/8 Rule
f) Higher-Order Formulas
g) Integration with Unequal Segments

2. Romberg Integration (Richardson Extrapolation)


Chapter Objectives
• Recognizing that Newton-Cotes integration formulas are based on the
strategy of replacing a complicated function or tabulated data with a
polynomial that is easy to integrate.
• Knowing how to implement the following single application Newton-Cotes
formulas:
• Trapezoidal rule
• Simpson’s 1/3 rule
• Simpson’s 3/8 rule
• Knowing how to implement the following composite Newton-Cotes
formulas:
• Trapezoidal rule
• Simpson’s 3/8 rule
• Recognizing that even-segment-odd-point formulas like Simpson’s 1/3 rule
achieve higher than expected accuracy.
• Knowing how to use the trapezoidal rule to integrate unequally spaced data.
• Understanding the difference between open and closed integration formulas.
Integration

³
b
• Integration: I f x dx
a

is the total value, or summation, of f(x) dx over the range from


a to b:
Newton-Cotes Formulas
• The Newton-Cotes formulas are the most common numerical
integration schemes.

• Generally, they are based on replacing a complicated


function or tabulated data with a polynomial that is easy to
integrate:

³ ³
b b
I f x dx # fn x dx
a a

• where fn(x) is an nth order interpolating polynomial.

f n ( x) a0  a1 x    an x n
Newton-Cotes Examples
• The integrating function can be polynomials for any order -
for example, (a) 0 order, (b) 1st order, (c) 2nd order.

(a) (b) (c)

The integral
al can be approximated
ap in one
step or in a series of steps to improve
accuracy.
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:

³
b
I fn x dx
a
Error:
bª f b f a º
I ³ a «¬f (a)  b  a x  a »dx
¼ Et 
1
f cc([ )(b  a ) 3
12
f a f b where [ lies somewhere in the
I ba
2 interval from a to b
Example f(x) = 0.2 +25x – 200x2 + 675x3 – 900x4 + 400x5

Integrate f(x) from a=0 to b=0.8


b 0.8
True integral value : I ³ f ( x )dx
a 0
1.64053

Solution: f(a)=f(0) = 0.2 and f(b)=f(0.8) = 0.232

f (a )  f (b)
Trapezoidal Rule : I (b  a )
2
0.2  0.232
0.8 0.1728
2
which represents an error of :

Et 1.64053  0.1728 1.46773 H t 89.5%


Composite Trapezoidal Rule
• Error can thus be reduced by
breaking the curve into parts.
• Assuming n+1 data points are
evenly spaced, there will be n
intervals over which to integrate.
• The total integral can be
calculated by integrating each
subinterval and then adding them
together:

³ ³ fn x dx  ³ ³
xn x1 x2 xn
I fn x dx fn x dx  fn x dx
x0 x0 x1 x n1

f x0  f x1 f x1  f x2 f xn1  f xn
I x1  x0  x2  x1   xn  xn1
2 2 2
h ª n1 º
I «f x0  2¦ f xi  f xn »
2 ¬ i 1 ¼
Example f(x) = 0.2 +25x – 200x2 + 675x3 – 900x4 + 400x5

Integrate f(x) from a=0 to b=0.8

Divide the total interval into two subintervals and use composite
Trapezoidal method:
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.
Simpson’s 1/3 Rule
• Simpson’s 1/3 rule corresponds to using second-order
polynomials. Using the Lagrange form for a quadratic fit of
three points:

x  x1 x  x2 x  x0 x  x2 x  x0 x  x1
fn x f x0  f x1  f x2
x0  x1 x0  x 2 x1  x0 x1  x2 x2  x 0 x2  x1

• Integration over the three points simplifies to:

x2
I ³
x0
f n x dx

I
h
> f x0  4 f x1  f x2 @ , where h (b-a)/ 2
3
Example f(x) = 0.2 +25x – 200x2 + 675x3 – 900x4 + 400x5

Integrate f(x) from a=0 to b=0.8

Use Simpsons 1/3rd rule to integrate over 3 points.


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
 [ ba
4 5
Et f
2880
where again [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.
Composite Simpson’s 1/3 Rule
• 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:

³ ³ ³ ³
xn x2 x4 xn
I
x0
fn x dx fn x dx  fn x dx   fn x dx
x0 x2 x n2

h h h
I
3
> f x 0  4 f x 1  f x 2 @ 
3
> f x2  4 f x3  f x4 @ 
3
> f xn2  4 f xn1  f xn @
ª º
h « »
n1 n2
I
3 «
f x 0  4 ¦ i ¦ i
f x  2 f x  f x n »
«
¬
i 1
i, odd
j 2
j, even »
¼
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:
³
x3
I x0
fn x dx
3h
I
8
> f x0  3 f x1  3 f x2  f x3 @
• Simpson’s 3/8 rule is generally
used in concert with Simpson’s
1/3 rule when the number of
segments is odd.
Higher-Order Formulas
• Higher-order Newton-Cotes formulas may also be used - in general, the
higher the order of the polynomial used, the higher the derivative of the
function in the error estimate and the higher the power of the step size.
• As in Simpson’s 1/3 and 3/8 rule, the even-segment-odd-point formulas
have truncation errors that are the same order as formulas adding one
more point. For this reason, the even-segment-odd-point formulas are
usually the methods of preference.

Segments Points Name Formula Truncation


(n) Error

1 2 Trapezoidal (b-a) * (f(x0)+ f(x1))/2 -(1/12)(b-a)3f”(ȟ)

2 3 Simpson’s (b-a) * (f(x0)+ 4f(x1)+f(x2))/6 -(1/2880)(b-a)5f(4)(ȟ)


1/3
3 4 Simpson’s (b-a) * (f(x0)+ 3f(x1)+ 3f(x2)+ f(x3))/8 -(1/6480)(b-a)5f(4)(ȟ)
3/8
4 5 Boole’s (b-a) * (7f(x0) + 32f(x1) + 12f(x2) + 32f(x3) proportional with (b-a)7
+ 7f(x4))/90
Integration with Unequal Segments
• Previous formulas were simplified based on equispaced data
points - though this is not always the case.
• The trapezoidal rule may be used with data containing
unequal segments:

³ ³ ³ ³
xn x1 x2 xn
I fn x dx fn x dx  fn x dx   fn x dx
x0 x0 x1 x n1

f x0  f x1 f x1  f x2 f xn1  f xn
I x1  x0  x2  x1   xn  xn1
2 2 2
MATLAB Functions
• MATLAB has built-in functions to evaluate integrals
based on the trapezoidal rule
• z = trapz(y)
z = trapz(x, y)
produces the integral of y with respect to x. If x is
omitted, the program assumes h=1.
• z = cumtrapz(y)
z = cumtrapz(x, y)
produces the cumulative integral of y with respect to
x. If x is omitted, the program assumes h=1.
Multiple Integrals
• Multiple integrals can be
determined numerically by first
integrating in one dimension,
then a second, and so on for all
dimensions of the problem.
6/27/2016
TOPICS COVERED
2. Romberg Integration (Richardson Extrapolation)

Objective:

Numerical Methods
Understanding how Richardson extrapolation
provides a means to create a more accurate
integral estimate by combining two less accurate
estimates.
Romberg Integration
Successive application of the trapezoidal rule to attain efficient
numerical integrals of functions.
Richardson Extrapolation
• Richard extrapolation methods use two estimates of an integral to
compute a third, more accurate approximation.

• If two O(h2) estimates I(h1) and I(h2) are calculated for an integral using
step sizes of h1 and h2, respectively, an improved O(h4) estimate may be
formed using:
1
I I(h2 )  >I(h2 )  I (h1 )@
(h1 / h2 ) 1
2

• For the special case where the interval is halved (h2=h1/2), this becomes:

4 1
I I(h2 )  I (h1 )
3 3
I I ( h2 )  E ( h2 )
4 1
I I(h2 )  I (h1 )
I # I ( h2 ) 
1
>I (h2 )  I (h1 )@ 3 3
h1 / h2  1
2

Example
Evaluate the integral of f(x) = 0.2 +25x – 200x2 + 675x3 – 900x4 + 400x5
from a=0 to b=0.8. I (True Integral value) = 1.6405

Segments h Integral İtr% Segments 1 & 2 combined to give :


4 1
1 0.8 0.1728 89.5 I# (1.0688)  (0.1728) 1.3675
3 3
E t 1.6405  1.3675 0.273 (H t 16.6%)
2 0.4 1.0688 34.9
Segments 2 & 4 combined to give :
4 0.2 1.4848 9.5 4 1
I# (1.4848)  (1.0688) 1.6234
3 3
In each case, two estimates with E t 1.6405  1.6234 0.0171 (H t 1%)
error O(h2) are combined to give
a third estimate with error O(h4) 4
Richardson Extrapolation (cont.)
• For the cases where there are two O(h4) estimates
and the interval is halved (hm=hl/2), an improved
O(h6) estimate may be formed using:
16 1
I I m  Il
15 15
• For the cases where there are two O(h6) estimates
and the interval is halved (hm=hl/2), an improved
O(h8) estimate may be formed using:
64 1
I I m  Il
63 63
The Romberg Integration Algorithm
4 k 1 I j 1,k 1  I j ,k 1
I j ,k #
4 k 1  1
k=1 refers to trapezoidal rule, hence O(h2) accuracy.
k=2 refers to O(h4) and k=3 Î O(h6)

Index j is used to distinguish between the more (j+1) and the less (j) accurate estimates.

You might also like