Sie sind auf Seite 1von 10

EEE 305 Lecture 7: Numerical Integration

Numerical Integration
Integration
𝑏
𝐼= 𝑓(𝑥) 𝑑𝑥
𝑎
Is the total value or summation of 𝑓 𝑥 𝑑𝑥 over the range from a to b

Figure 1 Integration

Newton-Cotes Integration Formulas


The Newton-Cotes formulas are the most common numerical integration schemes. They are based
on the strategy of replacing a complicated function or tabulated data with an approximating
function that is easy to integrate:
𝑏 𝑏
𝐼= 𝑓(𝑥) 𝑑𝑥 ≅ 𝑓𝑛 (𝑥) 𝑑𝑥
𝑎 𝑎
Where 𝑓𝑛 (𝑥) is the nth order interpolating polynomial in the form
𝑓𝑛 𝑥 = 𝑎0 + 𝑎1 𝑥 + 𝑎2 𝑥 2 + 𝑎3 𝑥 3 + ⋯ + 𝑎𝑛−1 𝑥 𝑛−1 + 𝑎𝑛 𝑥 𝑛
The interpolating function can be polynomial of any order. The graphs below shows straight lines or
(b) parabolas.

Figure 2 Use of (a) straingth line (b) parabola to approximate integration


1

The accuracy of the approximation can be increased by segmentation of the range with equal
Page

lengths.

Prepared BY
Shahadat Hussain Parvez
EEE 305 Lecture 7: Numerical Integration

The figure below shows the use of segmentation to approximate integration

Figure 3 the approximation of an integral by the area under three straight-line segments.

Closed and open forms of the Newton-Cotes formulas are available. The closed forms are those
where the data points at the beginning and end of the limits of integration are known (Fig. 4a). The
open forms have integration limits that extend beyond the range of the data (Fig. 4b). In this sense,
they are akin to extrapolation. Open Newton-Cotes formulas are not generally used for definite
integration. However, they are utilized for evaluating improper integrals and for the solution of
ordinary differential equations. This lecture emphasizes more on the closed forms.

Figure 4 the difference between (a) closed and (b) open integration formulas

Trapezoidal Rule
Trapezoidal rule is the first of the Newton-Cotes closed integration formula. It uses 1st order
polynomial to approximate the integration.
𝑏 𝑏
𝐼= 𝑓(𝑥) 𝑑𝑥 ≅ 𝑓1 (𝑥) 𝑑𝑥
𝑎 𝑎
𝑏
𝑓 𝑏 −𝑓 𝑎
𝐼= [𝑓 𝑎 + (𝑥 − 𝑎)]𝑑𝑥
𝑎 𝑏−𝑎
𝑓 𝑎 +𝑓 𝑏
𝐼 = 𝑏−𝑎
2
𝐼 ≅ 𝑊𝑖𝑑𝑡𝑕 × 𝐴𝑣𝑒𝑟𝑎𝑔𝑒 𝑕𝑒𝑖𝑔𝑕𝑡
2
Page

Prepared BY
Shahadat Hussain Parvez
EEE 305 Lecture 7: Numerical Integration

Figure 5 Graphical depiction of trapezoidal rule

The figure below shows the similarity between using trapezoidal rule for integration and actual area
of trapezoid. The difference is that in trapezoidal rule the trapezoid is shifted 90°

Figure 6 (a) The formula for computing the area of a trapezoid: height times the average of the bases. (b) For the
trapezoidal rule, the concept is the same but the trapezoid is on its side.

Error of trapezoidal rule


An estimate for the local truncation error of a single application of the trapezoidal rule is:

f  b  a 
1
Et  
3

12
Where 𝜉 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. Figure 7 below shows the error.

Figure 7 Graphical depiction of the use of a single application of the trapezoidal rule
3

Error can thus be reduced by breaking the curve into parts. Figure 8 in the next page shows how the
Page

error is minimized by breaking a curve into parts

Prepared BY
Shahadat Hussain Parvez
EEE 305 Lecture 7: Numerical Integration

Figure 8 Graphical depiction of the use of multiple application of the trapezoidal rule

Composite 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 (Fig. 9). The areas of
individual segments can then be added to yield the integral for the entire interval. The resulting
equations are called multiple-application, or composite, integration formulas. Assuming n+1 data
points are evenly spaced, there will be n intervals over which to integrate.
𝑏−𝑎
𝑕=
𝑛
where n is the number of segments and h is the height of each segment.
If a and b are designated as x0 and xn, respectively, the total integral can be represented as

I   f n x  dx   f n x  dx   f n x  dx     f n x  dx
xn x1 x2 xn

x0 x0 x1 xn 1

Substituting trapezoidal rule in each segment


f x0   f x1  f x1   f x2  f xn1   f xn 
I  x1  x0   x2  x1     xn  xn1 
2 2 2
Grouping them together we get
h n 1

I  f  x0   2 f xi   f xn 
2 i 1 
Figure 9 shows the composite application of trapezoidal rule
4
Page

Prepared BY
Shahadat Hussain Parvez
EEE 305 Lecture 7: Numerical Integration

Figure 9 Illustration of the multiple-application trapezoidal rule. (a) Two segments, (b) three segments, (c) four
segments, and (d) five segments.

Figure 10 shows the general format and nomenclature we will use to characterizemultiple-
application integrals.

Figure 10 The general format and nomenclature for multiple-applicationintegrals.


5
Page

Prepared BY
Shahadat Hussain Parvez
EEE 305 Lecture 7: Numerical Integration

Error of composite trapezoidal rule


An error for the multiple-application trapezoidal rule can be obtained by summing the individual
errors for each segment to give
3 𝑛
𝑏−𝑎
𝐸𝑡 = − 𝑓 ′ ′ (𝜉𝑖 )
12𝑛3
𝑖=1
′′
Where 𝑓 (𝜉𝑖 )is the second derivative at appoint 𝜉𝑖 located inside segment i.
The approximate error can be calculated as
𝑏−𝑎 3
𝐸𝑎 == − 𝑓′′
12𝑛3
Where
𝑛 ′′ 𝑏
𝑖=1 𝑓 (𝜉𝑖 ) 𝑎
𝑓(𝑥)
𝑓′′ ≅ = 𝑚𝑒𝑎𝑛 𝑠𝑒𝑐𝑜𝑛𝑑 𝑑𝑒𝑟𝑖𝑣𝑎𝑡𝑖𝑣𝑒 ≅
𝑛 𝑏−𝑎
Algorithm for trapezoidal rule

Figure 11 Algorithms for the (a) single-segment and (b) multiple-segment trapezoidal rule.

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.
6

Figure 12 (a) Graphical depiction of Simpson’s 1/3 rule: It consists of taking the area under a parabola connecting three
Page

points. (b) Graphical depiction of Simpson’s 3/8 rule: It consists of taking the area under a cubic equation connecting
four points.

Prepared BY
Shahadat Hussain Parvez
EEE 305 Lecture 7: Numerical Integration

Simpson’s 1/3 rule use 2nd order polynomial for approximation.


𝑏 𝑏
𝐼= 𝑓(𝑥) 𝑑𝑥 ≅ 𝑓2 (𝑥) 𝑑𝑥
𝑎 𝑎
If a and b are designates as 𝑥0 & 𝑥2 and 𝑓2 𝑥 is represented by second order Lagrange polynomial
𝑥 − 𝑥1 𝑥 − 𝑥2 𝑥 − 𝑥1 𝑥 − 𝑥2 𝑥 − 𝑥0 𝑥 − 𝑥1
𝑓𝑛 𝑥 = 𝑓 𝑥0 + 𝑓 𝑥1 + 𝑓(𝑥2 )
𝑥0 − 𝑥1 𝑥0 − 𝑥2 𝑥1 − 𝑥0 𝑥1 − 𝑥2 𝑥2 − 𝑥0 𝑥2 − 𝑥1
The integral becomes
𝑥2
𝑥 − 𝑥1 𝑥 − 𝑥2 𝑥 − 𝑥1 𝑥 − 𝑥2 𝑥 − 𝑥0 𝑥 − 𝑥1
𝐼= 𝑓 𝑥0 + 𝑓 𝑥1 + 𝑓(𝑥2 ) 𝑑𝑥
𝑥0 𝑥0 − 𝑥1 𝑥0 − 𝑥2 𝑥1 − 𝑥0 𝑥1 − 𝑥2 𝑥2 − 𝑥0 𝑥2 − 𝑥1
After integration and algebraic manipulation, the following formula results:
𝑕
𝐼 ≅ 𝑓 𝑥0 + 4𝑓 𝑥1 + 𝑓 𝑥2 𝑑𝑥
3
𝑓 𝑥0 + 4𝑓 𝑥1 + 𝑓 𝑥2
≅ (𝑏 − 𝑎)
6
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
𝐸𝑡 = − 𝑕4 𝑓 4 (𝜉)
90
𝑏−𝑎
Because 𝑕 =
2

f 4   b  a 
1
Et  
5

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.
Multiple application of 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:
𝑏−𝑎
𝑕=
𝑛

I   f n x  dx   f n x  dx   f n x  dx     f n x  dx
xn x2 x4 xn

x0 x0 x2 xn  2

I
h
 f x0   4 f x1   f x2   h  f x2   4 f x3   f x4     h  f xn2   4 f xn1   f xn 
3 3 3
 n 1 n2

h
I f x0   4  f xi   2  f xi   f xn 
3 i 1 j 2

 i , odd j , even 
7
Page

Prepared BY
Shahadat Hussain Parvez
EEE 305 Lecture 7: Numerical Integration

The figure below shows multiple application of Simpson’s 1/3 rule.

Figure 13 Graphical representation of the multiple application of Simpson’s 1/3 rule. Note that the method can be
employed only if the number of segments is even.

Error of multiple application Simpson’s 1/3 Rule


𝑏−𝑎 5 4
𝐸𝑎 = − 𝑓
180 𝑛4
Here 𝑓 4 is the average 4th order derivative for the interval.

Simpson’s 3/8 Rule


In a similar manner to the derivation of the trapezoidal and Simpson’s 1/3 rule, a third order
Lagrange polynomial can be fit to four points and integrated:

I   f n x  dx
x3

x0

To yield

I
3h
 f x0   3 f x1   3 f x2   f x3 
8
where h = (b − a)/3. This equation is called Simpson’s 3/8 rule because h is multiplied by 3/8. It is the
third Newton-Cotes closed integration formula. The 3/8 rule can also be ex-pressed in the form

Thus, the two interior points are given weights of three-eighths, whereas the end points are
weighted with one-eighth. Simpson’s 3/8 rule has an error of
8
Page

𝑏 −𝑎
or, because 𝑕 = 3
,

Prepared BY
Shahadat Hussain Parvez
EEE 305 Lecture 7: Numerical Integration

Simpson’s 3/8 rule is generally used in concert with Simpson’s 1/3 rule when the number of
segments is odd. The figure below shows how this works.

Figure 14 Illustration of how Simpson’s 1/3 and 3/8 rules can be applied in tandem to handle multiple applications with
odd numbers of intervals.

Algorithm to implement Simpsons rule

Figure 15 Pseudocode for Simpson’s rules. (a) Single-application Simpson’s 1/3 rule, (b) single-application Simpson’s 3/8
9

rule, (c) multiple-application Simpson’s 1/3 rule, and (d ) multiple-application Simpson’s rule for both odd and even
Page

number of segments. Note that for all cases, n must be greater or equal to 1.

Prepared BY
Shahadat Hussain Parvez
EEE 305 Lecture 7: Numerical Integration

The tables below shows the summary of Newton-Chotes integration formulas


Table 1 Newton-Cotes closed integration formulas. The step size is given by h = (b − a)/n.

Table 2 Newton-Cotes open integration formulas. The step size is given by h = (b − a)/n.

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:
I   f n x  dx   f n x  dx   f n x  dx     f n x  dx
xn x1 x2 xn

x0 x0 x1 xn1

f x0   f x1  f x1   f x2  f xn 1   f xn 


I  x1  x0   x2  x1     xn  xn 1 
2 2 2

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.

1. Chapra chapter 21 exercise 21.1 – 21.5


2. Chapra examples 21.1-21.7
10
Page

Prepared BY
Shahadat Hussain Parvez

Das könnte Ihnen auch gefallen