Beruflich Dokumente
Kultur Dokumente
Numerical Integration
Integration
𝑏
𝐼= 𝑓(𝑥) 𝑑𝑥
𝑎
Is the total value or summation of 𝑓 𝑥 𝑑𝑥 over the range from a to b
Figure 1 Integration
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
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
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.
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
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
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
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.
Prepared BY
Shahadat Hussain Parvez
EEE 305 Lecture 7: Numerical Integration
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
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 xn2 4 f xn1 f xn
3 3 3
n 1 n2
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
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.
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.
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
Table 2 Newton-Cotes open integration formulas. The step size is given by h = (b − a)/n.
x0 x0 x1 xn1
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.
Prepared BY
Shahadat Hussain Parvez