SlideShare a Scribd company logo
1 of 99
Download to read offline
PART S
NUMER
Calculusis themathematicsof change.Becauseengineersmust continuouslydeal with sys-
tems andprocessesthatchange,calculusis anessentialtool of ourprofession.Standingatthe
heart of calculusarethe related mathematicalconceptsof differentiationand integration.
According to the dictionary definition, to dlfferentiate means "to mark off by differ-
ences;distinguish;. . .toperceivethedifferenceinorbetween." Mathematically,thederiva-
tive,which servesasthefundamentalvehiclefordifferentiation,representstherateof change
of a dependent variable with respect to an independentvariable.As depicted in Fig. PT6.1,
the mathematicaldefinitionof the derivativebegins with a differenceapproximation:
where y and j(x) are alternative representatives for the dependent variable and x is the
independent variable. If Ax is allowed to approach zero, as occurs in moving from
Fig. PT6.la to c, the difference becomes a derivative
d y
- = lim
f(xr + Ax) - f(xi>
dx AX-o AX
FlGURE PT6.1
The graphical definition of a derivative: as Ax approaches zero in going from (a]to (c],the
differenceapproximation becomes a derivative.
568 NUMERICAL DIFFERENTIATIONAND INTEGRATION
FlGURE PT6.2
Graphical representation of the integral of f(x between the limits x = a to b. The integral is
equivalent to the area under the curve.
where dyldx [which can also be designated as y' orf '(xi)]
is the first derivative of y with re-
spect to x evaluated at xi. As seen in the visual depiction of Fig. PT6.lc, the derivative is
the slope of the tangent to the curve at xi.
The inverse process to differentiation in calculus is integration. According to the dic-
tionary definition, to integrate means "to bring together, as parts, into a whole; to unite; to
indicate the total amount . . . ." Mathematically, integration is represented by
which stands for the integral of the functionf(x) with respect to the independent variable x,
evaluated between the limits x = a to x = b. The functionf(x) in Eq. (PT6.2)is referred to
as the integrand.
As suggested bythedictionarydefinition,the"meaning" of Eq.(PT6.2)isthe totalvalue,
orsummation,off (x)dx over therangex = a to b.In fact,the symbol is actually a stylized
capitalSthat is intended to signify the close connection between integration and summation.
Figure PT6.2 represents a graphical manifestation of the concept. For functions lying
above the x axis, the integral expressed by Eq. (PT6.2)corresponds to the area under the
curve off(x) between x = a and b.'
As outlined above, the "marking off or discrimination" of differentiation and the
"bringing together" of integration are closely linked processes that are, in fact, inversely
'It should be noted that the process represented by Eq. (PT6.2) and Fig. PT6.2 is called definite integration.There
is another type called indefinite integration in which the limits a and b are unspecified. As will be discussed in
Part Seven, indefinite integration deals with determining a function whose derivative is given.
PT6.1 MOTIVATION 569
FIGURE PT6.3
The contrast between (a)differ-
entiation and (b)integration.
related (Fig. PT6.3).For example, if we are given a function y(t) that specifies an object's
position as a function of time, differentiationprovides a means to determine its velocity, as
in (Fig. PT6.3a).
Conversely,if we are provided with velocity as a function of time, integration can be used
to determine its position (Fig. PT6.3b),
Thus, we can make the general claim that the evaluation of the integral
is equivalent to solving the differential equation
for y(b)given the initial condition y(a) = 0.
Becauseof this close relationship,we have opted to devote this part of the book to both
processes. Among other things, this will provide the opportunity to highlight their similar-
ities and differences from a numerical perspective. In addition, our discussion will have
relevance to the next parts of the book, where we will cover differential equations.
NUMERICAL DIFFERENTIATIONAND INTEGRATION
PT6.1.1 Noncornputer Methods For Differentiation and Infegratisn
The function to be differentiatedor integrated will typicallybe in one of the following three
forms:
1. A simple continuous function such as a polynomial, an exponential, or a trigonometric
function.
2. A complicated continuous function that is difficult or impossible to differentiate or in-
tegrate directly.
3. A tabulated function where values of x andf(x) are given at a number of discrete points,
as is often the case with experimental or field data.
In the first case, the derivative or integral of a simple function may be evaluated ana-
lytically using calculus. For the second case, analytical solutions are often impractical, and
sometimes impossible, to obtain. In these instances, as well as in the third case of discrete
data, approximate methods must be employed.
A noncomputer method for determining derivatives from data is called equal-area
graphical dzfferentiation.In this method, the (x,y) data are tabulated and, for each interval,
a simple divided difference AylAx is employed to estimate the slope. Then these values
are plotted as a stepped curve versus x (Fig. PT6.4). Next, a smooth curve is drawn that at-
tempts to approximatethe area under the stepped curve. That is, it is drawn so that visually,
the positive and negative areas are balanced.The rates at given values of x can then be read
from the curve.
In the same spirit, visually oriented approaches were employed to integrate tabulated
data and complicated functions in the precomputer era. A simple intuitive approach is to
plot the function on a grid (Fig. PT6.5) and count the number of boxes that approximate the
area. This number multiplied by the area of each box provides a rough estimate of the total
FIGURE PT6.4
Equal-area differentiation.
(a)Centered finite divided
differences are used to estimate
the derivative for each interval
between the data points.
(b)The derivative estimates are
plotted as a bar graph. A
smooth curve is superimposed
on this plot to a the
area under the Ear graph. This
is accomplished by drawing the
curve so that equal positive and
negative areas are balanced.
(c)Values of dyldx can then be
read off the smooth curve.
PT6.1 MOTIVATION 571
FIGURE PT6.5
The use of a grid to approxi-
mate an integral.
FlGURE PT6.6
The use of rectangles, or strips,
to approximate the integral.
area under the curve. This estimate can be refined, at the expense of additional effort, by
using a finer grid.
Another commonsense approach is to divide the area into vertical segments, or strips,
with a height equal to the function value at the midpoint of each strip (Fig. PT6.6). The area
of the rectangles can then be calculated and summed to estimate the total area. In this
572 NUMERICALDIFFERENTIATION AND INTEGRATION
approach, it is assumed that the value at the midpoint provides a valid approximation of the
average height of the function for each strip. As with the grid method, refined estimates are
possible by using more (and thinner) strips to approximate the integral.
Although such simple approaches have utility for quick estimates, alternative numeri-
cal techniques are available for the same purpose. Not surprisingly, the simplest of these
methods is similar in spirit to the noncomputer techniques.
For differentiation, the most fundamental numerical techniques use finite divided dif-
ferences to estimate derivatives. For data with error, an alternative approach is to fit a
smooth curve to the data with a technique such as least-squares regression and then differ-
entiate this curve to obtain derivative estimates.
In a similar spirit, numerical integration or quadrature methods are available to obtain
integrals. These methods, which are actually easier to implement than the grid approach,
are similar in spirit to the strip method. That is, function heights are multiplied by strip
widths and summed to estimate the integral. However, through clever choices of weighting
factors, the resulting estimate can be made more accurate than that from the simple "strip
method."
As in the simple strip method, numerical integration and differentiation techniques uti-
lize data at discrete points. Because tabulated information is already in such a form, it is
naturally compatible with many of the numerical approaches. Although continuous func-
tions are not originally in discrete form, it is usually a simple proposition to use the given
equation to generate a table of values. As depicted in Fig. PT6.7, this table can then be eval-
uated with a numerical method.
PT6.1.2 Numerical Differentiation and Integration in Engineering
The differentiation and integration of a function has so many engineering applications that
you were required to take differential and integral calculus in your first year at college.
Many specific examples of such applications could be given in all fields of engineering.
Differentiation is commonplace in engineering because so much of our work involves
characterizing the changes of variables in both time and space. In fact, many of the laws
and other generalizations that figure so prominently in our work are based on the pre-
dictable ways in which change manifests itself in the physical world. A prime example is
Newton's second law, which is not couched in terms of the position of an object but rather
in its change of position with respect to time.
Aside from such temporal examples, numerous laws governing the spatial behavior of
variables are expressed in terms of derivatives. Among the most common of these are those
laws involving potentials or gradients. For example, Fourier's law of heat conduction
quantifies the observation that heat flows from regions of high to low temperature. For the
one-dimensional case, this can be expressed mathematically as
dT
Heat flux = -k' -
dx
Thus, the derivative provides a measure of the intensity of the temperature change, or gra-
dient, that drives the transfer of heat. Similar laws provide workable models in many other
areas of engineering, including the modeling of fluid dynamics, mass transfer, chemical re-
action kinetics, and electromagnetic flux. The ability to accurately estimate derivatives is
an important facet of our capability to work effectively in these areas.
PT6.1 MOTIVATION 573
FlGURE BT6.7
Application of a nurner~cal
inte-
gration method: (a)A compli-
cated, cont~nuous
function.
(b)Table of discrete values of
fix) generated from the function.
[c)Use of a numerical method
(the strip method here)to esti-
mate the integral on the basis of
the discrete points. For a tabu-
lated function, the data is al-
ready in tabular form (b);there-
fore, step (a)1s unnecessary.
Just as accurate estimates of derivatives are important in engineering, the calculation
of integrals is equally valuable. A number of examples relate directly to the idea of the in-
tegral as the area under a curve. Figure PT6.8 depicts a few cases where integration is used
for this purpose.
Other common applications relate to the analogy between integration and summation.
For example, a common application is to determine the mean of continuous functions. In
Part Five, you were introduced to the concept of the mean of n discrete data points [recall
Eq. (PT6.1)]:
2 Yi
/ = I
Mean = -
n
where y; are individual measurements. The determination of the mean of discrete points is
depicted in Fig. PT6.9a.
574 NUMERICAL DIFFERENTIATION AND INTEGRATION
FIGURE PT6.8
Examples of how integration is used to evaluate areas in engineering applications. (a]A sur-
veyor might need to know the area of a field bounded by a meandering stream and two roads
[b]A water-resourceengineer might need to know the cross-sectional area of a river. (c)A struc-
tural engineer might need to determine the net force due to a nonuniform wind blowing against
the side of a skyscraper.
FlGURE BT6.9
An illustration of the mean for
(a)discrete and (b)continuous
data
PT6.1 MOTIVATION 575
In contrast, supposethat y is a continuous function of an independent variable x, as de-
picted in Fig. PT6.9b. For this case, there are an infinite number of values between a and
b. Just as Eq. (PT6.3) can be applied to determine the mean of the discrete readings, you
might also be interested in computing the mean or average of the continuous function
y =f(x) for the interval from a to 6. Integration is used for this purpose, as specified by the
formula
l b f ( x )dx
Mean = (PT6.4)
b - a
This formula has hundreds of engineering applications. For example, it is used to calculate
the center of gravity of irregular objects in mechanical and civil engineering and to deter-
mine the root-mean-square current in electrical engineering.
Integrals are also employed by engineers to evaluate the total amount or quantity of a
given physical variable. The integral may be evaluated over a line, an area, or a volume.
For example, the total mass of chemical contained in a reactor is given as the product of the
concentration of chemical and the reactor volume, or
Mass = concentration x volume
where concentration has units of mass per volume. However, suppose that concentration
varies from location to location within the reactor. In this case, it is necessary to sum the
products of local concentrations ci and corresponding elemental volumes AVi:
n
Mass = ci AVi
1=1
where n is the number of discrete volumes. For the continuous case, where c(x, y, z) is a
known function and x, y, and z are independent variables designating position in Cartesian
coordinates, integration can be used for the same purpose:
Mass = c(x,y , z ) d x d y dz
which is referred to as a volume integral. Notice the strong analogy between summation
and integration.
Similar examples could be given in other fields of engineering. For example, the total
rate of energy transfer across a plane where the flux (in calories per square centimeter per
second) is a function of position is given by
which is referred to as an areal integral,where A = area.
576 NUMERICALDIFFERENTIATION AND INTEGRATION
Similarly,for the one-dimensional case, the total mass of a variable-density rod with
constant cross-sectionalarea is given by
where m = total weight (kg),L = length of the rod (m), p(x) = known density (kg/m3)as
a function of lengthx (m), and A = cross-sectional area of the rod (m2).
Finally, integrals are used to evaluate differential or rate equations. Suppose the ve-
locity of a particle is a known continuous function of time v(t),
The total distance y traveled by this particle over a time t is given by (Fig. PT6.3b)
(PT6.5)
These are just a few of the applications of differentiation and integration that you might
face regularly in the pursuit of your profession.When the functions to be analyzed are sim-
ple, you will normally choose to evaluate them analytically. For example, in the falling
parachutist problem, we determined the solution for velocity as a function of time
[Eq. (1.10)]. This relationship could be substituted into Eq. (PT6.5), which could then be
integratedeasily to determinehow far theparachutist fell over a timeperiod t. For this case,
the integral is simple to evaluate. However, it is difficult or impossible when the function
is complicated,as is typically the case in more realistic examples. In addition,the underly-
ing function is often unknown and defined only by measurement at discrete points. For
both these cases,you must have the ability to obtain approximatevalues for derivativesand
integralsusing numerical techniques. Several such techniques will be discussed in this part
of the book.
BT6.2 MATHEMATICAL BACKGROUND
In high school or during your first year of college, you were introduced to differential and
integral calculus. There you learned techniques to obtain analytical or exact derivatives
and integrals.
When we differentiate a function analytically,we generate a second function that can
be used to compute the derivative for different values of the independent variable. General
rules are available for this purpose. For example, in the case of the monomial
the following simple rule applies (n # 0):
which is the expression of the more general rule for
PT6.2 MATHEMATICALBACKGROUND 597
where u = a function of x. For this equation, the derivative is computed via
Two other useful formulas apply to the products and quotients of functions. For example,
if the product of two functions of x(u and v) is represented as y = u v, then the derivative
can be computed as
For the division,y = ulv,the derivative can be computed as
Other useful formulas are summarized in Table PT6.1.
Similar formulas are available for definite integration, which deals with determining
an integral between specified limits, as in
According to thefundamental theorem of integral calculus, Eq. (PT6.6) is evaluated as
where F(x) = the integraloff(x)-that is, any functionsuch that F'(x) =f(x). The nomen-
clature on the right-hand side stands for
TABLE F"T6.1 Some commonly used derivatives.
d
- sin x = cos x
d
-cot x = -csc2 x
dx dx
d
-cos x = -sin x
d
-sec x = sec x tan x
dx dx
d
-tan x = sec2 x
dx
d
-csc x = -csc x cot x
dx
d 1
- logo x = -
-
dx x l n a
578 NUMERICAL DIFFERENTIATIONAND INTEGRATION
An example of a definite integral is
~ 0 . 8
For this case, the function is a simple polynomial that can be integrated analytically by
evaluating each term according to the rule
b
xn dx = - (PT6.9)
where n cannot equal -1. Applying this rule to each term in Eq. (PT6.8) yields
which can be evaluated according to Eq. (PT6.7)as I = 1.6405333.This value is equal to
the area under the original polynomial [Eq. (PT6.8)] between x = 0 and 0.8.
The foregoing integrationdepends on knowledge of the rule expressed by Eq. (PT6.9).
Other functions follow different rules. These "rules" are all merely instances of antidiffer-
entiation, that is, finding F(x) so that Ff(x)=f(x). Consequently,analytical integration de-
pends on prior knowledge of the answer. Such knowledge is acquired by training and
TABLE PT6.2 Some simple integrals that are used in Part Six. The a and b in this table
are constants and should not be confused with the limits of integration
discussed in the text.
J u d v = u v - Jv d u
1
Icos [ax + b) dx= - sin (OX + b)+ C
dx 1 6 6
I
,
, = a ton-' yx + C
PT6.3 ORIENTATION 579
experience. Many of the rules are summarized in handbooks and in tables of integrals. We
list some commonly encountered integrals in Table PT6.2. However, many functions of
practical importance are too complicated to be contained in such tables. One reason why
the techniques in the present part of the book are so valuable is that they provide a means
to evaluate relationships such as Eq. (PT6.8) without knowledge of the rules.
PT6.3 ORIENTATION
Before proceeding to the numerical methods for integration, some further orientation might
be helpful. The following is intended as an overview of the material discussed in Part Six.
In addition, we have formulated some objectives to help focus your efforts when studying
the material.
PT6.3.1 Scope and Preview
Figure PT6.10 provides an overview of Part Six. Chapter 21 is devoted to the most com-
mon approaches for numerical integration-the Newton-Cotes ,formulas. These relation-
ships are based on replacing a complicated function or tabulated data with a simple poly-
nomial that is easy to integrate. Three of the most widely used Newton-Cotes formulas are
discussed in detail: the trapezoidal rule, Simpson's 1/3 rule, and Simpson's 318 rule. All
these formulas are designed for cases where the data to be integrated is evenly spaced. In
addition, we also include a discussion of numerical integration of unequally spaced data.
This is a very important topic because many real-world applications deal with data that is
in this form.
All the above material relates to closed integration, where the function values at the
ends of the limits of integration are known. At the end of Chap. 21, we present open inte-
grationformulas, where the integration limits extend beyond the range of the known data.
Although they are not commonly used for definite integration, open integration formulas
are presented here because they are utilized extensively in the solution of ordinary differ-
ential equations in Part Seven.
The formulations covered in Chap. 21 can be employed to analyze both tabulated data
and equations. Chapter 22 deals with two techniques that are expressly designed to inte-
grate equations and functions: Romherg integration and Gauss quad]-ature.Computer al-
gorithms are provided for both of these methods. In addition, methods for evaluating im-
proper integrals are discussed.
In Chap.23, we present additional information on numerical di'erentiation to supple-
ment the introductory material from Chap. 4. Topics include high-accuracy finite-difference
formulas, Richardson's extrapolation, and the differentiation of unequally spaced data. The
effect of errors on both numerical differentiation and integration is discussed. Finally, the
chapter is concluded with a description of the application of several software packages and
libraries for integration and differentiation.
Chapter 24 demonstrates how the methods can be applied for problem solving. As
with other parts of the book, applications are drawn from all fields of engineering.
A review section, or epilogue, is included at the end of Part Six. This review includes
a discussion of trade-offs that are relevant to implementation in engineering practice. In ad-
dition, important formulas are summarized. Finally, we present a short review of advanced
580 NUMERICAL DIFFERENTIATIONAND INTEGRATION
FIGURE PT6.10
Schematic of the organization of material in Part Six: Numerical Integration and Differentiation.
methods and alternative references that will facilitate your further studies of numerical
differentiation and integration.
PT6.3.2 Goals and Objectives
Study Objectives. After completing Part Six you should be able to solve many numeri-
cal integration and differentiation problems and appreciate their application for engineer-
PT6.3 ORIENTATION 58l
TABLE PT6.3 Specific study objectives for Part Six.
Understand the derivation of the Newton-Cotes formulas; know how to derve the trapezoidal rule and
how to set up the derivation of both of Simpson's rules; recognize that the trapezoidal and Simpson's
1/3 and 3/8 rules represent the areas under flrst-, second-, and third-order polynom~als,
respectively
Know the formulas and error equations for la) the trapezoidal rule, Ib)the multiple-application trape-
zoidal rule, (c)Slmpson's 1/3 rule, (dlSimpson's 3/8 rule, and (e)the multiple-application Simpson's
rule Be able to choose the "best" among these formulas for any particular problem context.
Recognize that Slrnpson's 1/3 rule is fourth-order accurate even though lt IS based on only three points;
realize that all the even-segment-odd-point Newton-Cotesformulas have sim~lar
enhanced accuracy
Know how to evaluate the ~ntegral
and derivative of unequally spaced data.
Recognize the difference between open and closed integration formulas.
Understand the theoret~calbasis of Richardson extrapolation and how ~t IS applied in the Romberg ~nte-
gration algorithm and for numerical differentiation
Understand the fundamental difference between Newton-Cotes and Gauss quadrature formulas.
Recognize why both Romberg integration and Gauss quadrature have utility when ~ntegrating
equa-
tions (as opposed to tabular or discrete data).
Know how open integration formulas are employed to evaluate improper integrals,
Understand the application of high-accuracy numerical-differentiat~on
formulas
Know how to differentiate unequally spaced data.
Recognize the differing effects of data error on the processesof numerical integration and differentiation
ing problem solving. You should strive to master several techniques and assess their relia-
bility. You should understand the trade-offs involved in selecting the "best" method (or
methods) for any particular problem. In addition to these general objectives, the specific
concepts listed in Table PT6.3 should be assimilated and mastered.
Computer Objectives. You have been provided with software and simple computer al-
gorithms to implement the techniques discussed in Part Six. All have utility as learning
tools.
The Numerical Methods TOOLKIT personal computer software is user-friendly. It
employs the trapezoidal rule to evaluate the integral of either continuous functions or tab-
ular data. The graphics associated with this software will enable you to easily visualize
your problem and the associated mathematical operations as the area between the curve
and the x axis. The software is very easy to apply to solve many practical problems and can
be used to check the results of any computer programs you may develop yourself.
In addition, algorithms are provided for most of the other methods in Part Five. This
information will allow you to expand your software library to include techniques beyond
the trapezoidal rule. For example, you may find it useful from a professional viewpoint to
have software to implement numerical integration and differentiation of unequally spaced
data. You may also want to develop your own software for Simpson's rules, Romberg inte-
gration, and Gauss quadrature, which are usually more efficient and accurate than the
trapezoidal rule.
Finally, one of your most important goals should be to master several of the general-
purpose software packages that are widely available. In particular, you should become adept
at using these tools to implement numerical methods for engineering problem solving.
CHAPTER 2
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:
wherefn(x) = a polynomial of the form
where n is the order of the polynomial. For example, in Fig. 21.la, a first-order polynomial
(a straight line) is used as an approximation. In Fig. 21.lh, a parabola is employed for the
same purpose.
The integral can also be approximated using a series of polynomials applied piecewise
to the function or data over segments of constant length. For example, in Fig. 21.2, three
FlGURE 21.1
The approximat~on
of an inte-
gral by the area under (a)a sin-
gle straight line and (b)a single
parabola
NEWTON-COTESINTEGRATION FORMULAS 583
straight-line segments are used to approximate the integral. Higher-order polynomials can
be utilized for the same purpose. With this background, we now recognize that the "strip
method" in Fig. PT6.6 employed a series of zero-order polynomials (that is, constants) to
approximate the integral.
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. 21.3~).
The open forms have integration limits that extend beyond the
range of the data (Fig. 21.3b). In this sense, they are akin to extrapolation as discussed in
Sec. 18.5. Open Newton-Cotes formulas are not generally used for definite integration.
FIGURE 21.2
The approximation of an inte-
gral by the area under three
straight-line segments.
FIGURE 21.3
The difference between
(a]closed and (b)open integra-
tion formulas.
584 NEWTON-COTESINTEGRATION FORMULAS
However, they are utilized for evaluating improper integrals and for the solution of ordi-
nary differential equations. This chapter emphasizes the closed forms. However, material
on open Newton-Cotes formulas is briefly introduced at the end of this chapter.
21.1 THE TRAPEZOIDAL RULE
The trapezoidal rule is the first of the Newton-Cotes closed integration formulas. It corre-
sponds to the case where the polynomial in Eq. (21.1) is first-order:
b b
f(x)dx 2 f1( x ) dx
Recall from Chap. 18that a straight line can be represented as [Eq. (18.2)]
fl(x) = f(a) + f(b) - f(a) (x
b - a
-a)
The area under this straight line is an estimate of the integral off (x) between the limits a
and b:
f(b) - f(a) (x - )
b - a
The result of the integration (see Box 21.1 for details) is
which is called the trapezoidal rule.
Before integration, Eq. (21.2) can be expressed as This result can be evaluated to give
f(b) - f W X +f(a) -
f l ( x )=
af(b)- af(a)
b - a b - a
I =
f(b) - f(a) (b2-a2)+ bf(a)- af(b)(b- a )
b - a 2 b - a
Grouping the last two terms gives Now, since b2 - a2 = (b - a)(b+a),
f1(x) =
f(b) - f(a)x + bf(a)-af(a) - af(b)+af(a) b + a
b - a b - a I = [ f ( b )- f(a)l +bf(a>- af(b)
or Multiplying and collecting terms yields
f1(x) =
f(b) - f(a)x + bf(a)-of@)
b - a b - a
which can be integrated between x = a and x = b to yield which is the formula for the trapezoidal rule.
I = f(b) - f(a)
*+
b - a 2
21.1 THE TRAPEZOIDAL RULE 585
Geometrically, the trapezoidal rule is equivalent to approximating the area of the
trapezoid under the straight line connectingf(a) andf(b) in Fig. 21.4.Recall from geome-
try that the formula for computingthe area of a trapezoid is the height times the averageof
the bases (Fig. 21.5~).
In our case, the concept is the same but the trapezoid is on its side
(Fig. 21.5b). Therefore,the integral estimate can be represented as
I E width x average height (21.4)
FIGURE 21.4
Graphical depiction of the trapezoidal rule.
FIGURE 21.5
[a)The formula for computin the area of a trapezoid: height times the average of the bases
[b)For the trapezoidal rule, R
t e concept is the same but the trapezoid is on its side.
586 NEWTON-COTESINTEGRATIONFORMULAS
I E (h- a) x average height (21.5)
where, for the trapezoidal rule, the average height is the average of the function values at
the end points, or [f(a) +f(b)]/2.
All the Newton-Cotes closed formulas can be expressed in the general format of
Eq. (21.5). In fact, they differ only with respect to the formulation of the average height.
21.I. 1 Error of the Trapezoidal Rule
When we employ the integral under a straight-line segment to approximate the integral
under a curve, we obviously can incur an error that may be substantial (Fig. 21.6). An
estimate for the local truncation error of a single application of the trapezoidal rule is
(Box. 21.2)
where <lies somewhere in the interval from a to b. Equation (21.6) indicates that if the
function being integrated is linear, the trapezoidal rule will be exact. Otherwise, for func-
tions with second- and higher-order derivatives (that is, with curvature), some error can
occur.
FIGURE 21.6
Graphical depiction of the use of a single opplication of the trapezoidal rule to approximate the
integral of fix) = 0.2 + 25x - 200x2 + 675x3 - 900x4 + 400x5 from x = 0to 0.8.
21.1 THE TRAPEZOIDALRULE 587
An alternative derivation of the trapezoidal rule is possible by inte- constant, this equation can be integrated:
grating the forward Newton-Gregory interpolating polynomial. Re-
call that for the first-order version with error term, the integral 1 = h
would be (Box 18.2)
a I and evaluated as
1 = Sb[ f ( a )+Af(o)a +m a ( a - l)h2 dx (821.2.1)
2
To simplify the analysis, realize that because a = (x - a)/h,
Because Af(a) =f(b) -f(a),the result can be written as
dx = h da
Inasmuch as h = b - a (for the one-segment trapezoidal rule), the
limits of integration a and b correspond to 0 and 1, respectively.
Therefore, Eq. (B21.2.1)can be expressed as
I = h ' [ f ( a )+Af(a)a +m a ( , - l)h2 d o
2 1 le and the second is an
approximation for the error.
If it is assumed that, for small h, the term f"(6) is approximately
EXAMPLE 2 1.1 Single Application of the Trapezoidal Rule
I Problem Statement. Use Eq. (21.3)to numerically integrate
i
i f(x) = 0.2 +25x - 200x2+675x3 - 900x4 +400x5
from a = 0 to b = 0.8.Recall from PT6.2 that the exact value of the integral can be deter-
mined analytically to be 1.640533.
Solution. The function values
can be substituted into Eq. (21.3)to yield
which represents an error of
which corresponds to a percent relative error of E, = 89.5%. The reason for this large error
is evident from the graphical depiction in Fig. 21.6. Notice that the area under the straight
line neglects a significant portion of the integral lying above the line.
In actual situations, we would have no foreknowledge of the true value. Therefore,
an approximate error estimate is required. To obtain this estimate, the function's second
588 NEWTON-COTESINTEGRATION FORMULAS
1 derivative over the interval can be computed by differentiating the original function twice
I to give
i
fl'(x) = -400 +4 0 5 0 ~
- 10,800x2+8000x3
I
!
, The average value of the second derivative can be computed using Eq. (PT6.4):
0 8
I ( -400 +4050x - 10,800x2+8000x3) dx
i f "(x) = = -60
0.8 - 0
i
a
which can be substituted into Eq. (21.6) to yield
I
1 which is of the same order of magnitude and sign as the true error. A discrepancy does exist,
' however, because of the fact that for an interval of this size, the average second derivative
I .is not necessarily an accurate approximation off'((). Thus, we denote that the error is ap-
proximate by using the notation E,, rather than exact by using E,.
I
21,1.2 The Multiple-ApplicationTrapezoidal Rule
One way to improve the accuracy of the trapezoidal rule is to divide the integration interval
from a to h into a number of segments and apply the method to each segment (Fig. 21.7).
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.
Figure 21.8 shows the general format and nomenclature we will use to characterize
multiple-application integrals. There are n + 1 equally spaced base points (xo,XI,x;?,. . .,
x,). Consequently, there are n segments of equal width:
If a and h are designated as xo and x,, respectively, the total integral can be represen-
ted as
Substituting the trapezoidal rule for each integral yields
or, grouping terms,
n-l
21.1 THE TRAPEZOIDAL RULE 589
FlGURE 21-7
Illustration of the multiple-appl~cation
trapezoidal rule. (a)Two segments, (b)three segments,
(c)four segments, and (d)five segments.
590 NEWTON-COTESINTEGRATIONFORMULAS
FIGURE 21.8
The general format and nornen-
clature for multiple-application
integrals.
or, using Eq. (21.7)to express Eq. (21.9)in the general form of Eq. (21.5),
Because the summation of the coefficients off(x) in the numerator divided by 2n is equal
to 1,the average height represents a weighted average of the function values. According to
Eq. (21.lo),the interior points are given twice the weight of the two end pointsf(x0) and
f(-4.
An error for the multiple-application trapezoidal rule can be obtained by summing the
individual errors for each segment to give
21.1 THE TRAPEZOIDAL RULE 5 91
where f1'(Ci)is the second derivative at a point cilocated in segment i. This result can be
simplified by estimating the mean or average value of the second derivative for the entire
interval as [Eq. (PT6.3)]
Cf "(ti)
Therefore Cf "(C;)
;
.
) nf and Eq. (21.11)can be rewritten as
Thus, if the number of segments is doubled, the truncation error will be quartered. Note
that Eq. (21.1 3) is an approximate error because of the approximate nature of Eq. (21.12).
EXAMPLE 2 1.2 Multiple-Application Trapezoidal Rule
i Problem Statement. Use the two-segment trapezoidal rule to estimate the integral of
1 f ( x ) = 0.2 +25x - 200x2 +675x3- 900x4 +400x5
I
from a = 0 to h = 0.8. Employ Eq. (21.13)to estimate the error. Recall that the correct
a
value for the integral is 1.640533.
i Solution. n = 2(h = 0.4):
: where -60 is the average second derivative determined previously in Example 21.1
The results of the previous example, along with three- through ten-segment applica-
tions of the trapezoidal rule, are summarized in Table 21.1. Notice how the error decreases
as the number of segments increases. However, alsonotice that the rate of decrease is grad-
ual. This is because the error is inversely related to the square of n [Eq. (21.13)].
Therefore,
doubling the number of segments quarters the error. In subsequent sections we develop
higher-order formulas that are more accurate and that converge more quickly on the true in-
tegral as the segments are increased. However, before investigating these formulas, we will
first discuss computer algorithms to implement the trapezoidal rule.
21
.
1
.
3 Computer Algorithms For the Trapezoidal Rule
Two simple algorithms for the trapezoidal rule are listed in Fig. 21.9. The first (Fig. 21.9~)
is for the single-segment version. The second (Fig. 21.9h) is for the multiple-segment
version with a constant segment width. Note that both are designed for data that is in tabu-
592 NEWTON-COTESINTEGRATION FORMULAS
TABLE 21.I Results for multiple-applicationtrapezoidal
rule to estimate the integral of f(x)= 0.2
+ 25x - 200x2+ 675x3 - 900x4+ 400x5
from x = 0 to 0.8. The exact value is
1.640533.
(a) Single-segment (b) Multiple-segment
FliNCTiON Trap (h, &O,
fl) FUNCTION Trapm (h, n, f)
Trap = h +
+ j f O +f?) / 2 sum = fo
EWD Trap D O i = I, n - I
sum = sum + 2 * F,
END GO
sum = sum + f,
Trapm = h * s u m / 2
END frapm
FIGURE 21.9
Algor~thns
for the (a]sngle-segmentand (b]multiple-segmenttrapezo~dal
rule
lated form. A general program should have the capability to evaluate known functions or
equations as well. We will illustrate how functions are handled in the next chapter.
An example of a user-friendly program for the multiple-segment trapezoidal rule is in-
cluded in the supplementary Numerical Methods TOOLKIT software associated with this
text. This software can evaluate the integrals of either tabulated data or user-defined func-
tions. The following example demonstrates its utility for evaluating integrals. It also pro-
vides a good reference for assessing and testing your own software.
EXAMPLE 21.3 Evaluating Integrals with the Computer
Problem Statement. Use the Numerical Methods TOOLKIT software to solve a prob-
lem related to our friend the falling parachutist. As you recall from Example 1.1, the
velocity of the parachutist is given as the following function of time:
21.1 THE TRAPEZOIDAL RULE 593
2
where v = velocity (m/s), g = the gravitational constant of 9.8 m/s , m = mass of the
parachutist equal to 68.1 kg, and c = the drag coefficient of 12.5kg/s. The model predicts
the velocity of the parachutist as a function of time as described in Example 1.1.
Suppose we would like to know how far the parachutist has fallen after a certain time t.
This distance is given by [Eq. (PT6.5)I
i
I where d is the distance in meters. Substituting Eq. (E21.3. I),
Use the Numerical Methods TOOLKIT software and your own software to determine this
I integral with the multiple-segment trapezoidal rule using different numbers of segments.
1 Note that performing the integration analytically and substituting known parameter values
[ results in an exact value of d = 289.43515 m.
Solution. Click the Integrate Function button on the TOOLKIT main menu to obtain a
blank screen similar to Fig. 21.10. This screen contains the input and output information
needed to integrate an analytical function or tabular data.
First, we can click the Input Function table and enter the function,
Next click the Input Parameters block and enter values for the lower and upper limits of in-
tegration of 0 and 10. Next, enter the value 10 for the number of segments along with plot
dimensions, as in Fig. 21.lo.
1 FIGURE21.10
1 Computer screen showing the integral of a function using the multiple-segment trapezoidal rule
1 program from the Numerical Methods TOOLKIT.
j
594 NEWTON-COTESINTEGRATIONFORMULAS
After clicking the Calc and Plot buttons, a calculated integral of 288.7491 is displayed.
Thus, we have attained the integral to three significant digits of accuracy. The integral is
equivalent to the area under the v(t)versus t curve, as shown in Fig. 21.10. Visual inspec-
tion confirms that the integral is the width of the interval (10 s) times the average height
(about 29 m/s). Aplot of the function showing the segments is shown in Fig. 21.10. We can
conveniently try other numbers of segments. By n = 500, the result is accurate to six sig-
nificant digits.
At this point, it is important to recognize that the Numerical Methods TOOLKIT uses
double precision to obtain its integral estimate. We therefore repeated this problem using a
program based on the pseudocode from Fig. 21.9b and employed single-precision numbers
(i.e., about seven significant decimal digits of precision). The results are
Segments Segment size Estimated d, m
Thus, up to about 500 segments, the multiple-application trapezoidal rule attains
excellent accuracy. However, notice how the error changes sign and begins to increase in
absolute value beyond the 500-segment case. The 10,000-segment case actually seems to
be diverging from the true value. This is due to the intrusion of round-off error because of
the great number of computations for this many segments. Thus, the level of precision is
limited, and we would never reach the exact result of 289.4351 obtained analytically. This
limitation will be discussed in further detail in Chap. 22.
Three major conclusions can be drawn from the Example 21.3:
For individual applications with nicely behaved functions, the multiple-segment trape-
zoidal rule is just fine for attaining the type of accuracy required in many engineering
applications.
If high accuracy is required, the multiple-segment trapezoidal rule demands a great deal
of computational effort. Although this effort may be negligible for a single application,
it could be very important when (a)numerous integrals are being evaluated or (b) where
the function itself is time consuming to evaluate. For such cases, more efficient ap-
proaches (like those in the remainder of this chapter and the next) may be necessary.
Finally, round-off error can represent a limitation on our ability to determine integrals.
This is due both to the machine precision as well as to the numerous computations
involved in simple techniques like the multiple-segment trapezoidal rule.
21.2 SIMPSON'S RULES 595
We now turn to one way in which efficiency is improved. That is, by using higher-
order polynomials to approximate the integral.
SIMPSON'S RULES
Aside from applying the trapezoidal rule with finer segmentation, another way to obtain a
more accurate estimate of an integral is to use higher-order polynomials to connect the
points. For example, if there is an extra point midway between f(a) and f(b),the three
points can be connected with a parabola (Fig. 21.11~).
If there are two points equally
spaced between f(a) andf(b),the four points can be connected with a third-order polyno-
mial (Fig. 21.1lb).The formulas that result from taking the integrals under these poly-
nomials are called Simpson's rules.
21.2.1 Simpson's 1/ 3 Rule
Simpson's 1/3 rule results when a second-order interpolating polynomial is substituted
into Eq. (21.1):
If a and b are designated as xo and x2 andf2(x)is represented by a second-order Lagrange
polynomial [Eq. (18.23)], the integral becomes
FIGURE 28.1 1
[a)Graphical depiction of Simp-
son's 1 /3 rule: it consists of
takin the area under a
paraEola connecting three
points. (b]Graphical depiction
of Simpson's 318 rule: it con-
sists of taking the area under a
cubic equation connecting four
points.
596 NEWTON-COTESINTEGRATIONFORMULAS
After integration and algebraic manipulation, the following formula results:
4(,4 i where, for thls case, h = (b - a)/2.This equation is known as Slmpson's 113 rule. It is the
A *
.
J b second Newton-Cotes closed integration formula. The label "1/3" stems from the fact that
h is divided by 3 in Eq. (21.14).An alternative denvation is shown in Box 21.3 where the
Newton-Gregory polynom~alis integrated to obtain the same formula.
Simpson's 113rule can also be expressed using the format of Eq. (21.5):
3 Derivation and Error
As was done in Box 21.2 for the trapezoidal rule, Simpson's 113
rule can be derived by integrating the forward Newton-Gregory in-
terpolating polynomial (Box 18.2):
Notice that we have written the polynomial up to the fourth-order
term rather than the third-order term as would be expected.The rea-
son for this will be apparent shortly. Also notice that the limits of
integration are from xo to x2. Therefore, when the simplifying sub-
stitutions are made (recall Box 21.2), the integral is from u =
0 to 2:
+ - - - + - - -
a 2 ) ,f*)(5)h412
( 2 8 o
and evaluated for the limits to give
A2f(x0)
2f(xo)+2Af(xo)+-
-
-
3
(B21.3.1)
Notice the significant result that the coefficient of the third divided
difference is zero. Because Af(xo)=f(xl) -f(xo) and A2f(xo)=
f(x2) - 2f(xl)+f(xo),Eq. (B21.3.1)can be rewritten as
/I I
I = - If(.r") +4f(xt)+f(sz)j- -f'"'(4)h5
3 90
' -
Strnpson's 1'3 rule Truncation error
4 u ( u- 1 - 2 - 3 ) da
+-
-
I Thus, the first tern is Simpson's 113rule and the second is the trun-
24 cation error. Because the third divided difference dropped out, we
which can be integrated to yield obtain the significant result that the formula is third-order accurate.
21.2 SIMPSON'S RULES 597
where a = xo, h = x2, and xl = the point midway between a and 6, which is given by
(b +a)/2. Notice that, according to Eq. (21.15), the middle point is weighted by two-
thirds and the two end points by one-sixth.
It can be shown that a single-segment application of Simpson's 1/3 rule has a trunca-
tion error of (Box 21.3)
or, because h = (h - a)/2,
where <lies somewhere in the interval from a to b. Thus, Simpson's 113 rule is more ac-
curate than the trapezoidal rule. However, comparison with Eq. (21.6) indicates that it is
more accurate than expected. Rather than being proportional to the third derivative, the
error is proportional to the fourth derivative. This is because, as shown in Box 21.3, the co-
efficient of the third-order term goes to zero during the integration of the interpolating
polynomial. Consequently, Simpson's 1/ 3 rule is third-order accurate even though it is
based on only three points. In other words, it yields exact results for cubic polynomials
even though it is derived from a parabola!
EXAMPLE 2 1.4 Single Application of Simpson's 1/3 Rule
: Problem Statement. Use ~ q .
(21.15)to integrate
I
; f(x) = 0.2 +25n - 200x2 +675x3- 900x4 +400x5
I
1
from a = 0 to b = 0.8. Recall that the exact integral is 1.640533.
I Solution.
i
I
Therefore, Eq. (21.15)can be used to compute
j which represents an exact error of
3
Et = 1.640533 - 1.367467 = 0.2730667 = 16.6%
1
i which is approximately 5 times more accurate than for a single application of the trape-
i zoidal rule (Example 21.1).
I
The estimated error is [Eq .(21.16)]
; where -2400 is the average fourth derivative for the interval as obtained using Eq. (PT6.4).
' As was the case in Example 21.1, the error is approximate (E,) because the average fourth
598 NEWTON-COTESINTEGRATIONFORMULAS
r derivative is not an exact estimate off (4)(<). However, because this case deals with a fifth-
: order polynomial, the result matches.
L
-
-
- -------- ------- -----
-
-
- --------------- -
21.2.2 The Multiple-ApplicationSimpson's 1/3 Rule
Just as with the trapezoidal rule, Simpson's rule can be improved by dividing the integra-
tion interval into a number of segments of equal width (Fig. 21.12):
h - a
h = -
n
The total integral can be represented as
Substituting Simpson's 113rule for the individual integral yields
+...+2h
f(xn-2) +4f(xn-1> +f ( ~ n >
6
or, combining terms and using Eq. (21.17),
1=1,3,5 j=2.4.h
1 2 (b -u ) (21 18,
3n
-- /
Width Average height
FlGURE 21.12
Graphical representation of the
multiple application of Simp-
son's 1/3 rule Note that the
method can be employed only
if the number of segments is
even.
21.2 SIMPSON'S RULES 599
Notice that, as illustrated in Fig. 21.12, an even number of segments must be utilized to
implement the method. In addition, the coefficients "4" and "2" in Eq. (21.18) might seem
peculiar at first glance. However, they follow naturally from Simpson's 1/3 rule. The odd
points represent the middle term for each application and hence carry the weight of 4 from
Eq. (21.15). The even points are common to adjacent applications and hence are counted
twice.
An error estimate for the multiple-application Simpson's rule is obtained in the same
fashion as for the trapezoidal rule by summing the individual errors for the segments and
averaging the derivative to yield
where f (4) is the average fourth derivative for the interval.
EXAMPLE 2 1.5 Multiple-Application Version of Simpson's 1/3 Rule
I Problem Statement. Use Eq. (21.18) with n = 4 to estimate the integral of
i
1 f(x) = 0.2 +25.1 - 200x2+675x3- 900x4+400x5
from a = 0 to h = 0.8. Recall that the exact integral is 1.640533.
j
! Solution. n = 4 (h = 0.2):
I
The estimated error [Eq. (21.19)] is
1
The previous example illustrates that the multiple-application version of Simpson's
113rule yields very accurate results. For this reason, it is considered superior to the trape-
zoidal rule for most applications. However, as mentioned previously, it is limited to cases
where the values are equispaced. Further, it is limited to situations where there are an even
number of segments and an odd number of points. Consequently, as discussed in the next
section, an odd-segment-even-point formula known as Simpson's 3/8 rule is used in con-
junction with the 1/3 rule to permit evaluation of both even and odd numbers of segments.
600 NEWTON-COTESINTEGRATION FORMULAS
21
.
2
.
3 Simpson's 318 Rule
In a similar manner to the derivation of the trapezoidal and Simpson's 113 rule, a third-
order Lagrange polynomial can be fit to four points and integrated:
to yield
where h = (h - a)/3.This equation is called Simpson's318 rule because h is multiplied by
318. It is the third Newton-Cotes closed integration formula. The 318 rule can also be ex-
pressed in the form of Eq. (21.5):
FIGURE 21.13
lliustration of how Simpson's
1/3 and 3/8 rules can be
applied in tandem to handle
rnult~ple
applications with odd
numbers of intervals.
21.2 SIMPSON'S RULES 601
Thus, the two interior points are given weights of three-eighths, whereas the end points are
weighted with one-eighth. Simpson's 3/8rule has an error of
or, because h = (b- a)/3,
Because the denominator of Eq. (21.21)
is larger than for Eq. (21.16),
the 3/8rule is some-
what more accurate than the 1/3 rule.
Simpson's 113 rule is usually the method of preference because it attains third-order
accuracy with three points rather than the four points required for the 3/8version. How-
ever, the 3/8rule has utility when the number of segments is odd. For instance, in Ex-
ample 21.5 we used Simpson's rule to integrate the function for four segments. Suppose
that you desired an estimate for five segments. One option would be to use a multiple-
application version of the trapezoidal rule as was done in Examples 21.2 and 21.3.This
may not be advisable, however, because of the large truncation error associated with this
method. An alternative would be to apply Simpson's 1/3 rule to the first two segments
and Simpson's 3/8rule to the last three (Fig. 21.13).
In this way, we could obtain an es-
timate with third-order accuracy across the entire interval.
EXAMPLE 2 1.6 Simpson's 3 / 8 Rule
Problem Statement.
(a) Use Simpson's 3/8rule to integrate
from a = 0 to b = 0.8.
(b) Use it in conjunction with Simpson's 113 rule to integrate the same function for five
segments.
I Solution.
(a)A single application of Simpson's 3/8rule requires four equally spaced points:
,f(O) = 0.2 f(0.2667)
= 1.432724
f(0.5333)= 3.487177 f(0.8)= 0.232
Using Eq. (21.20),
0.2+3(1.432724+3.487177)+0.232=
I 2 0.8
8
602 NEWTON-COTESINTEGRATIONFORMULAS
(b) The data needed for a five-segment application (h = 0.16) is
f(0) = 0.2 f(0.16) = 1.296919
f(0.32) = 1.743393 f(0.48) = 3.186015
f(0.64) = 3.181929 f(O.80) = 0.232
The integral for the first two segments is obtained using Simpson's 1/3 rule:
For the last three segments, the 318 rule can be used to obtain
The total integral is computed by summing the two results:
I = 0.3803237 + 1.264753 = 1.645077
E, = 1.640533 - 1.645077 = -0.00454383 E, = -0.28%
21.2.4 Computer Algorithms for Simpson" Rules
Pseudocode for a number of forms of Simpson's rule are outlined in Fig. 21.14. Note that
all are designed for data that is in tabulated form.A general program should have the capa-
bility to evaluate known functions or equations as well. We will illustrate how functions are
handled in the next chapter.
Notice that the program in Fig. 21.14d is set up so that either an even or odd number
of segments may be used. For the even case, Simpson's 113 rule is applied to each pair of
segments, and the results are summed to compute the total integral. For the odd case, Simp-
son's 318 rule is applied to the last three segments, and the 113rule is applied to all the pre-
vious segments.
21.2.5 Higher-Order Nedon-Cotes Closed Formulas
As noted previously, the trapezoidal rule and both of Simpson's rules are members of a
family of integrating equations known as the Newton-Cotes closed integration formulas.
Some of the formulas are summarized in Table 21.2, along with their truncation-error esti-
mates.
Notice that, as was the case with Simpson's 113 and 318 rules, the five- and six-point
formulas have the same order error. This general characteristic holds for the higher-point
formulas and leads to the result that the even-segment-odd-point formulas (for example,
113rule and Boole's rule) are usually the methods of preference.
However, it must also be stressed that, in engineering practice, the higher-order (that
is, greater than four-point) formulas are rarely used. Simpson's rules are sufficient for most
applications. Accuracy can be improved by using the multiple-application version. Fur-
thermore, when the function is known and high accuracy is required, methods such as
21.2 SIMPSON'S RULES 603
(a)
FUNCTION Simp13 (h, fO, f?,f2)
Simp13 = 2*h* (f0+4*Fl+f2) / 6
END Simp13
(b)
FUNCTION Simp38 (h, fO, f?,f2, f 3 )
Simp38 = 3*h* (f0+3*(fltf2)+f3) / 8
END 5imp38
( ~ 9
FUNCTION 5imp13m [h, n, f )
sum = f(0)
DO;= 1,n - 2 , 2
s u m = s u m + 4 * f , + 2 * F , + 7
END DO
sum = sum +4 * f n - , + f,
Sirnp13m = h * sum / 3
END SimpI3m
(4
FUNCTION Simplnt(a, b, n, f)
h = ( b - a ) / n
IF n = 1 THEN
sum = Trap(h, f,-l, f,)
ELSE
m = n
odd = n / 2 - INT(n / 2 )
I F o d d > O A N D n > I T H E N
sum = sum+5imp38(h,fn-sfn-2,fn-1,fn)
m = n - 3
END IF
IF m > 1THEN
sum = sum + 5imp13m(h, m, f)
END IF
END IF
Simplnt = sum
END Simplnt
FBOURE 21.I4
Pseudocode for Simpson's rules. (a)Single-application Simpson's 1/ 3 rule, [b)s~ngle-application
Simpson's 318 rule, [c)multiple-applicationSimpson's 1/3 rule, and [d)multiple-application
Simpson's rule for both odd and even number of segments. Note that for all cases n must be > I
TABLE 21 Newton-Cotes closed integration formulas. The formulas are presented in the
format of Eq. (21.5)so that the weighting of the data points to estimate the
average height is apparent. The step size is given by h = (b- o)/n.
Segmenb
(4 Points Name Formula Truncation Error
1 2 f(xoi+ {(xii
Trapezoidal rule (b- a)7
2 3 Simpson's 1/ 3 rule (b- a]
fix01+4fix1) +fix21
6
3 4 Simpson's 318 rule (b- a) fixo) + 3fIx11 + 3 f ( ~ ~ ]
+ Fix3]
8 - i3/80)h5f141([)
4 5 Boole's rule Ib- a
1 7fIxol + 32fix1)
+ 12fIxz)+ 32fix31 +7f(x4)
90 - (8/945)h7f161[c]
604 NEWTON-COTES INTEGRATION FORMULAS
Romberg integration or Gauss quadrature, described in Chap. 22, offer viable and attrac-
tive alternatives.
21.3 IlUTEGlZATlON WITH UNEQUAL SEGMENTS
To this point, all formulas for numerical integration have been based on equally spaced
data points. In practice, there are many situations where this assumption does not hold and
we must deal with unequal-sized segments. For example, experimentally derived data is
often of this type. For these cases, one method is to apply the trapezoidal rule to each seg-
ment and sum the results:
where hi= the width of segment i. Note that this was the same approach used for the
multiple-application trapezoidal rule. The only difference between Eqs. (21.8) and (21.22)
is that the h's in the former are constant. Consequently, Eq. (21.8) could be simplified
by grouping terms to yield Eq. (21.9). Although this simplification cannot be applied to
Eq. (21.22), a computer program can be easily developed to accommodate unequal-sized
segments. Before describing such an algorithm, we will illustrate in the following exam-
ple how Eq. (21.22) is applied to evaluate an integral.
EXAMPLE 2 1.7 Trapezoidal Rule with Unequal Segments
Problem Statement. The information in Table 21.3 was generated using the same
polynomial employed in Example 21.1. Use Eq. (21,22) to determine the integral for this
data. Recall that the correct answer is 1.640533.
Solution. Applying Eq. (21.22) to the data in Table 21.3 yields
which represents an absolute percent relative error of E, = 2.8%
TABLE 21.3 Data for f(x)= 0.2 +25x - 200x2+675x3 -
900x4 +400x5,with unequally spaced values
X f(X) X f (XI
00 0200000 0.44 2.842985
0.12 1.309729 0.54 3.507297
0.22 1.305241 0.64 3.181929
0.32 1 743393 0.70 2 363000
0.36 2.074903 0.80 0.232000
040 2.456000
21.3 INTEGRATIONWITH UNEQUAL SEGMENTS 605
FIGURE 2 1.1 5
Use of the trapezoidal rule to determine the integral of unevenly spaced data. Notice how the
shaded segments could be evaluated with Sirnpson's rule to attain higher accuracy.
The data from Example 21.7 is depicted in Fig. 21.15. Notice that some adjacent seg-
ments are of equal width and, consequently,could have been evaluated using Simpson's
rules. This usually leads to more accurate results, as illustrated by the following example.
EXAMPLE 2 1.8 Inclusion of Simpson's Rules in the Evaluation of Uneven Data
1 Problem Statement. Recompute the integral for the data in Table 21.3, but use
/ Simpson's rules for those segments where they are appropriate.
Solution. The first segment is evaluated with the trapezoidalrule:
1
1 Becausethe next two segmentsfromx = 0.12 to 0.32 are of equal length,their integralcan
be computed with Simpson's 113rule:
8
1 The next three segments are also equal and, as such, may be evaluated with the 3/8 rule to
! give I = 0.2726863. Similarly, the 1/3 rule can be applied to the two segments from
x = 0.44 to 0.64 to yield I = 0.6684701. Finally, the last two segments, which are of un-
I equal length, can be evaluated with the trapezoidal rule to give values of 0.1663479 and
1 0.1297500, respectively.The area of these individual segments can be summed to yield a
606 NEWTON-COTESINTEGRATION FORMULAS
1 total integral of 1.603641. This represents an error of el = 2.2%, which is superior to the
! result using the trapezoidal rule in Example 21.7.
L
Computer Program for Unequally Spaced Data. It is a fairly simple proposition to
program Eq. (21.22). Such an algorithm is listed in Fig. 21.16~.
However,as demonstrated in Example 21.8, the approach is enhanced if it implements
Simpson's rules wherever possible. For this reason, we have developed a second algorithm
that incorporates this capability.As depicted in Fig 21.16b, the algorithm checks the length
of adjacent segments. If two consecutive segments are of equal length, Simpson's 113rule
is applied. If three are equal, the 318 rule is used. When adjacent segments are of unequal
length, the trapezoidal rule is implemented.
FUGURE 21.16
Pseudocode for integratin unequally spaced data. (a)Trapezoidal rule and (b)combination
Simpson's and trapezoida9rules.
(4
FUNCTION Trapun (x, y,n)
LOCAL i, sum
5um = 0
D O i = l , n
sum = sum +(xi - xi-,)~(yi-, +yi)/2
END DO
Trapun = sum
END Trapun
(6)
FUNCTION Uneven (n, x, f )
h = XI - xo
k = 1
sum = 0.
D O j = 1, n
hf = xj+, - X,
J
IF A 0 5 ( h - hf)< .000001THEN
IF k = 3 THEN
sum = sum + Simp13 (h, 5-3,6-8G-I)
k = k - 1
ELSE
k = k + 1
END IF
ELSE
IF k = 1 THEN
sum = sum + Trap (h, j-,,$)
ELSE
IF k = 2 THEN
sum = sum + Simp13 (h, cT2,5-,, 5)
ELSE
sum = sum +Simp38 (h, 5-3, 5-2, 5-,, 5)
END IF
k = l
END IF
END IF
h = hf
END DO
Uneven = sum
END Uneven
PROBLEMS 607
TABLE 21.4 Newton-Cotes open integration formulas. The formulas are presented in the for-
mat of Eq. (21.5) so that the weighting of the data points to estimate the aver-
age height is apparent. The step size is given by h = (b- a)/n.
Segments
(4 Points Name Formula Truncation Error
2 1 Midpoint method lb - oi fix11 [ 1/31h3plt)
.S 4
1 1flx,! + flx2i + fjxgi + 1 1fjx',)
Ib- ai 24 195,') 44)h5f[4lje)
Thus, not only does it allow evaluation of unequal segment data, but if equally
spaced information is used, it reduces to Simpson's rules. As such, it represents a basic,
all-purpose algorithm for the determination of the integral of tabulated data.
21.4 OPEN INTEGMTION FORMULAS
Recall from Fig 21.3b that open integration formulas have limits that extend beyond the
range of the data. Table 21.4 summarizes the Newton-Cotes open integration formulas.
The formulas are expressed in the form of Eq. (21.5) so that the weighting factors are
evident. As with the closed versions, successive pairs of the formulas have the same order
error. The even-segment-odd-point formulas are usually the methods of preference be-
cause they require fewer points to attain the same accuracy as the odd-segment-even-point
formulas.
The open formulas are not often used for definite integration. However, as discussed
in Chap. 22, they have utility for analyzing improper integrals. In addition, they will have
relevance to our discussion of multistep methods for solving ordinary differential equa-
tions in Chap. 26.
PROBLEMS
21.1 Use analytical means to evaluate
(a) (I - .-"I d*
0
21.2 Use a single application of the trapezoidal rule to evaluate the
integrals from Prob. 21.1.
21.3 Evaluate the integrals from Prob. 21.1 with a multiple-
application trapezoidal rule, with n = 2,4, and 6.
21.4 Evaluate the integrals from Prob. 21.1 with a single applica-
tion of Simpson's 113rule.
21.5 Evaluate the integrals from Prob. 21.1 with a multiple-
application Simpson's 113rule, with n = 4 and 6.
608 NEWTON-COTESINTEGRATIONFORMULAS
21.6 Evaluate the integrals from Prob. 21.1 with a single applica-
tion of Simpson's 318 rule.
21.7 Evaluate the integrals from Prob. 21.1, but use a multiple-
application Simpson's rule, with n = 5.
21.8 Integrate the following function using the trapezoidal rule,
with n = 1, 2, 3, and 4:
Compute percent relative errors with respect to the true value of
4.8333 to evaluate the accuracy of the trapezoidal approximations.
21.9 Integrate the following function both analytically and using
Simpson's rules, with n = 4 and 5:
Discuss the results
21.10 Integrate the following function both analytically and nu-
merically. Use both the trapezoidal and Simpson's 113rules to nu-
merically integrate the function. For both cases, use the multiple-
application version, with n = 4.
Compute percent relative errors for the numerical results.
21.11 Integrate the following function both analytically and nu-
merically. For the numerical evaluations use (a) a single applica-
tion of the trapezoidal rule, (b) Simpson's 113 rule, (c) Simpson's
318 rule, (d) Boole's rule, (e) the midpoint method, (f) the 3
segmentl2-point open integration formula, and (g) the 4-
segmentl3-point open integration formula.
21.13 Integrate the following function,
Note that the true value is 0.602297. Evaluate this integral with the
multiple-segment trapezoidal rule. Use a sufficiently high n that
you get 4 significant digits of accuracy. Discuss your results.
21.14 Evaluate the integral of the following tabular data with the
trapezoidal rule:
21.15 Perform the same evaluation as in Prob. 21.14, but use
Simpson's rules.
21.16 Evaluate the integral of the following tabular data using the
trapezoidal rule:
x 1 -3 -1 1 3 5 7 9 1 1
fix) 1 1 -4 -9 2 4 2 6 -3
21.17 Perform the same evaluation as in Prob. 21.16, but use
Simpson's rules.
21.18 Determine the mean value of the function
between x = 2 and 10 by (a) graphing the function and visually
estimating the mean value, (b) using Eq. (PT6.4) and the analyti-
cal evaluation of the integral, and (c) using Eq. (PT6.4) and a five-
segment version of Simpson's rule to estimate the integral. Calcu-
late the relative percent error.
21.19 The function
f(x) = e-'
can be used to generate the following table of unequally spaced data:
Compute percent relative errors for the numerical results. x I 0 0.1 0.3 0.5 0.7 0.95 1.2
21.12 Integrate the following function both analytically and fix) I 1 0.904807408 06065 04
9
6
6 0.38670
.
3
0
1
2
numerically. For the numerical evaluations use (a) single applica-
Evaluate the integral from a = 0 to b = 1.2 using (a) analytical
tion of the trapezoidal rule: (b) Simpson's 113 rule, (c) Simpson's
means, (b) the trapezoidal rule, and (c) a of the trape-
318 rule, (d) multiple application of Simpson's rules (n = 5),
zoidal and Simpson's rules; employ Simpson's rules wherever pos-
(e) Boole's rule, ( f ) the midpoint method, (g) the 3-segment/2-
sible to obtain the highest accuracy. For (b) and (c), compute the
point open integration formula, and (h) the 4-segmentl3-point
percent relative error ( E ~ ) .
open integration formula.
21.20 Evaluate the following double integral:
P R
J (5 +3 sin x) dx
Compute percent relative errors for the numerical results.
PROBLEMS 609
(a) analytically. (b) using a multiple-application trapezoidal rule data. Test your program by duplicating the computation from Ex-
(n = 2), (c) using single applications of Simpson's 113 rule. For ample 21.2.
(b) and (c), compute the percent relative error ( E ~ ) . 21.23 Develop a user-friendly computer program for the multiple-
21.21 Evaluate the triple integral application version of Simpson's rule based on Fig. 21.14~.
Test it
by duplicating the computations from Example 21.5.
l6
/:(x3- 2y2) d . ~
dy dr 21.24 Develop a user-friendly computer program for integrating
unequally spaced data based on Fig. 21.16b. Test it by duplicating
the computation from Example 21.8.
(a) analytically and (b) using single applications of Simpson's 113 21-25 use the Integrate Function program on the Numerical
rule. For (b) compute the percent relative error (s,). MethodsTOOLKIT disk (or your own program fromProb. 21.22)to
Develop a user-friendly computerprogram for the repeat (a) Prob. 21.2, (b) Prob. 21.3, (c) Prob. 21.8, (d) Prob. 21.10,
application trapezoidal rule based on Fig. 21.9. Among (e) Prob. 21.12. Use the graphical option to help you visualize
things, (a) add documentation statements to the code, (b) make the the concept that I = lab
f(x) d x is the area between thef(.x) curve
and Outputuser-Oriented,and (c) the program so that and the axis,Try several differentstep sizes for each problem,
it is capable of evaluating given functions in addition to tabular
CHAPTER 22
ntegration o Equations
In the introduction to Part Six, we noted that functions to be integrated numerically will
typically be of two forms: a table of values or a function. The form of the data has an im-
portant influence on the approaches that can be used to evaluate the integral. For tabulated
information, you are limited by the number of points that are given. In contrast, if the func-
tion is available, you can generate as many values off(x) as are required to attain accept-
able accuracy (recall Fig. PT6.7).
This chapter is devoted to two techniques that are expressly designed to analyze cases
where the function is given. Both capitalize on the ability to generate function values to de-
velop efficient schemes for numerical integration. The first is based on Richardson's ex-
trapolation, which is a method for combining two numerical integral estimates to obtain a
third, more accurate value. The computational algorithm for implementing Richardson's
extrapolation in a highly efficient manner is called Romherg integration. This technique
is recursive and can be used to generate an integral estimate within a prespecified error
tolerance.
The second method is called Gauss quadrature. Recall that, in the last chapter, values
off(x) for the Newton-Cotes formulas were determined at specified values of x. For exam-
ple, if we used the trapezoidal rule to determine an integral, we were constrained to take the
weighted average of f(x) at the ends of the interval. Gauss-quadrature formulas employ x
values that are positioned between a and h in such a manner that a much more accurate in-
tegral estimate results.
In addition to these two standard techniques, we devote a final section to the evalua-
tion of improper integrals. In this discussion, we focus on integrals with infinite limits and
show how a change of variable and open integration formulas prove useful for such cases.
22.1 NEWTON-COTESALGORITHMS FOR EQUATlONS
In Chap. 21, we presented algorithms for multiple-application versions of the trapezoidal
rule and Simpson's rules. Although these pseudocodes can certainly be used to analyze
equations, in our effort to make them compatible with either data or functions, they could
not exploit the convenience of the latter.
Figure 22.1 shows pseudocodes that are expressly designed for cases where the func-
tion is analytical. In particular, notice that neither the independent nor the dependent
FlGURE 22.9
Algorithms for multiple appli-
cations of the (a)trapezoidal
and (b)Simpson's 113 rules,
where the function is available.
FIGURE 22.2
Absolute value of the true per-
cent relative error versus number
of segments for the determina-
tion of the integral of fix) =
0.2 + 25x - 200x2 +
675x3 - 900x4 +400x5,
evaluated from a = O to
b = 0.8 using the multiple-
application trapezoidal rule and
the multiple-application Sirnp-
son's 1/3 rule. Note that both
results indicate that for a large
number of segments, round-off
errors limit precision.
22.1 NEWTON-COTESALGORITHMS F
O
R EQUATIONS 611
(a)
FUNCTION TrapEq (n, a, b)
h = ( b - a ) / n
x = a
sum = f(x)
D O i = 1 , n - 1
x = x + h
sum = sum +2 a (x)
END DO
sum = sum +f(b)
TrapEq = ( b - a) a sum / (2 * n)
END TrapEq
(61
FUNCnON 5impEq (n, a, b)
h = ( b - a ) / n
x = a
sum = (x)
D O i = ? , n - 2,2
x = x + h
sum = sum +4 a(x)
x = x + h
sum = sum +2 xf(x)
END DO
x = x + h
sum = sum +4 ( x )
sum = sum +f(b)
5impEq = (b - a ) * sum / (3 n)
END 5impEq
612 INTEGRATIONO
F EQUATIONS
variable values are passed into the function via its argument as was the case for the codes
in Chap. 21. For the independent variable x, the integration interval (a,b) and the number
of segments are passed. This information is then employed to generate equispaced values
of x within the function. For the dependent variable, the function values in Fig. 22.1 are
computed using calls to the function being analyzed,f(x).
We developed single-precision programs based on these pseudocodes to analyze the
effort involved and the errors incurred as we progressively used more segments to esti-
mate the integral of a simple function. For an analytical function, the error equations
[Eqs. (21.13) and (21.19)] indicate that increasing the number of segments n will result in
more accurate integral estimates. This observation is borne out by Fig. 22.2, which is a plot
of true error versus n for the integral of f(x) = 0.2 + 25x - 200x2 + 675x3 - 900x4 +
400x5.Notice how the error drops as n increases. However, also notice that at large values
of n, the error starts to increase as round-off errors begin to dominate. Also observe that a
very large number of function evaluations (and, hence, computational effort) is required to
attain high levels of accuracy. As a consequence of these shortcomings, the multiple-
application trapezoidal rule and Simpson's rules are sometimes inadequate for problem
contexts where high efficiency and low errors are needed.
Romberg integration is one technique that is designed to attain efficient numerical integrals
of functions. It is quite similar to the techniques discussed in Chap. 21, in the sense that it
is based on successive application of the trapezoidal rule. However, through mathematical
manipulations, superior results are attained for less effort.
22.2.1 Richardson's Extrapolation
Recall that, in Sec. 10.3.3, we used iterative refinement to improve the solution of a set of
simultaneous linear equations. Error-correction techniques are also available to improve
the results of numerical integration on the basis of the integral estimates themselves. Gen-
erally called Richardson's extrapolation, these methods use two estimates of an integral to
compute a third. more accurate approximation.
The estimate and error associated with a multiple-application trapezoidal rule can be
represented generally as
where I = the exact value of the integral, I(h) = the approximation from an n-segment ap-
plication of the trapezoidal rule with step size h = (b - a)/n, and E(h) = the truncation
error. If we make two separate estimates using step sizes of hl and h2 and have exact val-
ues for the error,
Now recall that the error of the multiple-application trapezoidal rule can be represented ap-
proximately by Eq. (21.13) [with rz = (b - a)/h]:
h - a
? h 2 7 (22.2)
22.2 ROMBERG INTEGRATION 613
If it is assumed that j
" is constant regardless of step size, Eq. (22.2)can be used to deter-
mine that the ratio of the two errors will be
This calculation has the important effect of removing the term f from the computation. In
so doing, we have made it possible to utilize the information embodied by Eq. (22.2)with-
out prior knowledge of the function's second derivative. To do this, we rearrange Eq. (22.3)
to give
which can be substituted into Eq. (22.1):
which can be solved for
Thus, we have developed an estimate of the truncation error in terms of the integral esti-
mates and their step sizes. This estimate can then be substituted into
I = l(hz)+E(h2)
to yield an improved estimate of the integral:
It can be shown (Ralston and Rabinowitz, 1978) that the error of this estimate is 0(h4).
Thus, we have combined two trapezoidal rule estimates of 0(h2)to yield a new estimate
of O(h4).For the special case where the interval is halved (h2= h1/2),this equation
becomes
or, collecting terms,
EXAMPLE 22.1 Error Corrections of the Trapezoidal Rule
Problem Statement. In the previous chapter (Example 21.1 and Table 21.1), we used a
variety of numerical integration methods to evaluate the integral of f(x-) = 0.2 + 251--
200x2 + 675x3 - 900x4 +400x5 from a = 0 to h = 0.8. For example, single and
614 INTEGRATIONO
F EQUATIONS
/ multiple applications of the trapezoidal rule yielded the following results:
Segments h Integral E,, %
Use this information along with Eq. (22.5)to compute improved estimates of the integral.
Solution. The estimates for one and two segments can be combined to yield
The error of the improved integral is E, = 1.640533 - 1.367467 = 0.273067 ( 6 , =
16.6%),which is superior to the estimates upon which it was based.
In the same manner, the estimates for two and four segments can be combined to give
Equation (22.4)provides a way to combine two applications of the trapezoidal rule
with error 0(h2)to compute a third estimate with error 0(h4).This approach is a subset of
a more general method for combining integrals to obtain improved estimates. For in-
stance, in Example 22.1, we computed two improved integrals of 0(h4)on the basis of
three trapezoidal rule estimates. These two improved estimates can, in turn, be combined
to yield an even better value with 0(h6).For the special case where the original trape-
zoidal estimates are based on successive halving of the step size, the equation used for
0(h6)accuracy is
where I, and II are the more and less accurate estimates, respectively. Similarly, two 0(h6)
results can be combined to compute an integral that is O(hs)using
EXAMPLE 22.2 Higher-Order Error Correction of Integral Estimates
Problem Statement. In Example 22.1, we used Richardson's extrapolation to compute
two integral estimates of 0(h4).Utilize Eq. (22.6)to combine these estimates to compute
an integral with 0(h6).
22.2 ROMBERGINTEGRATION 615
Solution. The two integral estimates of O(h4)obtained in Example 22.1 were 1.367467
and 1.623467. These values can be substituted into Eq. (22.6)to yield
I which is the correct answer to the seven significant figures that are carried in this example.
2
2
.
2
.
2 The Romberg integration Algorithm
Notice that the coefficients in each of the extrapolation equations [Eqs. (22.5),(22.6),and
(22.7)]add up to 1. Thus, they represent weighting factors that, as accuracy increases,
place relatively greater weight on the superior integral estimate. These formulations can be
expressed in a general form that is well-suited for computer implementation:
where I,+,, k-1 and I,,k-1 = the more and less accurate integrals, respectively, and I,,J = the
improved integral. The index k signifies the level of the integration, where k = I corre-
sponds to the original trapezoidal rule estimates, k = 2 corresponds to 0(h4)),
k = 3 to
O(hb),
and so forth. The indexj is used to distinguish between the more ( B + 1) and the less
( j )accurate estimates. For example, for k = 2 andj = 1,Eq. (22.8)becomes
which is equivalent to Eq. (22.5).
The general form represented by Eq. (22.8)is attributed to Romberg, and its system-
atic application to evaluate integrals is known as Romberg inregration. Figure 22.3 is a
graphical depiction of the sequence of integral estimates generated using this approach.
Each matrix corresponds to a single iteration. The first column contains the trapezoidal rule
FIGURE 22.3
Graphical depiction of the
O(h2) O(h4)
sequence of integral estimates (4 0.172800 1 367467
generated using Rornberg 1 068800
~ntegration.
616 INTEGRATIONO
F EQUATIONS
evaluations that are designated Ij,~,
where j = 1 is for a single-segment application (step
size is b - a),j = 2 is for a two-segment application [step size is (b - a)/2], j = 3 is for
a four-segment application [step size is (b - a)/4], and so forth. The other columns of the
matrix are generated by systematically applying Eq. (22.8) to obtain successively better es-
timates of the integral.
For example, the first iteration (Fig. 22.3~)
involves computing the one- and two-
segment trapezoidal rule estimates and 12,1).Equation (22.8) is then used to compute
the element = 1.367467, which has an error of 0(h4).
Now, we must check to determine whether this result is adequate for our needs. As in
other approximate methods in this book, a termination, or stopping, criterion is required to
assess the accuracy of the results. One method that can be employed for the present pur-
poses is [Eq. (3.5)]
where E, = an estimate of the percent relative error. Thus, as was done previously in other
iterative processes, we compare the new estimate with a previous value. When the change
between the old and new values as represented by E, is below a prespecified error criterion
E,, the computation is terminated. For Fig. 22.3a, this evaluation indicates an 87.4 percent
change over the course of the first iteration.
The object of the second iteration (Fig. 22.3b) is to obtain the 0(h6)estimate-Il,s. To
do this, an additional trapezoidal rule estimate,13,~
= 1.4848, is determined. Then it is com-
bined with 12,1
using Eq. (22.8) to generate 12,~
= 1.623467.The result is, in turn, combined
FIGURE 22.4
Pseudocode for Romberg integration that uses the equal-size-segmentversion of the trapezoidal
rule from Fig. 22. 1 .
FUNCnON Rhomberg (a, b, maxit, es)
LOCAL 1(10,10)
n = 1
/?,I = TrapEq(n, a, b)
iter = 0
DO
iter = iter + 1
,= 2iter
/iter+l,l = TrapEq(n, a, b)
DO k = 2, iter + 1
j = 2 + iter - k
1.
~ , k
-
- (4k-I * $+,,k-l - $,k-l) / (4k-I - 1)
END DO
ea = ABS((ll,itcr+l - 11,iter)/ Il,iter+l) 100
i f (iter 2 maxit OR ea S es) EXIT
END DO
Rhomberg = /l,iter+l
END Rhomberg
22.3 GAUSS QUADRATURE 617
with 11,2to yield Ils = 1.640533. Equation (22.9) can be applied to determine that this
result represents a change of 22.6 percent when compared with the previous result 1 1 ~ 2 .
The third iteration (Fig. 22.3~)
continues the process in the same fashion. In this case,
a trapezoidal estimate is added to the first column, and then Eq. (22.8) is applied to com-
pute successively more accurate integrals along the lower diagonal. After only three itera-
tions, because we are evaluating a fifth-order polynomial, the result (11,4
= 1.640533) is
exact.
Romberg integration is more efficient than the trapezoidal rule and Simpson's rules
discussed in Chap. 21. For example, for determination of the integral as shown in Fig. 22.1,
Simpson's 1/3 rule would require a 256-segment application to yield an estimate of
1.640533. Finer approximations would not be possible because of round-off error. In con-
trast, Romberg integration yields an exact result (to seven significant figures) based on
combining one-, two-, four-, and eight-segment trapezoidal rules; that is, with only 15
function evaluations!
Figure 22.4 presents pseudocode for Romberg integration. By using loops, this algo-
rithm impleme~lts
the method in an efficient manner. Romberg integration is designed for
cases where the function to be integrated is known. This is because knowledge of the func-
tion permits the evaluations required for the initial implementations of the trapezoidal rule.
Tabulated data is rarely in the form needed to make the necessary successive halvings.
GAUSS QUADMTURE
In Chap. 21, we studied the group of numerical integration or quadrature formulas known
as the Newton-Cotes equations. A characteristic of these formulas (with the exception of
the special case of Sec. 21.3) was that the integral estimate was based on evenly spaced
function values. Consequently, the location of the base points used in these equations was
predetermined or fixed.
For example, as depicted in Fig. 22.5a, the trapezoidal rule is based on taking the area
under the straight line connecting the function values at the ends of the integration interval.
The formula that is used to compute this area is
where a and b = the limits of integration and b - a = the width of the integration inter-
val. Because the trapezoidal rule must pass through the end points, there are cases such as
Fig. 22.5a where the formula results in a large error.
Now, suppose that the constraint of fixed base points was removed and we were free
to evaluate the area under a straight line joining any two points on the curve. By position-
ing these points wisely, we could define a straight line that would balance the positive and
negative errors. Hence, as in Fig. 22.56, we would arrive at an improved estimate of the
integral.
Gauss quadrature is the name for one class of techniques to implement such a strat-
egy. The particular Gauss quadrature formulas described in this section are called Gauss-
Legendl-e formulas. Before describing the approach, we will show how numerical in-
tegration formulas such as the trapezoidal rule can be derived using the method of
INTEGRATION O
F EQUATIONS
FlGURE 22.5
(a)Graphical depiction of the
trapezoidal rule as the area
under the straight line ioining
fixed end points. (b)An
improved integral estimate ob-
tained by taking the area under
the straight line passing through
two intermediate points. By po-
sitioning these points wisely, the
ositive and negative errors are
Lalance, and an improved in-
tegral estimate results.
undetermined coefficients. This method will then be employed to develop the Gauss-
Legendre formulas.
22.3.1 Method of Undetermined Coefficients
In Chap. 21, we derived the trapezoidal rule by integrating a linear interpolating polynomial
and by geometrical reasoning. The method of undetermined coefficients offers a third ap-
proach that alsohas utility in deriving other integrationtechniques such as Gauss quadrature.
To illustrate the approach, Eq. (22.10) is expressed as
where the c's = constants. Now realize that the trapezoidal rule should yield exact results
when the function being integrated is a constant or a straight line. Two simple equations
that represent these cases are y = 1 and y = x. Both are illustrated in Fig. 22.6. Thus, the
following equalities should hold:
C O + C ~ = 1 dx
and
22.3 GAUSS QUADRATURE 6
19
FlGURE 22.6
Two integrals that should be evaluated exactly by the trapezoidal rule: (a)a constant and (b)a
straight line.
or, evaluating the integrals,
and
b - a b - a
-Co -+cl2=O
2
These are two equations with two unknowns that can be solved for
b - a
Co = C1 = --
2
which, when substitutedback into Eq. (22.1I), gives
b - a b - a
I = -f(a) + T f ( b )
2
which is equivalent to the trapezoidal rule.
620 INTEGRATIONOF EQUATIONS
22,3.2 Derivationof the Tvvo-Point Gauss-Legendre Formula
Just as was the case for the above derivation of the trapezoidal rule, the object of Gauss
quadrature is to determine the coefficients of an equation of the fonn
where the c's = the unknown coefficients. However, in contrast to the trapezoidal rule that
used fixed end points a and b, the function arguments xo and xl are not fixed at the end
points, but are unknowns (Fig. 22.7). Thus, we now have a total of four unknowns that
must be evaluated, and consequently, we require four conditions to determine them
exactly.
Just as for the trapezoidal rule, we can obtain two of these conditions by assuming that
Eq. (22.12)fits the integral of a constant and a linear function exactly. Then, to arrive at the
other two conditions, we merely extend this reasoning by assuming that it also fits the in-
tegral of a parabolic (y = 2)
and a cubic (y = x3)function. By doing this, we determine
all four unknowns and in the bargain derive a linear two-point integration formula that is
exact for cubics. The four equations to be solved are
cof(xo) +cl f(x1) = (22.13)
cof(xo) f cl f(x1) = (22.14)
FIGURE 22.7
Graphical depiction of the unknown variables xo and X I for integration by Gauss quadrature
22.3 GAUSS QUADRATURE 621
Equations (22.13) through (22.16) can be solved simultaneously for
which can be substituted into Eq. (22.12) to yield the two-point Gauss-Legendre formula
Thus, we arrive at the interesting result that the simple addition of the function values at
x = 1/& and -I/& yields an integral estimate that is third-order accurate.
Notice that the integrationlimits in Eqs. (22.13)through (22.16) are from -1to 1.This
was done to simplify the mathematics and to make the formulation as general as possible.
A simple change of variable can be used to translate other limits of integration into this
form. This is accomplished by assuming that a new variable xd is related to the original
variablex in a linear fashion, as in
X = a0 $. alxd (22.18)
If the lower limit, x = a, corresponds to x
d = -1, these values can be substituted into
Eq. (22.18) to yield
a = ao +al(-1) (22.19)
Similarly,the upper limit, x = b, corresponds to x
d = 1,to give
b = ag +al(l) (22.20)
Equations (22.19) and (22.20) can be solved simultaneouslyfor
and
b - a
a1 = -
2
which can be substituted into Eq. (22.18) to yield
This equation can be differentiated to give
h - a
dx = -
2
dxd
Equations (22.23) and (22.24) can be substituted for x and dx,respectively,in the equation
to be integrated. These substitutions effectively transform the integration interval without
22.3 GAUSS QUADRATURE 621
Equations (22.13)through (22.16)can be solved simultaneously for
which can be substituted into Eq. (22.12)to yield the two-point Gauss-Legendre formula
Thus, we arrive at the interesting result that the simple addition of the function values at
x = I /& and -1/& yields an integral estimate that is third-order accurate.
Notice that the integration limits in Eqs. (22.13)through (22.16)are from -1to 1.This
was done to simplify the mathematics and to make the formulation as general as possible.
A simple change of variable can be used to translate other limits of integration into this
form. This is accomplished by assuming that a new variable xd is related to the original
variable x in a linear fashion, as in
x = a0 +alxd (22.18)
If the lower limit, x = a, corresponds to xd = -1, these values can be substituted into
Eq. (22.18)to yield
a =ao +al(-1) (22.19)
Similarly, the upper limit. x = b, corresponds to xd = 1,to give
b = a o f a ~ ( l ) (22.20)
Equations (22.19)and (22.20)can be solved simultaneously for
and
b - a
a] = -
2
which can be substituted into Eq. (22.18)to yield
This equation can be differentiated to give
Equations (22.23)and (22.24)can be substituted for s and ds,respectively, in the equation
to be integrated. These substitutions effectively transform the integration interval without
622 INTEGRATIONO
F EQUATIONS
changing the value of the integral. The following example illustrates how this is done in
practice.
EXAMPLE 22.3 Two-Point Gauss-Legendre Formula
I Problem Statement. Use Eq. (22.17) to evaluate the integral of
I
between the limits x = 0 to 0.8. Recall that this was the same problem that we solved in
1 Chap. 21 using a variety of Newton-Cotes formulations. The exact value of the integral is
1 1.640533.
Solution. Before integrating the function, we must perform a change of variable so
; that the limits are from -1 to +1. To do this, we substitute a = 0 and b = 0.8 into
i Eq. (22.23) to yield
The derivative of this relationship is [Eq. (22.24)]
Both of these can be substituted into the original equation to yield
Therefore, the right-hand side is in the form that is suitable for evaluation using Gauss
quadrature. The transformed function can be evaluated at -l / f i to be equal to 0.516741
and at 1/& to be equal to 1.305837. Therefore, the integral according to Eq. (22.17) is
which represents a percent relative error of -11.1 percent. This result is comparable in
magnitude to a four-segment application of the trapezoidal rule (Table 21.1) or a single ap-
plication of Simpson's 113 and 318 rules (Examples 21.4 and 21.6). This latter result is to
be expected because Simpson's rules are also third-order accurate. However, because of
the clever choice of base points, Gauss quadrature attains this accuracy on the basis of only
two function evaluations.
2
2
.
3
.
3 Higher-Point Formulas
Beyond the two-point formula described in the previous section, higher-point versions can
be developed in the general form
22.3 GAUSS QUADRATURE 623
TABLE 22.1 Weighting factors c and function arguments x used in Gauss-Legendre
formulas.
u
-
Weighting Funcgon Truncatisn
Points Factors Arguments Error
2 co = 1 .OOOOOOO xo = -0.577350269 =/141(5)
c
i = 1 0
0
0
0
0
0
0 X I = 0.577350269
3 co = 0.5555556 xo = -0.774596669 =
f
i
6
l
l
(
)
c
l = 0.8888889 XI= 0.0
q = 0.5555556 x2 = 0.774596669
4 co = 03
4
7
8
5
4
8 xo = -0.86
1 1
3
6
312 ~f 181[()
cj = 0.6521
4
5
2 XI = -03
3
9
9
81
0
4
4
c
:
! = 0.652
1
4
5
2 X>= 0339981044
cg = 0.3478548 X
, = 0
.
8
6
1
1
3
6
312
co = 0
.
2
3
6
9
2
6
9 xo = -0.906
1 7
9
8
4
6 =
f
l
'
O
l
[
{
)
c
i = 0.4786287 x
i = -0.5384693
1
0
c
:
,= 0.5688889 x2 = 0.0
cg = 0.4786287 x
3 = 0.538469310
~4= 0.2369269 x
4
= 0.906179846
co= 0.171
3
2
4
5 xo = -0.9324695
1
4 =f112)(~)
cl = 0
.
3
6
0
7
6
1
6 X I = -0.661
2
0
9
3
8
6
c2 = 0.4679
1 3
9 x
, = -
0
.
2
3
8
6
1
9
18
6
cg = 0.4679
1 3
9 x3 = 0.238619186
cq = 0
.
3
6
0
7
6
1
6 x4 = 0
.
6
6
1
2
0
9
3
8
6
c
g = O 1
7
1
3
2
4
5 x5 = 0.9324695
1
4
where n = the number of points. Values for c's andx's for up to and including the six-point
formula are summarized in Table 22.1.
EXAMPLE 22.4 Three-Point Gauss-Legendre Formula
i Problem Statement. Use the three-point formula from Table 22.1 to estimate the inte-
i
I gral for the same function as in Example 22.3.
! Solution. According to Table 22.1, the three-point formula is
1 I = 0,5555556f(-0.7745967) +0.8888889f(0) +0.5555556f(0.7745967)
I
which is equal to
I = 0.2813013 +0.8732444 +0.4859876 = 1.640533
"hich is exact.
i
Because Gauss quadrature requires function evaluations at nonuniformly spaced
points within the integration interval, it is not appropriate for cases where the function is
unknown. Thus, it is not suited for engineering problems that deal with tabulated data.
However, where the function is known, its efficiency can be a decided advantage. This is
particularly true when numerous integral evaluations must be performed.
624 INTEGRATIONO
F EQUATIONS
EXAMPLE 22.5 Applying Gauss Quadrature to the Falling Parachutist Problem
I
Problem Statement. In Example 21.3, we used the multiple-application trapezoidal
i where g = 9.8, c = 12.5,and m = 68.1.The exact value of the integral was determinedby
calculus to be 289.4351.Recall that the best estimate obtained using a 500-segment trape-
I zoidal rule was 289.4348 with an 2 1.15 x lo-' percent. Repeat this computation
1 using Gauss quadrature.
/ Solution. After modifying the function, the following results are obtained:
Two-point estimate = 290.0145
Three-point estimate = 289.4393
Four-pointestimate = 289.4352
Five-point estimate = 289.4351
Six-point estimate = 289.4351
1 Thus, the five- and six-point estimates yield results that are exact to seven significant
t
' figures.
i
22.3.4 Error Analysis For Gauss Quadrature
The error for the Gauss-Legendreformulas is specified generallyby (Carnahanet al., 1969)
where n = the number of points minus one andf (2n+2)(t)
= the (2n +2)th derivative of
the function after the change of variable with 6located somewhere on the interval from -1
to 1.Comparison of Eq. (22.26) with Table 21.2 indicates the superiority of Gauss quadra-
ture to Newton-Cotes formulas, provided the higher-order derivatives do not increase sub-
stantially with increasing n. Problem 22.8 at the end of this chapter illustrates a case where
the Gauss-Legendre formulas perform poorly. In these situations, the multiple-application
Simpson's rule or Romberg integration would be preferable. However, for many functions
confronted in engineering practice, Gauss quadratureprovides an efficientmeans for eval-
uating integrals.
2
2
.
4 IMPROPER INTEGRALS - - -
To this point, we have dealt exclusively with integrals having finite limits and bounded in-
tegrands. Although these types are commonplace in engineering, there will be times when
improper integrals must be evaluated. In this section we will focus on one type of improper
integral-that is, one with a lower limit of -m or an upper limit of +m.
Suchintegralsusually can be evaluatedby making a change of variable that transforms
the infinite range to one that is finite. The following identity serves this purpose and works
22.4 I
M
P
R
O
P
E
R INTEGRALS 625
for any functionthat decreasestoward zeroat leastas fastas1/.x2asx approachesinfinity:
for ab > 0. Therefore, it can be used only when a is positive and b is a,or when a is -00
and b is negative. For cases where the limits are from -cm to a positive value or from a
negative value to cm,the integral can be implemented in two steps. For example,
(22.28)
where -A is chosen as a sufficientlylarge negative value so that the function has begun to
approach zero asymptotically at least as fast as 1/x2.After the integral has been divided
into two parts, the first can be evaluated with Eq. (22.27) and the second with a Newton-
Cotes closed formula such as Simpson's 1/3 rule.
One problem with using Eq. (22.27) to evaluate an integral is that the transformed
function will be singular at one of the limits. The open integration formulas can be used to
circumvent this dilemma as they allow evaluation of the integral withoutemployingdata at
the end points of the integration interval. To allow the maximum flexibility, a multiple-
application version of one of the open formulas from Table 21.4 is required.
Multiple-applicationversions of the open formulas can be concocted by using closed
formulasfortheinteriorsegmentsandopen formrllasfortheends.Forexample,themultiple-
segment trapezoidal rule and the midpoint rule can be combined to give
In addition, semiopenformulas can be developed for cases where one or the other end
of the interval is closed. For example, a formula that is open at the lower limit and closed
at the upper limit is given as
Although these relationships can be used, a preferred formula is (Press et at., 1986)
which is called the extended midpointrule. Notice that this formula is based on limits of in-
tegration that are h/2 after and before the first and last data points (Fig. 22.8).
FIGURE 22.8
Placement of data points relative to integration limits for the extended midpoint rule.
INTEGRATIONO
F EQUATIONS
EXAMPLE 22.6 Evaluation of an Improper Integral
: Problem Statement. The cumulative normal distribution is an important formula in
statistics (see Fig. 22.9):
FIGURE 22.9
(a)The normal d~strlbutlon,
(b)the transformed abscissa ~nterms of the standardized normal devi-
ate, and (c)the cumulative normal distr~butionThe shaded area in (a)and the po~nt
~n(c)repre
sent the probab~llty
that a ra~dom
event will be less than the mean plus one standard dev~atron
22.4 IMPROPERINTEGRALS 621
where x = (y - E;)/sy
is called the normalized standard deviate. It represents a change of
variable to scale the normal distribution so that it is centered on zero and the distance along
the abscissa is measured in multiples of the standard deviation (Fig. 22.9b).
Equation (E22.6.1) represents the probability that an event will be less than x. For ex-
ample, if x = 1,Eq. (E22.6.1) can be used to determine that the probability that an event
will occur that is less than one standard deviation above the mean is N(l) = 0.8413. In
other words,if 100events occur,approximately84will be less than the mean plus one stan-
dard deviation. Because Eq. (E22.6.1) cannot be evaluated in a simple functional form, it
is solved numerically and listed in statistical tables. Use Eq. (22.28) in conjunction with
Simpson's 1/3 rule and the extended midpoint rule to determine N(l) numerically.
Solution. Equation (E22.6.1) can be re-expressed in terms of Eq. (22.28) as
The first integral can be evaluated by applying Eq. (22.27) to give
Then the extended midpoint rule with h = 1/8 can be employed to estimate
Simpson's 1/3 rule with h = 0.5 can be used to estimate the second integral as
Therefore, the final result can be computed as
which represents an error of E* = 0.046 percent.
The foregoing computation can be improved in a number of ways. First, higher-order
formulas could be used. For example, a Romberg integration could be employed. Second,
more points could be used. Press et al. (1986) explore both options in depth.
Aside from infinite limits, there are other ways in which an integral can be improper.
Common examples include cases where the integral is singular at either the limits or at a
point within the integral. Press et al. (1986) provide a nice discussion of ways to handle
these situations.
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf

More Related Content

Similar to 6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf

IMAGE REGISTRATION USING ADVANCED TOPOLOGY PRESERVING RELAXATION LABELING
IMAGE REGISTRATION USING ADVANCED TOPOLOGY PRESERVING RELAXATION LABELING IMAGE REGISTRATION USING ADVANCED TOPOLOGY PRESERVING RELAXATION LABELING
IMAGE REGISTRATION USING ADVANCED TOPOLOGY PRESERVING RELAXATION LABELING cscpconf
 
IMAGE REGISTRATION USING ADVANCED TOPOLOGY PRESERVING RELAXATION LABELING
IMAGE REGISTRATION USING ADVANCED TOPOLOGY PRESERVING RELAXATION LABELING IMAGE REGISTRATION USING ADVANCED TOPOLOGY PRESERVING RELAXATION LABELING
IMAGE REGISTRATION USING ADVANCED TOPOLOGY PRESERVING RELAXATION LABELING csandit
 
A COMPARATIVE STUDY ON DISTANCE MEASURING APPROACHES FOR CLUSTERING
A COMPARATIVE STUDY ON DISTANCE MEASURING APPROACHES FOR CLUSTERINGA COMPARATIVE STUDY ON DISTANCE MEASURING APPROACHES FOR CLUSTERING
A COMPARATIVE STUDY ON DISTANCE MEASURING APPROACHES FOR CLUSTERINGIJORCS
 
Approximate Thin Plate Spline Mappings
Approximate Thin Plate Spline MappingsApproximate Thin Plate Spline Mappings
Approximate Thin Plate Spline MappingsArchzilon Eshun-Davies
 
Quantum algorithm for solving linear systems of equations
 Quantum algorithm for solving linear systems of equations Quantum algorithm for solving linear systems of equations
Quantum algorithm for solving linear systems of equationsXequeMateShannon
 
cis98010
cis98010cis98010
cis98010perfj
 
Integration techniques for two dimensional domains
Integration techniques for two dimensional domainsIntegration techniques for two dimensional domains
Integration techniques for two dimensional domainseSAT Publishing House
 
83662164 case-study-1
83662164 case-study-183662164 case-study-1
83662164 case-study-1homeworkping3
 
A COUNTEREXAMPLE TO THE FORWARD RECURSION IN FUZZY CRITICAL PATH ANALYSIS UND...
A COUNTEREXAMPLE TO THE FORWARD RECURSION IN FUZZY CRITICAL PATH ANALYSIS UND...A COUNTEREXAMPLE TO THE FORWARD RECURSION IN FUZZY CRITICAL PATH ANALYSIS UND...
A COUNTEREXAMPLE TO THE FORWARD RECURSION IN FUZZY CRITICAL PATH ANALYSIS UND...Wireilla
 
A Counterexample to the Forward Recursion in Fuzzy Critical Path Analysis Und...
A Counterexample to the Forward Recursion in Fuzzy Critical Path Analysis Und...A Counterexample to the Forward Recursion in Fuzzy Critical Path Analysis Und...
A Counterexample to the Forward Recursion in Fuzzy Critical Path Analysis Und...ijfls
 
Numerical disperison analysis of sympletic and adi scheme
Numerical disperison analysis of sympletic and adi schemeNumerical disperison analysis of sympletic and adi scheme
Numerical disperison analysis of sympletic and adi schemexingangahu
 
OPTIMAL GLOBAL THRESHOLD ESTIMATION USING STATISTICAL CHANGE-POINT DETECTION
OPTIMAL GLOBAL THRESHOLD ESTIMATION USING STATISTICAL CHANGE-POINT DETECTIONOPTIMAL GLOBAL THRESHOLD ESTIMATION USING STATISTICAL CHANGE-POINT DETECTION
OPTIMAL GLOBAL THRESHOLD ESTIMATION USING STATISTICAL CHANGE-POINT DETECTIONsipij
 
A NEW STUDY OF TRAPEZOIDAL, SIMPSON’S1/3 AND SIMPSON’S 3/8 RULES OF NUMERICAL...
A NEW STUDY OF TRAPEZOIDAL, SIMPSON’S1/3 AND SIMPSON’S 3/8 RULES OF NUMERICAL...A NEW STUDY OF TRAPEZOIDAL, SIMPSON’S1/3 AND SIMPSON’S 3/8 RULES OF NUMERICAL...
A NEW STUDY OF TRAPEZOIDAL, SIMPSON’S1/3 AND SIMPSON’S 3/8 RULES OF NUMERICAL...mathsjournal
 
Some Engg. Applications of Matrices and Partial Derivatives
Some Engg. Applications of Matrices and Partial DerivativesSome Engg. Applications of Matrices and Partial Derivatives
Some Engg. Applications of Matrices and Partial DerivativesSanjaySingh011996
 

Similar to 6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf (20)

Lar calc10 ch04_sec4
Lar calc10 ch04_sec4Lar calc10 ch04_sec4
Lar calc10 ch04_sec4
 
IMAGE REGISTRATION USING ADVANCED TOPOLOGY PRESERVING RELAXATION LABELING
IMAGE REGISTRATION USING ADVANCED TOPOLOGY PRESERVING RELAXATION LABELING IMAGE REGISTRATION USING ADVANCED TOPOLOGY PRESERVING RELAXATION LABELING
IMAGE REGISTRATION USING ADVANCED TOPOLOGY PRESERVING RELAXATION LABELING
 
IMAGE REGISTRATION USING ADVANCED TOPOLOGY PRESERVING RELAXATION LABELING
IMAGE REGISTRATION USING ADVANCED TOPOLOGY PRESERVING RELAXATION LABELING IMAGE REGISTRATION USING ADVANCED TOPOLOGY PRESERVING RELAXATION LABELING
IMAGE REGISTRATION USING ADVANCED TOPOLOGY PRESERVING RELAXATION LABELING
 
A COMPARATIVE STUDY ON DISTANCE MEASURING APPROACHES FOR CLUSTERING
A COMPARATIVE STUDY ON DISTANCE MEASURING APPROACHES FOR CLUSTERINGA COMPARATIVE STUDY ON DISTANCE MEASURING APPROACHES FOR CLUSTERING
A COMPARATIVE STUDY ON DISTANCE MEASURING APPROACHES FOR CLUSTERING
 
Approximate Thin Plate Spline Mappings
Approximate Thin Plate Spline MappingsApproximate Thin Plate Spline Mappings
Approximate Thin Plate Spline Mappings
 
Quantum algorithm for solving linear systems of equations
 Quantum algorithm for solving linear systems of equations Quantum algorithm for solving linear systems of equations
Quantum algorithm for solving linear systems of equations
 
cis98010
cis98010cis98010
cis98010
 
Integration techniques for two dimensional domains
Integration techniques for two dimensional domainsIntegration techniques for two dimensional domains
Integration techniques for two dimensional domains
 
RS
RSRS
RS
 
Final document
Final documentFinal document
Final document
 
83662164 case-study-1
83662164 case-study-183662164 case-study-1
83662164 case-study-1
 
A COUNTEREXAMPLE TO THE FORWARD RECURSION IN FUZZY CRITICAL PATH ANALYSIS UND...
A COUNTEREXAMPLE TO THE FORWARD RECURSION IN FUZZY CRITICAL PATH ANALYSIS UND...A COUNTEREXAMPLE TO THE FORWARD RECURSION IN FUZZY CRITICAL PATH ANALYSIS UND...
A COUNTEREXAMPLE TO THE FORWARD RECURSION IN FUZZY CRITICAL PATH ANALYSIS UND...
 
A Counterexample to the Forward Recursion in Fuzzy Critical Path Analysis Und...
A Counterexample to the Forward Recursion in Fuzzy Critical Path Analysis Und...A Counterexample to the Forward Recursion in Fuzzy Critical Path Analysis Und...
A Counterexample to the Forward Recursion in Fuzzy Critical Path Analysis Und...
 
Numerical disperison analysis of sympletic and adi scheme
Numerical disperison analysis of sympletic and adi schemeNumerical disperison analysis of sympletic and adi scheme
Numerical disperison analysis of sympletic and adi scheme
 
OPTIMAL GLOBAL THRESHOLD ESTIMATION USING STATISTICAL CHANGE-POINT DETECTION
OPTIMAL GLOBAL THRESHOLD ESTIMATION USING STATISTICAL CHANGE-POINT DETECTIONOPTIMAL GLOBAL THRESHOLD ESTIMATION USING STATISTICAL CHANGE-POINT DETECTION
OPTIMAL GLOBAL THRESHOLD ESTIMATION USING STATISTICAL CHANGE-POINT DETECTION
 
LRIEEE-MTT
LRIEEE-MTTLRIEEE-MTT
LRIEEE-MTT
 
A NEW STUDY OF TRAPEZOIDAL, SIMPSON’S1/3 AND SIMPSON’S 3/8 RULES OF NUMERICAL...
A NEW STUDY OF TRAPEZOIDAL, SIMPSON’S1/3 AND SIMPSON’S 3/8 RULES OF NUMERICAL...A NEW STUDY OF TRAPEZOIDAL, SIMPSON’S1/3 AND SIMPSON’S 3/8 RULES OF NUMERICAL...
A NEW STUDY OF TRAPEZOIDAL, SIMPSON’S1/3 AND SIMPSON’S 3/8 RULES OF NUMERICAL...
 
Some Engg. Applications of Matrices and Partial Derivatives
Some Engg. Applications of Matrices and Partial DerivativesSome Engg. Applications of Matrices and Partial Derivatives
Some Engg. Applications of Matrices and Partial Derivatives
 
deepak real.ppt
deepak real.pptdeepak real.ppt
deepak real.ppt
 
BNL_Research_Report
BNL_Research_ReportBNL_Research_Report
BNL_Research_Report
 

Recently uploaded

HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 

Recently uploaded (20)

HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 

6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf

  • 2. NUMER Calculusis themathematicsof change.Becauseengineersmust continuouslydeal with sys- tems andprocessesthatchange,calculusis anessentialtool of ourprofession.Standingatthe heart of calculusarethe related mathematicalconceptsof differentiationand integration. According to the dictionary definition, to dlfferentiate means "to mark off by differ- ences;distinguish;. . .toperceivethedifferenceinorbetween." Mathematically,thederiva- tive,which servesasthefundamentalvehiclefordifferentiation,representstherateof change of a dependent variable with respect to an independentvariable.As depicted in Fig. PT6.1, the mathematicaldefinitionof the derivativebegins with a differenceapproximation: where y and j(x) are alternative representatives for the dependent variable and x is the independent variable. If Ax is allowed to approach zero, as occurs in moving from Fig. PT6.la to c, the difference becomes a derivative d y - = lim f(xr + Ax) - f(xi> dx AX-o AX FlGURE PT6.1 The graphical definition of a derivative: as Ax approaches zero in going from (a]to (c],the differenceapproximation becomes a derivative.
  • 3. 568 NUMERICAL DIFFERENTIATIONAND INTEGRATION FlGURE PT6.2 Graphical representation of the integral of f(x between the limits x = a to b. The integral is equivalent to the area under the curve. where dyldx [which can also be designated as y' orf '(xi)] is the first derivative of y with re- spect to x evaluated at xi. As seen in the visual depiction of Fig. PT6.lc, the derivative is the slope of the tangent to the curve at xi. The inverse process to differentiation in calculus is integration. According to the dic- tionary definition, to integrate means "to bring together, as parts, into a whole; to unite; to indicate the total amount . . . ." Mathematically, integration is represented by which stands for the integral of the functionf(x) with respect to the independent variable x, evaluated between the limits x = a to x = b. The functionf(x) in Eq. (PT6.2)is referred to as the integrand. As suggested bythedictionarydefinition,the"meaning" of Eq.(PT6.2)isthe totalvalue, orsummation,off (x)dx over therangex = a to b.In fact,the symbol is actually a stylized capitalSthat is intended to signify the close connection between integration and summation. Figure PT6.2 represents a graphical manifestation of the concept. For functions lying above the x axis, the integral expressed by Eq. (PT6.2)corresponds to the area under the curve off(x) between x = a and b.' As outlined above, the "marking off or discrimination" of differentiation and the "bringing together" of integration are closely linked processes that are, in fact, inversely 'It should be noted that the process represented by Eq. (PT6.2) and Fig. PT6.2 is called definite integration.There is another type called indefinite integration in which the limits a and b are unspecified. As will be discussed in Part Seven, indefinite integration deals with determining a function whose derivative is given.
  • 4. PT6.1 MOTIVATION 569 FIGURE PT6.3 The contrast between (a)differ- entiation and (b)integration. related (Fig. PT6.3).For example, if we are given a function y(t) that specifies an object's position as a function of time, differentiationprovides a means to determine its velocity, as in (Fig. PT6.3a). Conversely,if we are provided with velocity as a function of time, integration can be used to determine its position (Fig. PT6.3b), Thus, we can make the general claim that the evaluation of the integral is equivalent to solving the differential equation for y(b)given the initial condition y(a) = 0. Becauseof this close relationship,we have opted to devote this part of the book to both processes. Among other things, this will provide the opportunity to highlight their similar- ities and differences from a numerical perspective. In addition, our discussion will have relevance to the next parts of the book, where we will cover differential equations.
  • 5. NUMERICAL DIFFERENTIATIONAND INTEGRATION PT6.1.1 Noncornputer Methods For Differentiation and Infegratisn The function to be differentiatedor integrated will typicallybe in one of the following three forms: 1. A simple continuous function such as a polynomial, an exponential, or a trigonometric function. 2. A complicated continuous function that is difficult or impossible to differentiate or in- tegrate directly. 3. A tabulated function where values of x andf(x) are given at a number of discrete points, as is often the case with experimental or field data. In the first case, the derivative or integral of a simple function may be evaluated ana- lytically using calculus. For the second case, analytical solutions are often impractical, and sometimes impossible, to obtain. In these instances, as well as in the third case of discrete data, approximate methods must be employed. A noncomputer method for determining derivatives from data is called equal-area graphical dzfferentiation.In this method, the (x,y) data are tabulated and, for each interval, a simple divided difference AylAx is employed to estimate the slope. Then these values are plotted as a stepped curve versus x (Fig. PT6.4). Next, a smooth curve is drawn that at- tempts to approximatethe area under the stepped curve. That is, it is drawn so that visually, the positive and negative areas are balanced.The rates at given values of x can then be read from the curve. In the same spirit, visually oriented approaches were employed to integrate tabulated data and complicated functions in the precomputer era. A simple intuitive approach is to plot the function on a grid (Fig. PT6.5) and count the number of boxes that approximate the area. This number multiplied by the area of each box provides a rough estimate of the total FIGURE PT6.4 Equal-area differentiation. (a)Centered finite divided differences are used to estimate the derivative for each interval between the data points. (b)The derivative estimates are plotted as a bar graph. A smooth curve is superimposed on this plot to a the area under the Ear graph. This is accomplished by drawing the curve so that equal positive and negative areas are balanced. (c)Values of dyldx can then be read off the smooth curve.
  • 6. PT6.1 MOTIVATION 571 FIGURE PT6.5 The use of a grid to approxi- mate an integral. FlGURE PT6.6 The use of rectangles, or strips, to approximate the integral. area under the curve. This estimate can be refined, at the expense of additional effort, by using a finer grid. Another commonsense approach is to divide the area into vertical segments, or strips, with a height equal to the function value at the midpoint of each strip (Fig. PT6.6). The area of the rectangles can then be calculated and summed to estimate the total area. In this
  • 7. 572 NUMERICALDIFFERENTIATION AND INTEGRATION approach, it is assumed that the value at the midpoint provides a valid approximation of the average height of the function for each strip. As with the grid method, refined estimates are possible by using more (and thinner) strips to approximate the integral. Although such simple approaches have utility for quick estimates, alternative numeri- cal techniques are available for the same purpose. Not surprisingly, the simplest of these methods is similar in spirit to the noncomputer techniques. For differentiation, the most fundamental numerical techniques use finite divided dif- ferences to estimate derivatives. For data with error, an alternative approach is to fit a smooth curve to the data with a technique such as least-squares regression and then differ- entiate this curve to obtain derivative estimates. In a similar spirit, numerical integration or quadrature methods are available to obtain integrals. These methods, which are actually easier to implement than the grid approach, are similar in spirit to the strip method. That is, function heights are multiplied by strip widths and summed to estimate the integral. However, through clever choices of weighting factors, the resulting estimate can be made more accurate than that from the simple "strip method." As in the simple strip method, numerical integration and differentiation techniques uti- lize data at discrete points. Because tabulated information is already in such a form, it is naturally compatible with many of the numerical approaches. Although continuous func- tions are not originally in discrete form, it is usually a simple proposition to use the given equation to generate a table of values. As depicted in Fig. PT6.7, this table can then be eval- uated with a numerical method. PT6.1.2 Numerical Differentiation and Integration in Engineering The differentiation and integration of a function has so many engineering applications that you were required to take differential and integral calculus in your first year at college. Many specific examples of such applications could be given in all fields of engineering. Differentiation is commonplace in engineering because so much of our work involves characterizing the changes of variables in both time and space. In fact, many of the laws and other generalizations that figure so prominently in our work are based on the pre- dictable ways in which change manifests itself in the physical world. A prime example is Newton's second law, which is not couched in terms of the position of an object but rather in its change of position with respect to time. Aside from such temporal examples, numerous laws governing the spatial behavior of variables are expressed in terms of derivatives. Among the most common of these are those laws involving potentials or gradients. For example, Fourier's law of heat conduction quantifies the observation that heat flows from regions of high to low temperature. For the one-dimensional case, this can be expressed mathematically as dT Heat flux = -k' - dx Thus, the derivative provides a measure of the intensity of the temperature change, or gra- dient, that drives the transfer of heat. Similar laws provide workable models in many other areas of engineering, including the modeling of fluid dynamics, mass transfer, chemical re- action kinetics, and electromagnetic flux. The ability to accurately estimate derivatives is an important facet of our capability to work effectively in these areas.
  • 8. PT6.1 MOTIVATION 573 FlGURE BT6.7 Application of a nurner~cal inte- gration method: (a)A compli- cated, cont~nuous function. (b)Table of discrete values of fix) generated from the function. [c)Use of a numerical method (the strip method here)to esti- mate the integral on the basis of the discrete points. For a tabu- lated function, the data is al- ready in tabular form (b);there- fore, step (a)1s unnecessary. Just as accurate estimates of derivatives are important in engineering, the calculation of integrals is equally valuable. A number of examples relate directly to the idea of the in- tegral as the area under a curve. Figure PT6.8 depicts a few cases where integration is used for this purpose. Other common applications relate to the analogy between integration and summation. For example, a common application is to determine the mean of continuous functions. In Part Five, you were introduced to the concept of the mean of n discrete data points [recall Eq. (PT6.1)]: 2 Yi / = I Mean = - n where y; are individual measurements. The determination of the mean of discrete points is depicted in Fig. PT6.9a.
  • 9. 574 NUMERICAL DIFFERENTIATION AND INTEGRATION FIGURE PT6.8 Examples of how integration is used to evaluate areas in engineering applications. (a]A sur- veyor might need to know the area of a field bounded by a meandering stream and two roads [b]A water-resourceengineer might need to know the cross-sectional area of a river. (c)A struc- tural engineer might need to determine the net force due to a nonuniform wind blowing against the side of a skyscraper. FlGURE BT6.9 An illustration of the mean for (a)discrete and (b)continuous data
  • 10. PT6.1 MOTIVATION 575 In contrast, supposethat y is a continuous function of an independent variable x, as de- picted in Fig. PT6.9b. For this case, there are an infinite number of values between a and b. Just as Eq. (PT6.3) can be applied to determine the mean of the discrete readings, you might also be interested in computing the mean or average of the continuous function y =f(x) for the interval from a to 6. Integration is used for this purpose, as specified by the formula l b f ( x )dx Mean = (PT6.4) b - a This formula has hundreds of engineering applications. For example, it is used to calculate the center of gravity of irregular objects in mechanical and civil engineering and to deter- mine the root-mean-square current in electrical engineering. Integrals are also employed by engineers to evaluate the total amount or quantity of a given physical variable. The integral may be evaluated over a line, an area, or a volume. For example, the total mass of chemical contained in a reactor is given as the product of the concentration of chemical and the reactor volume, or Mass = concentration x volume where concentration has units of mass per volume. However, suppose that concentration varies from location to location within the reactor. In this case, it is necessary to sum the products of local concentrations ci and corresponding elemental volumes AVi: n Mass = ci AVi 1=1 where n is the number of discrete volumes. For the continuous case, where c(x, y, z) is a known function and x, y, and z are independent variables designating position in Cartesian coordinates, integration can be used for the same purpose: Mass = c(x,y , z ) d x d y dz which is referred to as a volume integral. Notice the strong analogy between summation and integration. Similar examples could be given in other fields of engineering. For example, the total rate of energy transfer across a plane where the flux (in calories per square centimeter per second) is a function of position is given by which is referred to as an areal integral,where A = area.
  • 11. 576 NUMERICALDIFFERENTIATION AND INTEGRATION Similarly,for the one-dimensional case, the total mass of a variable-density rod with constant cross-sectionalarea is given by where m = total weight (kg),L = length of the rod (m), p(x) = known density (kg/m3)as a function of lengthx (m), and A = cross-sectional area of the rod (m2). Finally, integrals are used to evaluate differential or rate equations. Suppose the ve- locity of a particle is a known continuous function of time v(t), The total distance y traveled by this particle over a time t is given by (Fig. PT6.3b) (PT6.5) These are just a few of the applications of differentiation and integration that you might face regularly in the pursuit of your profession.When the functions to be analyzed are sim- ple, you will normally choose to evaluate them analytically. For example, in the falling parachutist problem, we determined the solution for velocity as a function of time [Eq. (1.10)]. This relationship could be substituted into Eq. (PT6.5), which could then be integratedeasily to determinehow far theparachutist fell over a timeperiod t. For this case, the integral is simple to evaluate. However, it is difficult or impossible when the function is complicated,as is typically the case in more realistic examples. In addition,the underly- ing function is often unknown and defined only by measurement at discrete points. For both these cases,you must have the ability to obtain approximatevalues for derivativesand integralsusing numerical techniques. Several such techniques will be discussed in this part of the book. BT6.2 MATHEMATICAL BACKGROUND In high school or during your first year of college, you were introduced to differential and integral calculus. There you learned techniques to obtain analytical or exact derivatives and integrals. When we differentiate a function analytically,we generate a second function that can be used to compute the derivative for different values of the independent variable. General rules are available for this purpose. For example, in the case of the monomial the following simple rule applies (n # 0): which is the expression of the more general rule for
  • 12. PT6.2 MATHEMATICALBACKGROUND 597 where u = a function of x. For this equation, the derivative is computed via Two other useful formulas apply to the products and quotients of functions. For example, if the product of two functions of x(u and v) is represented as y = u v, then the derivative can be computed as For the division,y = ulv,the derivative can be computed as Other useful formulas are summarized in Table PT6.1. Similar formulas are available for definite integration, which deals with determining an integral between specified limits, as in According to thefundamental theorem of integral calculus, Eq. (PT6.6) is evaluated as where F(x) = the integraloff(x)-that is, any functionsuch that F'(x) =f(x). The nomen- clature on the right-hand side stands for TABLE F"T6.1 Some commonly used derivatives. d - sin x = cos x d -cot x = -csc2 x dx dx d -cos x = -sin x d -sec x = sec x tan x dx dx d -tan x = sec2 x dx d -csc x = -csc x cot x dx d 1 - logo x = - - dx x l n a
  • 13. 578 NUMERICAL DIFFERENTIATIONAND INTEGRATION An example of a definite integral is ~ 0 . 8 For this case, the function is a simple polynomial that can be integrated analytically by evaluating each term according to the rule b xn dx = - (PT6.9) where n cannot equal -1. Applying this rule to each term in Eq. (PT6.8) yields which can be evaluated according to Eq. (PT6.7)as I = 1.6405333.This value is equal to the area under the original polynomial [Eq. (PT6.8)] between x = 0 and 0.8. The foregoing integrationdepends on knowledge of the rule expressed by Eq. (PT6.9). Other functions follow different rules. These "rules" are all merely instances of antidiffer- entiation, that is, finding F(x) so that Ff(x)=f(x). Consequently,analytical integration de- pends on prior knowledge of the answer. Such knowledge is acquired by training and TABLE PT6.2 Some simple integrals that are used in Part Six. The a and b in this table are constants and should not be confused with the limits of integration discussed in the text. J u d v = u v - Jv d u 1 Icos [ax + b) dx= - sin (OX + b)+ C dx 1 6 6 I , , = a ton-' yx + C
  • 14. PT6.3 ORIENTATION 579 experience. Many of the rules are summarized in handbooks and in tables of integrals. We list some commonly encountered integrals in Table PT6.2. However, many functions of practical importance are too complicated to be contained in such tables. One reason why the techniques in the present part of the book are so valuable is that they provide a means to evaluate relationships such as Eq. (PT6.8) without knowledge of the rules. PT6.3 ORIENTATION Before proceeding to the numerical methods for integration, some further orientation might be helpful. The following is intended as an overview of the material discussed in Part Six. In addition, we have formulated some objectives to help focus your efforts when studying the material. PT6.3.1 Scope and Preview Figure PT6.10 provides an overview of Part Six. Chapter 21 is devoted to the most com- mon approaches for numerical integration-the Newton-Cotes ,formulas. These relation- ships are based on replacing a complicated function or tabulated data with a simple poly- nomial that is easy to integrate. Three of the most widely used Newton-Cotes formulas are discussed in detail: the trapezoidal rule, Simpson's 1/3 rule, and Simpson's 318 rule. All these formulas are designed for cases where the data to be integrated is evenly spaced. In addition, we also include a discussion of numerical integration of unequally spaced data. This is a very important topic because many real-world applications deal with data that is in this form. All the above material relates to closed integration, where the function values at the ends of the limits of integration are known. At the end of Chap. 21, we present open inte- grationformulas, where the integration limits extend beyond the range of the known data. Although they are not commonly used for definite integration, open integration formulas are presented here because they are utilized extensively in the solution of ordinary differ- ential equations in Part Seven. The formulations covered in Chap. 21 can be employed to analyze both tabulated data and equations. Chapter 22 deals with two techniques that are expressly designed to inte- grate equations and functions: Romherg integration and Gauss quad]-ature.Computer al- gorithms are provided for both of these methods. In addition, methods for evaluating im- proper integrals are discussed. In Chap.23, we present additional information on numerical di'erentiation to supple- ment the introductory material from Chap. 4. Topics include high-accuracy finite-difference formulas, Richardson's extrapolation, and the differentiation of unequally spaced data. The effect of errors on both numerical differentiation and integration is discussed. Finally, the chapter is concluded with a description of the application of several software packages and libraries for integration and differentiation. Chapter 24 demonstrates how the methods can be applied for problem solving. As with other parts of the book, applications are drawn from all fields of engineering. A review section, or epilogue, is included at the end of Part Six. This review includes a discussion of trade-offs that are relevant to implementation in engineering practice. In ad- dition, important formulas are summarized. Finally, we present a short review of advanced
  • 15. 580 NUMERICAL DIFFERENTIATIONAND INTEGRATION FIGURE PT6.10 Schematic of the organization of material in Part Six: Numerical Integration and Differentiation. methods and alternative references that will facilitate your further studies of numerical differentiation and integration. PT6.3.2 Goals and Objectives Study Objectives. After completing Part Six you should be able to solve many numeri- cal integration and differentiation problems and appreciate their application for engineer-
  • 16. PT6.3 ORIENTATION 58l TABLE PT6.3 Specific study objectives for Part Six. Understand the derivation of the Newton-Cotes formulas; know how to derve the trapezoidal rule and how to set up the derivation of both of Simpson's rules; recognize that the trapezoidal and Simpson's 1/3 and 3/8 rules represent the areas under flrst-, second-, and third-order polynom~als, respectively Know the formulas and error equations for la) the trapezoidal rule, Ib)the multiple-application trape- zoidal rule, (c)Slmpson's 1/3 rule, (dlSimpson's 3/8 rule, and (e)the multiple-application Simpson's rule Be able to choose the "best" among these formulas for any particular problem context. Recognize that Slrnpson's 1/3 rule is fourth-order accurate even though lt IS based on only three points; realize that all the even-segment-odd-point Newton-Cotesformulas have sim~lar enhanced accuracy Know how to evaluate the ~ntegral and derivative of unequally spaced data. Recognize the difference between open and closed integration formulas. Understand the theoret~calbasis of Richardson extrapolation and how ~t IS applied in the Romberg ~nte- gration algorithm and for numerical differentiation Understand the fundamental difference between Newton-Cotes and Gauss quadrature formulas. Recognize why both Romberg integration and Gauss quadrature have utility when ~ntegrating equa- tions (as opposed to tabular or discrete data). Know how open integration formulas are employed to evaluate improper integrals, Understand the application of high-accuracy numerical-differentiat~on formulas Know how to differentiate unequally spaced data. Recognize the differing effects of data error on the processesof numerical integration and differentiation ing problem solving. You should strive to master several techniques and assess their relia- bility. You should understand the trade-offs involved in selecting the "best" method (or methods) for any particular problem. In addition to these general objectives, the specific concepts listed in Table PT6.3 should be assimilated and mastered. Computer Objectives. You have been provided with software and simple computer al- gorithms to implement the techniques discussed in Part Six. All have utility as learning tools. The Numerical Methods TOOLKIT personal computer software is user-friendly. It employs the trapezoidal rule to evaluate the integral of either continuous functions or tab- ular data. The graphics associated with this software will enable you to easily visualize your problem and the associated mathematical operations as the area between the curve and the x axis. The software is very easy to apply to solve many practical problems and can be used to check the results of any computer programs you may develop yourself. In addition, algorithms are provided for most of the other methods in Part Five. This information will allow you to expand your software library to include techniques beyond the trapezoidal rule. For example, you may find it useful from a professional viewpoint to have software to implement numerical integration and differentiation of unequally spaced data. You may also want to develop your own software for Simpson's rules, Romberg inte- gration, and Gauss quadrature, which are usually more efficient and accurate than the trapezoidal rule. Finally, one of your most important goals should be to master several of the general- purpose software packages that are widely available. In particular, you should become adept at using these tools to implement numerical methods for engineering problem solving.
  • 17. CHAPTER 2 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: wherefn(x) = a polynomial of the form where n is the order of the polynomial. For example, in Fig. 21.la, a first-order polynomial (a straight line) is used as an approximation. In Fig. 21.lh, a parabola is employed for the same purpose. The integral can also be approximated using a series of polynomials applied piecewise to the function or data over segments of constant length. For example, in Fig. 21.2, three FlGURE 21.1 The approximat~on of an inte- gral by the area under (a)a sin- gle straight line and (b)a single parabola
  • 18. NEWTON-COTESINTEGRATION FORMULAS 583 straight-line segments are used to approximate the integral. Higher-order polynomials can be utilized for the same purpose. With this background, we now recognize that the "strip method" in Fig. PT6.6 employed a series of zero-order polynomials (that is, constants) to approximate the integral. 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. 21.3~). The open forms have integration limits that extend beyond the range of the data (Fig. 21.3b). In this sense, they are akin to extrapolation as discussed in Sec. 18.5. Open Newton-Cotes formulas are not generally used for definite integration. FIGURE 21.2 The approximation of an inte- gral by the area under three straight-line segments. FIGURE 21.3 The difference between (a]closed and (b)open integra- tion formulas.
  • 19. 584 NEWTON-COTESINTEGRATION FORMULAS However, they are utilized for evaluating improper integrals and for the solution of ordi- nary differential equations. This chapter emphasizes the closed forms. However, material on open Newton-Cotes formulas is briefly introduced at the end of this chapter. 21.1 THE TRAPEZOIDAL RULE The trapezoidal rule is the first of the Newton-Cotes closed integration formulas. It corre- sponds to the case where the polynomial in Eq. (21.1) is first-order: b b f(x)dx 2 f1( x ) dx Recall from Chap. 18that a straight line can be represented as [Eq. (18.2)] fl(x) = f(a) + f(b) - f(a) (x b - a -a) The area under this straight line is an estimate of the integral off (x) between the limits a and b: f(b) - f(a) (x - ) b - a The result of the integration (see Box 21.1 for details) is which is called the trapezoidal rule. Before integration, Eq. (21.2) can be expressed as This result can be evaluated to give f(b) - f W X +f(a) - f l ( x )= af(b)- af(a) b - a b - a I = f(b) - f(a) (b2-a2)+ bf(a)- af(b)(b- a ) b - a 2 b - a Grouping the last two terms gives Now, since b2 - a2 = (b - a)(b+a), f1(x) = f(b) - f(a)x + bf(a)-af(a) - af(b)+af(a) b + a b - a b - a I = [ f ( b )- f(a)l +bf(a>- af(b) or Multiplying and collecting terms yields f1(x) = f(b) - f(a)x + bf(a)-of@) b - a b - a which can be integrated between x = a and x = b to yield which is the formula for the trapezoidal rule. I = f(b) - f(a) *+ b - a 2
  • 20. 21.1 THE TRAPEZOIDAL RULE 585 Geometrically, the trapezoidal rule is equivalent to approximating the area of the trapezoid under the straight line connectingf(a) andf(b) in Fig. 21.4.Recall from geome- try that the formula for computingthe area of a trapezoid is the height times the averageof the bases (Fig. 21.5~). In our case, the concept is the same but the trapezoid is on its side (Fig. 21.5b). Therefore,the integral estimate can be represented as I E width x average height (21.4) FIGURE 21.4 Graphical depiction of the trapezoidal rule. FIGURE 21.5 [a)The formula for computin the area of a trapezoid: height times the average of the bases [b)For the trapezoidal rule, R t e concept is the same but the trapezoid is on its side.
  • 21. 586 NEWTON-COTESINTEGRATIONFORMULAS I E (h- a) x average height (21.5) where, for the trapezoidal rule, the average height is the average of the function values at the end points, or [f(a) +f(b)]/2. All the Newton-Cotes closed formulas can be expressed in the general format of Eq. (21.5). In fact, they differ only with respect to the formulation of the average height. 21.I. 1 Error of the Trapezoidal Rule When we employ the integral under a straight-line segment to approximate the integral under a curve, we obviously can incur an error that may be substantial (Fig. 21.6). An estimate for the local truncation error of a single application of the trapezoidal rule is (Box. 21.2) where <lies somewhere in the interval from a to b. Equation (21.6) indicates that if the function being integrated is linear, the trapezoidal rule will be exact. Otherwise, for func- tions with second- and higher-order derivatives (that is, with curvature), some error can occur. FIGURE 21.6 Graphical depiction of the use of a single opplication of the trapezoidal rule to approximate the integral of fix) = 0.2 + 25x - 200x2 + 675x3 - 900x4 + 400x5 from x = 0to 0.8.
  • 22. 21.1 THE TRAPEZOIDALRULE 587 An alternative derivation of the trapezoidal rule is possible by inte- constant, this equation can be integrated: grating the forward Newton-Gregory interpolating polynomial. Re- call that for the first-order version with error term, the integral 1 = h would be (Box 18.2) a I and evaluated as 1 = Sb[ f ( a )+Af(o)a +m a ( a - l)h2 dx (821.2.1) 2 To simplify the analysis, realize that because a = (x - a)/h, Because Af(a) =f(b) -f(a),the result can be written as dx = h da Inasmuch as h = b - a (for the one-segment trapezoidal rule), the limits of integration a and b correspond to 0 and 1, respectively. Therefore, Eq. (B21.2.1)can be expressed as I = h ' [ f ( a )+Af(a)a +m a ( , - l)h2 d o 2 1 le and the second is an approximation for the error. If it is assumed that, for small h, the term f"(6) is approximately EXAMPLE 2 1.1 Single Application of the Trapezoidal Rule I Problem Statement. Use Eq. (21.3)to numerically integrate i i f(x) = 0.2 +25x - 200x2+675x3 - 900x4 +400x5 from a = 0 to b = 0.8.Recall from PT6.2 that the exact value of the integral can be deter- mined analytically to be 1.640533. Solution. The function values can be substituted into Eq. (21.3)to yield which represents an error of which corresponds to a percent relative error of E, = 89.5%. The reason for this large error is evident from the graphical depiction in Fig. 21.6. Notice that the area under the straight line neglects a significant portion of the integral lying above the line. In actual situations, we would have no foreknowledge of the true value. Therefore, an approximate error estimate is required. To obtain this estimate, the function's second
  • 23. 588 NEWTON-COTESINTEGRATION FORMULAS 1 derivative over the interval can be computed by differentiating the original function twice I to give i fl'(x) = -400 +4 0 5 0 ~ - 10,800x2+8000x3 I ! , The average value of the second derivative can be computed using Eq. (PT6.4): 0 8 I ( -400 +4050x - 10,800x2+8000x3) dx i f "(x) = = -60 0.8 - 0 i a which can be substituted into Eq. (21.6) to yield I 1 which is of the same order of magnitude and sign as the true error. A discrepancy does exist, ' however, because of the fact that for an interval of this size, the average second derivative I .is not necessarily an accurate approximation off'((). Thus, we denote that the error is ap- proximate by using the notation E,, rather than exact by using E,. I 21,1.2 The Multiple-ApplicationTrapezoidal Rule One way to improve the accuracy of the trapezoidal rule is to divide the integration interval from a to h into a number of segments and apply the method to each segment (Fig. 21.7). 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. Figure 21.8 shows the general format and nomenclature we will use to characterize multiple-application integrals. There are n + 1 equally spaced base points (xo,XI,x;?,. . ., x,). Consequently, there are n segments of equal width: If a and h are designated as xo and x,, respectively, the total integral can be represen- ted as Substituting the trapezoidal rule for each integral yields or, grouping terms, n-l
  • 24. 21.1 THE TRAPEZOIDAL RULE 589 FlGURE 21-7 Illustration of the multiple-appl~cation trapezoidal rule. (a)Two segments, (b)three segments, (c)four segments, and (d)five segments.
  • 25. 590 NEWTON-COTESINTEGRATIONFORMULAS FIGURE 21.8 The general format and nornen- clature for multiple-application integrals. or, using Eq. (21.7)to express Eq. (21.9)in the general form of Eq. (21.5), Because the summation of the coefficients off(x) in the numerator divided by 2n is equal to 1,the average height represents a weighted average of the function values. According to Eq. (21.lo),the interior points are given twice the weight of the two end pointsf(x0) and f(-4. An error for the multiple-application trapezoidal rule can be obtained by summing the individual errors for each segment to give
  • 26. 21.1 THE TRAPEZOIDAL RULE 5 91 where f1'(Ci)is the second derivative at a point cilocated in segment i. This result can be simplified by estimating the mean or average value of the second derivative for the entire interval as [Eq. (PT6.3)] Cf "(ti) Therefore Cf "(C;) ; . ) nf and Eq. (21.11)can be rewritten as Thus, if the number of segments is doubled, the truncation error will be quartered. Note that Eq. (21.1 3) is an approximate error because of the approximate nature of Eq. (21.12). EXAMPLE 2 1.2 Multiple-Application Trapezoidal Rule i Problem Statement. Use the two-segment trapezoidal rule to estimate the integral of 1 f ( x ) = 0.2 +25x - 200x2 +675x3- 900x4 +400x5 I from a = 0 to h = 0.8. Employ Eq. (21.13)to estimate the error. Recall that the correct a value for the integral is 1.640533. i Solution. n = 2(h = 0.4): : where -60 is the average second derivative determined previously in Example 21.1 The results of the previous example, along with three- through ten-segment applica- tions of the trapezoidal rule, are summarized in Table 21.1. Notice how the error decreases as the number of segments increases. However, alsonotice that the rate of decrease is grad- ual. This is because the error is inversely related to the square of n [Eq. (21.13)]. Therefore, doubling the number of segments quarters the error. In subsequent sections we develop higher-order formulas that are more accurate and that converge more quickly on the true in- tegral as the segments are increased. However, before investigating these formulas, we will first discuss computer algorithms to implement the trapezoidal rule. 21 . 1 . 3 Computer Algorithms For the Trapezoidal Rule Two simple algorithms for the trapezoidal rule are listed in Fig. 21.9. The first (Fig. 21.9~) is for the single-segment version. The second (Fig. 21.9h) is for the multiple-segment version with a constant segment width. Note that both are designed for data that is in tabu-
  • 27. 592 NEWTON-COTESINTEGRATION FORMULAS TABLE 21.I Results for multiple-applicationtrapezoidal rule to estimate the integral of f(x)= 0.2 + 25x - 200x2+ 675x3 - 900x4+ 400x5 from x = 0 to 0.8. The exact value is 1.640533. (a) Single-segment (b) Multiple-segment FliNCTiON Trap (h, &O, fl) FUNCTION Trapm (h, n, f) Trap = h + + j f O +f?) / 2 sum = fo EWD Trap D O i = I, n - I sum = sum + 2 * F, END GO sum = sum + f, Trapm = h * s u m / 2 END frapm FIGURE 21.9 Algor~thns for the (a]sngle-segmentand (b]multiple-segmenttrapezo~dal rule lated form. A general program should have the capability to evaluate known functions or equations as well. We will illustrate how functions are handled in the next chapter. An example of a user-friendly program for the multiple-segment trapezoidal rule is in- cluded in the supplementary Numerical Methods TOOLKIT software associated with this text. This software can evaluate the integrals of either tabulated data or user-defined func- tions. The following example demonstrates its utility for evaluating integrals. It also pro- vides a good reference for assessing and testing your own software. EXAMPLE 21.3 Evaluating Integrals with the Computer Problem Statement. Use the Numerical Methods TOOLKIT software to solve a prob- lem related to our friend the falling parachutist. As you recall from Example 1.1, the velocity of the parachutist is given as the following function of time:
  • 28. 21.1 THE TRAPEZOIDAL RULE 593 2 where v = velocity (m/s), g = the gravitational constant of 9.8 m/s , m = mass of the parachutist equal to 68.1 kg, and c = the drag coefficient of 12.5kg/s. The model predicts the velocity of the parachutist as a function of time as described in Example 1.1. Suppose we would like to know how far the parachutist has fallen after a certain time t. This distance is given by [Eq. (PT6.5)I i I where d is the distance in meters. Substituting Eq. (E21.3. I), Use the Numerical Methods TOOLKIT software and your own software to determine this I integral with the multiple-segment trapezoidal rule using different numbers of segments. 1 Note that performing the integration analytically and substituting known parameter values [ results in an exact value of d = 289.43515 m. Solution. Click the Integrate Function button on the TOOLKIT main menu to obtain a blank screen similar to Fig. 21.10. This screen contains the input and output information needed to integrate an analytical function or tabular data. First, we can click the Input Function table and enter the function, Next click the Input Parameters block and enter values for the lower and upper limits of in- tegration of 0 and 10. Next, enter the value 10 for the number of segments along with plot dimensions, as in Fig. 21.lo. 1 FIGURE21.10 1 Computer screen showing the integral of a function using the multiple-segment trapezoidal rule 1 program from the Numerical Methods TOOLKIT. j
  • 29. 594 NEWTON-COTESINTEGRATIONFORMULAS After clicking the Calc and Plot buttons, a calculated integral of 288.7491 is displayed. Thus, we have attained the integral to three significant digits of accuracy. The integral is equivalent to the area under the v(t)versus t curve, as shown in Fig. 21.10. Visual inspec- tion confirms that the integral is the width of the interval (10 s) times the average height (about 29 m/s). Aplot of the function showing the segments is shown in Fig. 21.10. We can conveniently try other numbers of segments. By n = 500, the result is accurate to six sig- nificant digits. At this point, it is important to recognize that the Numerical Methods TOOLKIT uses double precision to obtain its integral estimate. We therefore repeated this problem using a program based on the pseudocode from Fig. 21.9b and employed single-precision numbers (i.e., about seven significant decimal digits of precision). The results are Segments Segment size Estimated d, m Thus, up to about 500 segments, the multiple-application trapezoidal rule attains excellent accuracy. However, notice how the error changes sign and begins to increase in absolute value beyond the 500-segment case. The 10,000-segment case actually seems to be diverging from the true value. This is due to the intrusion of round-off error because of the great number of computations for this many segments. Thus, the level of precision is limited, and we would never reach the exact result of 289.4351 obtained analytically. This limitation will be discussed in further detail in Chap. 22. Three major conclusions can be drawn from the Example 21.3: For individual applications with nicely behaved functions, the multiple-segment trape- zoidal rule is just fine for attaining the type of accuracy required in many engineering applications. If high accuracy is required, the multiple-segment trapezoidal rule demands a great deal of computational effort. Although this effort may be negligible for a single application, it could be very important when (a)numerous integrals are being evaluated or (b) where the function itself is time consuming to evaluate. For such cases, more efficient ap- proaches (like those in the remainder of this chapter and the next) may be necessary. Finally, round-off error can represent a limitation on our ability to determine integrals. This is due both to the machine precision as well as to the numerous computations involved in simple techniques like the multiple-segment trapezoidal rule.
  • 30. 21.2 SIMPSON'S RULES 595 We now turn to one way in which efficiency is improved. That is, by using higher- order polynomials to approximate the integral. SIMPSON'S RULES Aside from applying the trapezoidal rule with finer segmentation, another way to obtain a more accurate estimate of an integral is to use higher-order polynomials to connect the points. For example, if there is an extra point midway between f(a) and f(b),the three points can be connected with a parabola (Fig. 21.11~). If there are two points equally spaced between f(a) andf(b),the four points can be connected with a third-order polyno- mial (Fig. 21.1lb).The formulas that result from taking the integrals under these poly- nomials are called Simpson's rules. 21.2.1 Simpson's 1/ 3 Rule Simpson's 1/3 rule results when a second-order interpolating polynomial is substituted into Eq. (21.1): If a and b are designated as xo and x2 andf2(x)is represented by a second-order Lagrange polynomial [Eq. (18.23)], the integral becomes FIGURE 28.1 1 [a)Graphical depiction of Simp- son's 1 /3 rule: it consists of takin the area under a paraEola connecting three points. (b]Graphical depiction of Simpson's 318 rule: it con- sists of taking the area under a cubic equation connecting four points.
  • 31. 596 NEWTON-COTESINTEGRATIONFORMULAS After integration and algebraic manipulation, the following formula results: 4(,4 i where, for thls case, h = (b - a)/2.This equation is known as Slmpson's 113 rule. It is the A * . J b second Newton-Cotes closed integration formula. The label "1/3" stems from the fact that h is divided by 3 in Eq. (21.14).An alternative denvation is shown in Box 21.3 where the Newton-Gregory polynom~alis integrated to obtain the same formula. Simpson's 113rule can also be expressed using the format of Eq. (21.5): 3 Derivation and Error As was done in Box 21.2 for the trapezoidal rule, Simpson's 113 rule can be derived by integrating the forward Newton-Gregory in- terpolating polynomial (Box 18.2): Notice that we have written the polynomial up to the fourth-order term rather than the third-order term as would be expected.The rea- son for this will be apparent shortly. Also notice that the limits of integration are from xo to x2. Therefore, when the simplifying sub- stitutions are made (recall Box 21.2), the integral is from u = 0 to 2: + - - - + - - - a 2 ) ,f*)(5)h412 ( 2 8 o and evaluated for the limits to give A2f(x0) 2f(xo)+2Af(xo)+- - - 3 (B21.3.1) Notice the significant result that the coefficient of the third divided difference is zero. Because Af(xo)=f(xl) -f(xo) and A2f(xo)= f(x2) - 2f(xl)+f(xo),Eq. (B21.3.1)can be rewritten as /I I I = - If(.r") +4f(xt)+f(sz)j- -f'"'(4)h5 3 90 ' - Strnpson's 1'3 rule Truncation error 4 u ( u- 1 - 2 - 3 ) da +- - I Thus, the first tern is Simpson's 113rule and the second is the trun- 24 cation error. Because the third divided difference dropped out, we which can be integrated to yield obtain the significant result that the formula is third-order accurate.
  • 32. 21.2 SIMPSON'S RULES 597 where a = xo, h = x2, and xl = the point midway between a and 6, which is given by (b +a)/2. Notice that, according to Eq. (21.15), the middle point is weighted by two- thirds and the two end points by one-sixth. It can be shown that a single-segment application of Simpson's 1/3 rule has a trunca- tion error of (Box 21.3) or, because h = (h - a)/2, where <lies somewhere in the interval from a to b. Thus, Simpson's 113 rule is more ac- curate than the trapezoidal rule. However, comparison with Eq. (21.6) indicates that it is more accurate than expected. Rather than being proportional to the third derivative, the error is proportional to the fourth derivative. This is because, as shown in Box 21.3, the co- efficient of the third-order term goes to zero during the integration of the interpolating polynomial. Consequently, Simpson's 1/ 3 rule is third-order accurate even though it is based on only three points. In other words, it yields exact results for cubic polynomials even though it is derived from a parabola! EXAMPLE 2 1.4 Single Application of Simpson's 1/3 Rule : Problem Statement. Use ~ q . (21.15)to integrate I ; f(x) = 0.2 +25n - 200x2 +675x3- 900x4 +400x5 I 1 from a = 0 to b = 0.8. Recall that the exact integral is 1.640533. I Solution. i I Therefore, Eq. (21.15)can be used to compute j which represents an exact error of 3 Et = 1.640533 - 1.367467 = 0.2730667 = 16.6% 1 i which is approximately 5 times more accurate than for a single application of the trape- i zoidal rule (Example 21.1). I The estimated error is [Eq .(21.16)] ; where -2400 is the average fourth derivative for the interval as obtained using Eq. (PT6.4). ' As was the case in Example 21.1, the error is approximate (E,) because the average fourth
  • 33. 598 NEWTON-COTESINTEGRATIONFORMULAS r derivative is not an exact estimate off (4)(<). However, because this case deals with a fifth- : order polynomial, the result matches. L - - - -------- ------- ----- - - - --------------- - 21.2.2 The Multiple-ApplicationSimpson's 1/3 Rule Just as with the trapezoidal rule, Simpson's rule can be improved by dividing the integra- tion interval into a number of segments of equal width (Fig. 21.12): h - a h = - n The total integral can be represented as Substituting Simpson's 113rule for the individual integral yields +...+2h f(xn-2) +4f(xn-1> +f ( ~ n > 6 or, combining terms and using Eq. (21.17), 1=1,3,5 j=2.4.h 1 2 (b -u ) (21 18, 3n -- / Width Average height FlGURE 21.12 Graphical representation of the multiple application of Simp- son's 1/3 rule Note that the method can be employed only if the number of segments is even.
  • 34. 21.2 SIMPSON'S RULES 599 Notice that, as illustrated in Fig. 21.12, an even number of segments must be utilized to implement the method. In addition, the coefficients "4" and "2" in Eq. (21.18) might seem peculiar at first glance. However, they follow naturally from Simpson's 1/3 rule. The odd points represent the middle term for each application and hence carry the weight of 4 from Eq. (21.15). The even points are common to adjacent applications and hence are counted twice. An error estimate for the multiple-application Simpson's rule is obtained in the same fashion as for the trapezoidal rule by summing the individual errors for the segments and averaging the derivative to yield where f (4) is the average fourth derivative for the interval. EXAMPLE 2 1.5 Multiple-Application Version of Simpson's 1/3 Rule I Problem Statement. Use Eq. (21.18) with n = 4 to estimate the integral of i 1 f(x) = 0.2 +25.1 - 200x2+675x3- 900x4+400x5 from a = 0 to h = 0.8. Recall that the exact integral is 1.640533. j ! Solution. n = 4 (h = 0.2): I The estimated error [Eq. (21.19)] is 1 The previous example illustrates that the multiple-application version of Simpson's 113rule yields very accurate results. For this reason, it is considered superior to the trape- zoidal rule for most applications. However, as mentioned previously, it is limited to cases where the values are equispaced. Further, it is limited to situations where there are an even number of segments and an odd number of points. Consequently, as discussed in the next section, an odd-segment-even-point formula known as Simpson's 3/8 rule is used in con- junction with the 1/3 rule to permit evaluation of both even and odd numbers of segments.
  • 35. 600 NEWTON-COTESINTEGRATION FORMULAS 21 . 2 . 3 Simpson's 318 Rule In a similar manner to the derivation of the trapezoidal and Simpson's 113 rule, a third- order Lagrange polynomial can be fit to four points and integrated: to yield where h = (h - a)/3.This equation is called Simpson's318 rule because h is multiplied by 318. It is the third Newton-Cotes closed integration formula. The 318 rule can also be ex- pressed in the form of Eq. (21.5): FIGURE 21.13 lliustration of how Simpson's 1/3 and 3/8 rules can be applied in tandem to handle rnult~ple applications with odd numbers of intervals.
  • 36. 21.2 SIMPSON'S RULES 601 Thus, the two interior points are given weights of three-eighths, whereas the end points are weighted with one-eighth. Simpson's 3/8rule has an error of or, because h = (b- a)/3, Because the denominator of Eq. (21.21) is larger than for Eq. (21.16), the 3/8rule is some- what more accurate than the 1/3 rule. Simpson's 113 rule is usually the method of preference because it attains third-order accuracy with three points rather than the four points required for the 3/8version. How- ever, the 3/8rule has utility when the number of segments is odd. For instance, in Ex- ample 21.5 we used Simpson's rule to integrate the function for four segments. Suppose that you desired an estimate for five segments. One option would be to use a multiple- application version of the trapezoidal rule as was done in Examples 21.2 and 21.3.This may not be advisable, however, because of the large truncation error associated with this method. An alternative would be to apply Simpson's 1/3 rule to the first two segments and Simpson's 3/8rule to the last three (Fig. 21.13). In this way, we could obtain an es- timate with third-order accuracy across the entire interval. EXAMPLE 2 1.6 Simpson's 3 / 8 Rule Problem Statement. (a) Use Simpson's 3/8rule to integrate from a = 0 to b = 0.8. (b) Use it in conjunction with Simpson's 113 rule to integrate the same function for five segments. I Solution. (a)A single application of Simpson's 3/8rule requires four equally spaced points: ,f(O) = 0.2 f(0.2667) = 1.432724 f(0.5333)= 3.487177 f(0.8)= 0.232 Using Eq. (21.20), 0.2+3(1.432724+3.487177)+0.232= I 2 0.8 8
  • 37. 602 NEWTON-COTESINTEGRATIONFORMULAS (b) The data needed for a five-segment application (h = 0.16) is f(0) = 0.2 f(0.16) = 1.296919 f(0.32) = 1.743393 f(0.48) = 3.186015 f(0.64) = 3.181929 f(O.80) = 0.232 The integral for the first two segments is obtained using Simpson's 1/3 rule: For the last three segments, the 318 rule can be used to obtain The total integral is computed by summing the two results: I = 0.3803237 + 1.264753 = 1.645077 E, = 1.640533 - 1.645077 = -0.00454383 E, = -0.28% 21.2.4 Computer Algorithms for Simpson" Rules Pseudocode for a number of forms of Simpson's rule are outlined in Fig. 21.14. Note that all are designed for data that is in tabulated form.A general program should have the capa- bility to evaluate known functions or equations as well. We will illustrate how functions are handled in the next chapter. Notice that the program in Fig. 21.14d is set up so that either an even or odd number of segments may be used. For the even case, Simpson's 113 rule is applied to each pair of segments, and the results are summed to compute the total integral. For the odd case, Simp- son's 318 rule is applied to the last three segments, and the 113rule is applied to all the pre- vious segments. 21.2.5 Higher-Order Nedon-Cotes Closed Formulas As noted previously, the trapezoidal rule and both of Simpson's rules are members of a family of integrating equations known as the Newton-Cotes closed integration formulas. Some of the formulas are summarized in Table 21.2, along with their truncation-error esti- mates. Notice that, as was the case with Simpson's 113 and 318 rules, the five- and six-point formulas have the same order error. This general characteristic holds for the higher-point formulas and leads to the result that the even-segment-odd-point formulas (for example, 113rule and Boole's rule) are usually the methods of preference. However, it must also be stressed that, in engineering practice, the higher-order (that is, greater than four-point) formulas are rarely used. Simpson's rules are sufficient for most applications. Accuracy can be improved by using the multiple-application version. Fur- thermore, when the function is known and high accuracy is required, methods such as
  • 38. 21.2 SIMPSON'S RULES 603 (a) FUNCTION Simp13 (h, fO, f?,f2) Simp13 = 2*h* (f0+4*Fl+f2) / 6 END Simp13 (b) FUNCTION Simp38 (h, fO, f?,f2, f 3 ) Simp38 = 3*h* (f0+3*(fltf2)+f3) / 8 END 5imp38 ( ~ 9 FUNCTION 5imp13m [h, n, f ) sum = f(0) DO;= 1,n - 2 , 2 s u m = s u m + 4 * f , + 2 * F , + 7 END DO sum = sum +4 * f n - , + f, Sirnp13m = h * sum / 3 END SimpI3m (4 FUNCTION Simplnt(a, b, n, f) h = ( b - a ) / n IF n = 1 THEN sum = Trap(h, f,-l, f,) ELSE m = n odd = n / 2 - INT(n / 2 ) I F o d d > O A N D n > I T H E N sum = sum+5imp38(h,fn-sfn-2,fn-1,fn) m = n - 3 END IF IF m > 1THEN sum = sum + 5imp13m(h, m, f) END IF END IF Simplnt = sum END Simplnt FBOURE 21.I4 Pseudocode for Simpson's rules. (a)Single-application Simpson's 1/ 3 rule, [b)s~ngle-application Simpson's 318 rule, [c)multiple-applicationSimpson's 1/3 rule, and [d)multiple-application Simpson's rule for both odd and even number of segments. Note that for all cases n must be > I TABLE 21 Newton-Cotes closed integration formulas. The formulas are presented in the format of Eq. (21.5)so that the weighting of the data points to estimate the average height is apparent. The step size is given by h = (b- o)/n. Segmenb (4 Points Name Formula Truncation Error 1 2 f(xoi+ {(xii Trapezoidal rule (b- a)7 2 3 Simpson's 1/ 3 rule (b- a] fix01+4fix1) +fix21 6 3 4 Simpson's 318 rule (b- a) fixo) + 3fIx11 + 3 f ( ~ ~ ] + Fix3] 8 - i3/80)h5f141([) 4 5 Boole's rule Ib- a 1 7fIxol + 32fix1) + 12fIxz)+ 32fix31 +7f(x4) 90 - (8/945)h7f161[c]
  • 39. 604 NEWTON-COTES INTEGRATION FORMULAS Romberg integration or Gauss quadrature, described in Chap. 22, offer viable and attrac- tive alternatives. 21.3 IlUTEGlZATlON WITH UNEQUAL SEGMENTS To this point, all formulas for numerical integration have been based on equally spaced data points. In practice, there are many situations where this assumption does not hold and we must deal with unequal-sized segments. For example, experimentally derived data is often of this type. For these cases, one method is to apply the trapezoidal rule to each seg- ment and sum the results: where hi= the width of segment i. Note that this was the same approach used for the multiple-application trapezoidal rule. The only difference between Eqs. (21.8) and (21.22) is that the h's in the former are constant. Consequently, Eq. (21.8) could be simplified by grouping terms to yield Eq. (21.9). Although this simplification cannot be applied to Eq. (21.22), a computer program can be easily developed to accommodate unequal-sized segments. Before describing such an algorithm, we will illustrate in the following exam- ple how Eq. (21.22) is applied to evaluate an integral. EXAMPLE 2 1.7 Trapezoidal Rule with Unequal Segments Problem Statement. The information in Table 21.3 was generated using the same polynomial employed in Example 21.1. Use Eq. (21,22) to determine the integral for this data. Recall that the correct answer is 1.640533. Solution. Applying Eq. (21.22) to the data in Table 21.3 yields which represents an absolute percent relative error of E, = 2.8% TABLE 21.3 Data for f(x)= 0.2 +25x - 200x2+675x3 - 900x4 +400x5,with unequally spaced values X f(X) X f (XI 00 0200000 0.44 2.842985 0.12 1.309729 0.54 3.507297 0.22 1.305241 0.64 3.181929 0.32 1 743393 0.70 2 363000 0.36 2.074903 0.80 0.232000 040 2.456000
  • 40. 21.3 INTEGRATIONWITH UNEQUAL SEGMENTS 605 FIGURE 2 1.1 5 Use of the trapezoidal rule to determine the integral of unevenly spaced data. Notice how the shaded segments could be evaluated with Sirnpson's rule to attain higher accuracy. The data from Example 21.7 is depicted in Fig. 21.15. Notice that some adjacent seg- ments are of equal width and, consequently,could have been evaluated using Simpson's rules. This usually leads to more accurate results, as illustrated by the following example. EXAMPLE 2 1.8 Inclusion of Simpson's Rules in the Evaluation of Uneven Data 1 Problem Statement. Recompute the integral for the data in Table 21.3, but use / Simpson's rules for those segments where they are appropriate. Solution. The first segment is evaluated with the trapezoidalrule: 1 1 Becausethe next two segmentsfromx = 0.12 to 0.32 are of equal length,their integralcan be computed with Simpson's 113rule: 8 1 The next three segments are also equal and, as such, may be evaluated with the 3/8 rule to ! give I = 0.2726863. Similarly, the 1/3 rule can be applied to the two segments from x = 0.44 to 0.64 to yield I = 0.6684701. Finally, the last two segments, which are of un- I equal length, can be evaluated with the trapezoidal rule to give values of 0.1663479 and 1 0.1297500, respectively.The area of these individual segments can be summed to yield a
  • 41. 606 NEWTON-COTESINTEGRATION FORMULAS 1 total integral of 1.603641. This represents an error of el = 2.2%, which is superior to the ! result using the trapezoidal rule in Example 21.7. L Computer Program for Unequally Spaced Data. It is a fairly simple proposition to program Eq. (21.22). Such an algorithm is listed in Fig. 21.16~. However,as demonstrated in Example 21.8, the approach is enhanced if it implements Simpson's rules wherever possible. For this reason, we have developed a second algorithm that incorporates this capability.As depicted in Fig 21.16b, the algorithm checks the length of adjacent segments. If two consecutive segments are of equal length, Simpson's 113rule is applied. If three are equal, the 318 rule is used. When adjacent segments are of unequal length, the trapezoidal rule is implemented. FUGURE 21.16 Pseudocode for integratin unequally spaced data. (a)Trapezoidal rule and (b)combination Simpson's and trapezoida9rules. (4 FUNCTION Trapun (x, y,n) LOCAL i, sum 5um = 0 D O i = l , n sum = sum +(xi - xi-,)~(yi-, +yi)/2 END DO Trapun = sum END Trapun (6) FUNCTION Uneven (n, x, f ) h = XI - xo k = 1 sum = 0. D O j = 1, n hf = xj+, - X, J IF A 0 5 ( h - hf)< .000001THEN IF k = 3 THEN sum = sum + Simp13 (h, 5-3,6-8G-I) k = k - 1 ELSE k = k + 1 END IF ELSE IF k = 1 THEN sum = sum + Trap (h, j-,,$) ELSE IF k = 2 THEN sum = sum + Simp13 (h, cT2,5-,, 5) ELSE sum = sum +Simp38 (h, 5-3, 5-2, 5-,, 5) END IF k = l END IF END IF h = hf END DO Uneven = sum END Uneven
  • 42. PROBLEMS 607 TABLE 21.4 Newton-Cotes open integration formulas. The formulas are presented in the for- mat of Eq. (21.5) so that the weighting of the data points to estimate the aver- age height is apparent. The step size is given by h = (b- a)/n. Segments (4 Points Name Formula Truncation Error 2 1 Midpoint method lb - oi fix11 [ 1/31h3plt) .S 4 1 1flx,! + flx2i + fjxgi + 1 1fjx',) Ib- ai 24 195,') 44)h5f[4lje) Thus, not only does it allow evaluation of unequal segment data, but if equally spaced information is used, it reduces to Simpson's rules. As such, it represents a basic, all-purpose algorithm for the determination of the integral of tabulated data. 21.4 OPEN INTEGMTION FORMULAS Recall from Fig 21.3b that open integration formulas have limits that extend beyond the range of the data. Table 21.4 summarizes the Newton-Cotes open integration formulas. The formulas are expressed in the form of Eq. (21.5) so that the weighting factors are evident. As with the closed versions, successive pairs of the formulas have the same order error. The even-segment-odd-point formulas are usually the methods of preference be- cause they require fewer points to attain the same accuracy as the odd-segment-even-point formulas. The open formulas are not often used for definite integration. However, as discussed in Chap. 22, they have utility for analyzing improper integrals. In addition, they will have relevance to our discussion of multistep methods for solving ordinary differential equa- tions in Chap. 26. PROBLEMS 21.1 Use analytical means to evaluate (a) (I - .-"I d* 0 21.2 Use a single application of the trapezoidal rule to evaluate the integrals from Prob. 21.1. 21.3 Evaluate the integrals from Prob. 21.1 with a multiple- application trapezoidal rule, with n = 2,4, and 6. 21.4 Evaluate the integrals from Prob. 21.1 with a single applica- tion of Simpson's 113rule. 21.5 Evaluate the integrals from Prob. 21.1 with a multiple- application Simpson's 113rule, with n = 4 and 6.
  • 43. 608 NEWTON-COTESINTEGRATIONFORMULAS 21.6 Evaluate the integrals from Prob. 21.1 with a single applica- tion of Simpson's 318 rule. 21.7 Evaluate the integrals from Prob. 21.1, but use a multiple- application Simpson's rule, with n = 5. 21.8 Integrate the following function using the trapezoidal rule, with n = 1, 2, 3, and 4: Compute percent relative errors with respect to the true value of 4.8333 to evaluate the accuracy of the trapezoidal approximations. 21.9 Integrate the following function both analytically and using Simpson's rules, with n = 4 and 5: Discuss the results 21.10 Integrate the following function both analytically and nu- merically. Use both the trapezoidal and Simpson's 113rules to nu- merically integrate the function. For both cases, use the multiple- application version, with n = 4. Compute percent relative errors for the numerical results. 21.11 Integrate the following function both analytically and nu- merically. For the numerical evaluations use (a) a single applica- tion of the trapezoidal rule, (b) Simpson's 113 rule, (c) Simpson's 318 rule, (d) Boole's rule, (e) the midpoint method, (f) the 3 segmentl2-point open integration formula, and (g) the 4- segmentl3-point open integration formula. 21.13 Integrate the following function, Note that the true value is 0.602297. Evaluate this integral with the multiple-segment trapezoidal rule. Use a sufficiently high n that you get 4 significant digits of accuracy. Discuss your results. 21.14 Evaluate the integral of the following tabular data with the trapezoidal rule: 21.15 Perform the same evaluation as in Prob. 21.14, but use Simpson's rules. 21.16 Evaluate the integral of the following tabular data using the trapezoidal rule: x 1 -3 -1 1 3 5 7 9 1 1 fix) 1 1 -4 -9 2 4 2 6 -3 21.17 Perform the same evaluation as in Prob. 21.16, but use Simpson's rules. 21.18 Determine the mean value of the function between x = 2 and 10 by (a) graphing the function and visually estimating the mean value, (b) using Eq. (PT6.4) and the analyti- cal evaluation of the integral, and (c) using Eq. (PT6.4) and a five- segment version of Simpson's rule to estimate the integral. Calcu- late the relative percent error. 21.19 The function f(x) = e-' can be used to generate the following table of unequally spaced data: Compute percent relative errors for the numerical results. x I 0 0.1 0.3 0.5 0.7 0.95 1.2 21.12 Integrate the following function both analytically and fix) I 1 0.904807408 06065 04 9 6 6 0.38670 . 3 0 1 2 numerically. For the numerical evaluations use (a) single applica- Evaluate the integral from a = 0 to b = 1.2 using (a) analytical tion of the trapezoidal rule: (b) Simpson's 113 rule, (c) Simpson's means, (b) the trapezoidal rule, and (c) a of the trape- 318 rule, (d) multiple application of Simpson's rules (n = 5), zoidal and Simpson's rules; employ Simpson's rules wherever pos- (e) Boole's rule, ( f ) the midpoint method, (g) the 3-segment/2- sible to obtain the highest accuracy. For (b) and (c), compute the point open integration formula, and (h) the 4-segmentl3-point percent relative error ( E ~ ) . open integration formula. 21.20 Evaluate the following double integral: P R J (5 +3 sin x) dx Compute percent relative errors for the numerical results.
  • 44. PROBLEMS 609 (a) analytically. (b) using a multiple-application trapezoidal rule data. Test your program by duplicating the computation from Ex- (n = 2), (c) using single applications of Simpson's 113 rule. For ample 21.2. (b) and (c), compute the percent relative error ( E ~ ) . 21.23 Develop a user-friendly computer program for the multiple- 21.21 Evaluate the triple integral application version of Simpson's rule based on Fig. 21.14~. Test it by duplicating the computations from Example 21.5. l6 /:(x3- 2y2) d . ~ dy dr 21.24 Develop a user-friendly computer program for integrating unequally spaced data based on Fig. 21.16b. Test it by duplicating the computation from Example 21.8. (a) analytically and (b) using single applications of Simpson's 113 21-25 use the Integrate Function program on the Numerical rule. For (b) compute the percent relative error (s,). MethodsTOOLKIT disk (or your own program fromProb. 21.22)to Develop a user-friendly computerprogram for the repeat (a) Prob. 21.2, (b) Prob. 21.3, (c) Prob. 21.8, (d) Prob. 21.10, application trapezoidal rule based on Fig. 21.9. Among (e) Prob. 21.12. Use the graphical option to help you visualize things, (a) add documentation statements to the code, (b) make the the concept that I = lab f(x) d x is the area between thef(.x) curve and Outputuser-Oriented,and (c) the program so that and the axis,Try several differentstep sizes for each problem, it is capable of evaluating given functions in addition to tabular
  • 45. CHAPTER 22 ntegration o Equations In the introduction to Part Six, we noted that functions to be integrated numerically will typically be of two forms: a table of values or a function. The form of the data has an im- portant influence on the approaches that can be used to evaluate the integral. For tabulated information, you are limited by the number of points that are given. In contrast, if the func- tion is available, you can generate as many values off(x) as are required to attain accept- able accuracy (recall Fig. PT6.7). This chapter is devoted to two techniques that are expressly designed to analyze cases where the function is given. Both capitalize on the ability to generate function values to de- velop efficient schemes for numerical integration. The first is based on Richardson's ex- trapolation, which is a method for combining two numerical integral estimates to obtain a third, more accurate value. The computational algorithm for implementing Richardson's extrapolation in a highly efficient manner is called Romherg integration. This technique is recursive and can be used to generate an integral estimate within a prespecified error tolerance. The second method is called Gauss quadrature. Recall that, in the last chapter, values off(x) for the Newton-Cotes formulas were determined at specified values of x. For exam- ple, if we used the trapezoidal rule to determine an integral, we were constrained to take the weighted average of f(x) at the ends of the interval. Gauss-quadrature formulas employ x values that are positioned between a and h in such a manner that a much more accurate in- tegral estimate results. In addition to these two standard techniques, we devote a final section to the evalua- tion of improper integrals. In this discussion, we focus on integrals with infinite limits and show how a change of variable and open integration formulas prove useful for such cases. 22.1 NEWTON-COTESALGORITHMS FOR EQUATlONS In Chap. 21, we presented algorithms for multiple-application versions of the trapezoidal rule and Simpson's rules. Although these pseudocodes can certainly be used to analyze equations, in our effort to make them compatible with either data or functions, they could not exploit the convenience of the latter. Figure 22.1 shows pseudocodes that are expressly designed for cases where the func- tion is analytical. In particular, notice that neither the independent nor the dependent
  • 46. FlGURE 22.9 Algorithms for multiple appli- cations of the (a)trapezoidal and (b)Simpson's 113 rules, where the function is available. FIGURE 22.2 Absolute value of the true per- cent relative error versus number of segments for the determina- tion of the integral of fix) = 0.2 + 25x - 200x2 + 675x3 - 900x4 +400x5, evaluated from a = O to b = 0.8 using the multiple- application trapezoidal rule and the multiple-application Sirnp- son's 1/3 rule. Note that both results indicate that for a large number of segments, round-off errors limit precision. 22.1 NEWTON-COTESALGORITHMS F O R EQUATIONS 611 (a) FUNCTION TrapEq (n, a, b) h = ( b - a ) / n x = a sum = f(x) D O i = 1 , n - 1 x = x + h sum = sum +2 a (x) END DO sum = sum +f(b) TrapEq = ( b - a) a sum / (2 * n) END TrapEq (61 FUNCnON 5impEq (n, a, b) h = ( b - a ) / n x = a sum = (x) D O i = ? , n - 2,2 x = x + h sum = sum +4 a(x) x = x + h sum = sum +2 xf(x) END DO x = x + h sum = sum +4 ( x ) sum = sum +f(b) 5impEq = (b - a ) * sum / (3 n) END 5impEq
  • 47. 612 INTEGRATIONO F EQUATIONS variable values are passed into the function via its argument as was the case for the codes in Chap. 21. For the independent variable x, the integration interval (a,b) and the number of segments are passed. This information is then employed to generate equispaced values of x within the function. For the dependent variable, the function values in Fig. 22.1 are computed using calls to the function being analyzed,f(x). We developed single-precision programs based on these pseudocodes to analyze the effort involved and the errors incurred as we progressively used more segments to esti- mate the integral of a simple function. For an analytical function, the error equations [Eqs. (21.13) and (21.19)] indicate that increasing the number of segments n will result in more accurate integral estimates. This observation is borne out by Fig. 22.2, which is a plot of true error versus n for the integral of f(x) = 0.2 + 25x - 200x2 + 675x3 - 900x4 + 400x5.Notice how the error drops as n increases. However, also notice that at large values of n, the error starts to increase as round-off errors begin to dominate. Also observe that a very large number of function evaluations (and, hence, computational effort) is required to attain high levels of accuracy. As a consequence of these shortcomings, the multiple- application trapezoidal rule and Simpson's rules are sometimes inadequate for problem contexts where high efficiency and low errors are needed. Romberg integration is one technique that is designed to attain efficient numerical integrals of functions. It is quite similar to the techniques discussed in Chap. 21, in the sense that it is based on successive application of the trapezoidal rule. However, through mathematical manipulations, superior results are attained for less effort. 22.2.1 Richardson's Extrapolation Recall that, in Sec. 10.3.3, we used iterative refinement to improve the solution of a set of simultaneous linear equations. Error-correction techniques are also available to improve the results of numerical integration on the basis of the integral estimates themselves. Gen- erally called Richardson's extrapolation, these methods use two estimates of an integral to compute a third. more accurate approximation. The estimate and error associated with a multiple-application trapezoidal rule can be represented generally as where I = the exact value of the integral, I(h) = the approximation from an n-segment ap- plication of the trapezoidal rule with step size h = (b - a)/n, and E(h) = the truncation error. If we make two separate estimates using step sizes of hl and h2 and have exact val- ues for the error, Now recall that the error of the multiple-application trapezoidal rule can be represented ap- proximately by Eq. (21.13) [with rz = (b - a)/h]: h - a ? h 2 7 (22.2)
  • 48. 22.2 ROMBERG INTEGRATION 613 If it is assumed that j " is constant regardless of step size, Eq. (22.2)can be used to deter- mine that the ratio of the two errors will be This calculation has the important effect of removing the term f from the computation. In so doing, we have made it possible to utilize the information embodied by Eq. (22.2)with- out prior knowledge of the function's second derivative. To do this, we rearrange Eq. (22.3) to give which can be substituted into Eq. (22.1): which can be solved for Thus, we have developed an estimate of the truncation error in terms of the integral esti- mates and their step sizes. This estimate can then be substituted into I = l(hz)+E(h2) to yield an improved estimate of the integral: It can be shown (Ralston and Rabinowitz, 1978) that the error of this estimate is 0(h4). Thus, we have combined two trapezoidal rule estimates of 0(h2)to yield a new estimate of O(h4).For the special case where the interval is halved (h2= h1/2),this equation becomes or, collecting terms, EXAMPLE 22.1 Error Corrections of the Trapezoidal Rule Problem Statement. In the previous chapter (Example 21.1 and Table 21.1), we used a variety of numerical integration methods to evaluate the integral of f(x-) = 0.2 + 251-- 200x2 + 675x3 - 900x4 +400x5 from a = 0 to h = 0.8. For example, single and
  • 49. 614 INTEGRATIONO F EQUATIONS / multiple applications of the trapezoidal rule yielded the following results: Segments h Integral E,, % Use this information along with Eq. (22.5)to compute improved estimates of the integral. Solution. The estimates for one and two segments can be combined to yield The error of the improved integral is E, = 1.640533 - 1.367467 = 0.273067 ( 6 , = 16.6%),which is superior to the estimates upon which it was based. In the same manner, the estimates for two and four segments can be combined to give Equation (22.4)provides a way to combine two applications of the trapezoidal rule with error 0(h2)to compute a third estimate with error 0(h4).This approach is a subset of a more general method for combining integrals to obtain improved estimates. For in- stance, in Example 22.1, we computed two improved integrals of 0(h4)on the basis of three trapezoidal rule estimates. These two improved estimates can, in turn, be combined to yield an even better value with 0(h6).For the special case where the original trape- zoidal estimates are based on successive halving of the step size, the equation used for 0(h6)accuracy is where I, and II are the more and less accurate estimates, respectively. Similarly, two 0(h6) results can be combined to compute an integral that is O(hs)using EXAMPLE 22.2 Higher-Order Error Correction of Integral Estimates Problem Statement. In Example 22.1, we used Richardson's extrapolation to compute two integral estimates of 0(h4).Utilize Eq. (22.6)to combine these estimates to compute an integral with 0(h6).
  • 50. 22.2 ROMBERGINTEGRATION 615 Solution. The two integral estimates of O(h4)obtained in Example 22.1 were 1.367467 and 1.623467. These values can be substituted into Eq. (22.6)to yield I which is the correct answer to the seven significant figures that are carried in this example. 2 2 . 2 . 2 The Romberg integration Algorithm Notice that the coefficients in each of the extrapolation equations [Eqs. (22.5),(22.6),and (22.7)]add up to 1. Thus, they represent weighting factors that, as accuracy increases, place relatively greater weight on the superior integral estimate. These formulations can be expressed in a general form that is well-suited for computer implementation: where I,+,, k-1 and I,,k-1 = the more and less accurate integrals, respectively, and I,,J = the improved integral. The index k signifies the level of the integration, where k = I corre- sponds to the original trapezoidal rule estimates, k = 2 corresponds to 0(h4)), k = 3 to O(hb), and so forth. The indexj is used to distinguish between the more ( B + 1) and the less ( j )accurate estimates. For example, for k = 2 andj = 1,Eq. (22.8)becomes which is equivalent to Eq. (22.5). The general form represented by Eq. (22.8)is attributed to Romberg, and its system- atic application to evaluate integrals is known as Romberg inregration. Figure 22.3 is a graphical depiction of the sequence of integral estimates generated using this approach. Each matrix corresponds to a single iteration. The first column contains the trapezoidal rule FIGURE 22.3 Graphical depiction of the O(h2) O(h4) sequence of integral estimates (4 0.172800 1 367467 generated using Rornberg 1 068800 ~ntegration.
  • 51. 616 INTEGRATIONO F EQUATIONS evaluations that are designated Ij,~, where j = 1 is for a single-segment application (step size is b - a),j = 2 is for a two-segment application [step size is (b - a)/2], j = 3 is for a four-segment application [step size is (b - a)/4], and so forth. The other columns of the matrix are generated by systematically applying Eq. (22.8) to obtain successively better es- timates of the integral. For example, the first iteration (Fig. 22.3~) involves computing the one- and two- segment trapezoidal rule estimates and 12,1).Equation (22.8) is then used to compute the element = 1.367467, which has an error of 0(h4). Now, we must check to determine whether this result is adequate for our needs. As in other approximate methods in this book, a termination, or stopping, criterion is required to assess the accuracy of the results. One method that can be employed for the present pur- poses is [Eq. (3.5)] where E, = an estimate of the percent relative error. Thus, as was done previously in other iterative processes, we compare the new estimate with a previous value. When the change between the old and new values as represented by E, is below a prespecified error criterion E,, the computation is terminated. For Fig. 22.3a, this evaluation indicates an 87.4 percent change over the course of the first iteration. The object of the second iteration (Fig. 22.3b) is to obtain the 0(h6)estimate-Il,s. To do this, an additional trapezoidal rule estimate,13,~ = 1.4848, is determined. Then it is com- bined with 12,1 using Eq. (22.8) to generate 12,~ = 1.623467.The result is, in turn, combined FIGURE 22.4 Pseudocode for Romberg integration that uses the equal-size-segmentversion of the trapezoidal rule from Fig. 22. 1 . FUNCnON Rhomberg (a, b, maxit, es) LOCAL 1(10,10) n = 1 /?,I = TrapEq(n, a, b) iter = 0 DO iter = iter + 1 ,= 2iter /iter+l,l = TrapEq(n, a, b) DO k = 2, iter + 1 j = 2 + iter - k 1. ~ , k - - (4k-I * $+,,k-l - $,k-l) / (4k-I - 1) END DO ea = ABS((ll,itcr+l - 11,iter)/ Il,iter+l) 100 i f (iter 2 maxit OR ea S es) EXIT END DO Rhomberg = /l,iter+l END Rhomberg
  • 52. 22.3 GAUSS QUADRATURE 617 with 11,2to yield Ils = 1.640533. Equation (22.9) can be applied to determine that this result represents a change of 22.6 percent when compared with the previous result 1 1 ~ 2 . The third iteration (Fig. 22.3~) continues the process in the same fashion. In this case, a trapezoidal estimate is added to the first column, and then Eq. (22.8) is applied to com- pute successively more accurate integrals along the lower diagonal. After only three itera- tions, because we are evaluating a fifth-order polynomial, the result (11,4 = 1.640533) is exact. Romberg integration is more efficient than the trapezoidal rule and Simpson's rules discussed in Chap. 21. For example, for determination of the integral as shown in Fig. 22.1, Simpson's 1/3 rule would require a 256-segment application to yield an estimate of 1.640533. Finer approximations would not be possible because of round-off error. In con- trast, Romberg integration yields an exact result (to seven significant figures) based on combining one-, two-, four-, and eight-segment trapezoidal rules; that is, with only 15 function evaluations! Figure 22.4 presents pseudocode for Romberg integration. By using loops, this algo- rithm impleme~lts the method in an efficient manner. Romberg integration is designed for cases where the function to be integrated is known. This is because knowledge of the func- tion permits the evaluations required for the initial implementations of the trapezoidal rule. Tabulated data is rarely in the form needed to make the necessary successive halvings. GAUSS QUADMTURE In Chap. 21, we studied the group of numerical integration or quadrature formulas known as the Newton-Cotes equations. A characteristic of these formulas (with the exception of the special case of Sec. 21.3) was that the integral estimate was based on evenly spaced function values. Consequently, the location of the base points used in these equations was predetermined or fixed. For example, as depicted in Fig. 22.5a, the trapezoidal rule is based on taking the area under the straight line connecting the function values at the ends of the integration interval. The formula that is used to compute this area is where a and b = the limits of integration and b - a = the width of the integration inter- val. Because the trapezoidal rule must pass through the end points, there are cases such as Fig. 22.5a where the formula results in a large error. Now, suppose that the constraint of fixed base points was removed and we were free to evaluate the area under a straight line joining any two points on the curve. By position- ing these points wisely, we could define a straight line that would balance the positive and negative errors. Hence, as in Fig. 22.56, we would arrive at an improved estimate of the integral. Gauss quadrature is the name for one class of techniques to implement such a strat- egy. The particular Gauss quadrature formulas described in this section are called Gauss- Legendl-e formulas. Before describing the approach, we will show how numerical in- tegration formulas such as the trapezoidal rule can be derived using the method of
  • 53. INTEGRATION O F EQUATIONS FlGURE 22.5 (a)Graphical depiction of the trapezoidal rule as the area under the straight line ioining fixed end points. (b)An improved integral estimate ob- tained by taking the area under the straight line passing through two intermediate points. By po- sitioning these points wisely, the ositive and negative errors are Lalance, and an improved in- tegral estimate results. undetermined coefficients. This method will then be employed to develop the Gauss- Legendre formulas. 22.3.1 Method of Undetermined Coefficients In Chap. 21, we derived the trapezoidal rule by integrating a linear interpolating polynomial and by geometrical reasoning. The method of undetermined coefficients offers a third ap- proach that alsohas utility in deriving other integrationtechniques such as Gauss quadrature. To illustrate the approach, Eq. (22.10) is expressed as where the c's = constants. Now realize that the trapezoidal rule should yield exact results when the function being integrated is a constant or a straight line. Two simple equations that represent these cases are y = 1 and y = x. Both are illustrated in Fig. 22.6. Thus, the following equalities should hold: C O + C ~ = 1 dx and
  • 54. 22.3 GAUSS QUADRATURE 6 19 FlGURE 22.6 Two integrals that should be evaluated exactly by the trapezoidal rule: (a)a constant and (b)a straight line. or, evaluating the integrals, and b - a b - a -Co -+cl2=O 2 These are two equations with two unknowns that can be solved for b - a Co = C1 = -- 2 which, when substitutedback into Eq. (22.1I), gives b - a b - a I = -f(a) + T f ( b ) 2 which is equivalent to the trapezoidal rule.
  • 55. 620 INTEGRATIONOF EQUATIONS 22,3.2 Derivationof the Tvvo-Point Gauss-Legendre Formula Just as was the case for the above derivation of the trapezoidal rule, the object of Gauss quadrature is to determine the coefficients of an equation of the fonn where the c's = the unknown coefficients. However, in contrast to the trapezoidal rule that used fixed end points a and b, the function arguments xo and xl are not fixed at the end points, but are unknowns (Fig. 22.7). Thus, we now have a total of four unknowns that must be evaluated, and consequently, we require four conditions to determine them exactly. Just as for the trapezoidal rule, we can obtain two of these conditions by assuming that Eq. (22.12)fits the integral of a constant and a linear function exactly. Then, to arrive at the other two conditions, we merely extend this reasoning by assuming that it also fits the in- tegral of a parabolic (y = 2) and a cubic (y = x3)function. By doing this, we determine all four unknowns and in the bargain derive a linear two-point integration formula that is exact for cubics. The four equations to be solved are cof(xo) +cl f(x1) = (22.13) cof(xo) f cl f(x1) = (22.14) FIGURE 22.7 Graphical depiction of the unknown variables xo and X I for integration by Gauss quadrature
  • 56. 22.3 GAUSS QUADRATURE 621 Equations (22.13) through (22.16) can be solved simultaneously for which can be substituted into Eq. (22.12) to yield the two-point Gauss-Legendre formula Thus, we arrive at the interesting result that the simple addition of the function values at x = 1/& and -I/& yields an integral estimate that is third-order accurate. Notice that the integrationlimits in Eqs. (22.13)through (22.16) are from -1to 1.This was done to simplify the mathematics and to make the formulation as general as possible. A simple change of variable can be used to translate other limits of integration into this form. This is accomplished by assuming that a new variable xd is related to the original variablex in a linear fashion, as in X = a0 $. alxd (22.18) If the lower limit, x = a, corresponds to x d = -1, these values can be substituted into Eq. (22.18) to yield a = ao +al(-1) (22.19) Similarly,the upper limit, x = b, corresponds to x d = 1,to give b = ag +al(l) (22.20) Equations (22.19) and (22.20) can be solved simultaneouslyfor and b - a a1 = - 2 which can be substituted into Eq. (22.18) to yield This equation can be differentiated to give h - a dx = - 2 dxd Equations (22.23) and (22.24) can be substituted for x and dx,respectively,in the equation to be integrated. These substitutions effectively transform the integration interval without
  • 57. 22.3 GAUSS QUADRATURE 621 Equations (22.13)through (22.16)can be solved simultaneously for which can be substituted into Eq. (22.12)to yield the two-point Gauss-Legendre formula Thus, we arrive at the interesting result that the simple addition of the function values at x = I /& and -1/& yields an integral estimate that is third-order accurate. Notice that the integration limits in Eqs. (22.13)through (22.16)are from -1to 1.This was done to simplify the mathematics and to make the formulation as general as possible. A simple change of variable can be used to translate other limits of integration into this form. This is accomplished by assuming that a new variable xd is related to the original variable x in a linear fashion, as in x = a0 +alxd (22.18) If the lower limit, x = a, corresponds to xd = -1, these values can be substituted into Eq. (22.18)to yield a =ao +al(-1) (22.19) Similarly, the upper limit. x = b, corresponds to xd = 1,to give b = a o f a ~ ( l ) (22.20) Equations (22.19)and (22.20)can be solved simultaneously for and b - a a] = - 2 which can be substituted into Eq. (22.18)to yield This equation can be differentiated to give Equations (22.23)and (22.24)can be substituted for s and ds,respectively, in the equation to be integrated. These substitutions effectively transform the integration interval without
  • 58. 622 INTEGRATIONO F EQUATIONS changing the value of the integral. The following example illustrates how this is done in practice. EXAMPLE 22.3 Two-Point Gauss-Legendre Formula I Problem Statement. Use Eq. (22.17) to evaluate the integral of I between the limits x = 0 to 0.8. Recall that this was the same problem that we solved in 1 Chap. 21 using a variety of Newton-Cotes formulations. The exact value of the integral is 1 1.640533. Solution. Before integrating the function, we must perform a change of variable so ; that the limits are from -1 to +1. To do this, we substitute a = 0 and b = 0.8 into i Eq. (22.23) to yield The derivative of this relationship is [Eq. (22.24)] Both of these can be substituted into the original equation to yield Therefore, the right-hand side is in the form that is suitable for evaluation using Gauss quadrature. The transformed function can be evaluated at -l / f i to be equal to 0.516741 and at 1/& to be equal to 1.305837. Therefore, the integral according to Eq. (22.17) is which represents a percent relative error of -11.1 percent. This result is comparable in magnitude to a four-segment application of the trapezoidal rule (Table 21.1) or a single ap- plication of Simpson's 113 and 318 rules (Examples 21.4 and 21.6). This latter result is to be expected because Simpson's rules are also third-order accurate. However, because of the clever choice of base points, Gauss quadrature attains this accuracy on the basis of only two function evaluations. 2 2 . 3 . 3 Higher-Point Formulas Beyond the two-point formula described in the previous section, higher-point versions can be developed in the general form
  • 59. 22.3 GAUSS QUADRATURE 623 TABLE 22.1 Weighting factors c and function arguments x used in Gauss-Legendre formulas. u - Weighting Funcgon Truncatisn Points Factors Arguments Error 2 co = 1 .OOOOOOO xo = -0.577350269 =/141(5) c i = 1 0 0 0 0 0 0 0 X I = 0.577350269 3 co = 0.5555556 xo = -0.774596669 = f i 6 l l ( ) c l = 0.8888889 XI= 0.0 q = 0.5555556 x2 = 0.774596669 4 co = 03 4 7 8 5 4 8 xo = -0.86 1 1 3 6 312 ~f 181[() cj = 0.6521 4 5 2 XI = -03 3 9 9 81 0 4 4 c : ! = 0.652 1 4 5 2 X>= 0339981044 cg = 0.3478548 X , = 0 . 8 6 1 1 3 6 312 co = 0 . 2 3 6 9 2 6 9 xo = -0.906 1 7 9 8 4 6 = f l ' O l [ { ) c i = 0.4786287 x i = -0.5384693 1 0 c : ,= 0.5688889 x2 = 0.0 cg = 0.4786287 x 3 = 0.538469310 ~4= 0.2369269 x 4 = 0.906179846 co= 0.171 3 2 4 5 xo = -0.9324695 1 4 =f112)(~) cl = 0 . 3 6 0 7 6 1 6 X I = -0.661 2 0 9 3 8 6 c2 = 0.4679 1 3 9 x , = - 0 . 2 3 8 6 1 9 18 6 cg = 0.4679 1 3 9 x3 = 0.238619186 cq = 0 . 3 6 0 7 6 1 6 x4 = 0 . 6 6 1 2 0 9 3 8 6 c g = O 1 7 1 3 2 4 5 x5 = 0.9324695 1 4 where n = the number of points. Values for c's andx's for up to and including the six-point formula are summarized in Table 22.1. EXAMPLE 22.4 Three-Point Gauss-Legendre Formula i Problem Statement. Use the three-point formula from Table 22.1 to estimate the inte- i I gral for the same function as in Example 22.3. ! Solution. According to Table 22.1, the three-point formula is 1 I = 0,5555556f(-0.7745967) +0.8888889f(0) +0.5555556f(0.7745967) I which is equal to I = 0.2813013 +0.8732444 +0.4859876 = 1.640533 "hich is exact. i Because Gauss quadrature requires function evaluations at nonuniformly spaced points within the integration interval, it is not appropriate for cases where the function is unknown. Thus, it is not suited for engineering problems that deal with tabulated data. However, where the function is known, its efficiency can be a decided advantage. This is particularly true when numerous integral evaluations must be performed.
  • 60. 624 INTEGRATIONO F EQUATIONS EXAMPLE 22.5 Applying Gauss Quadrature to the Falling Parachutist Problem I Problem Statement. In Example 21.3, we used the multiple-application trapezoidal i where g = 9.8, c = 12.5,and m = 68.1.The exact value of the integral was determinedby calculus to be 289.4351.Recall that the best estimate obtained using a 500-segment trape- I zoidal rule was 289.4348 with an 2 1.15 x lo-' percent. Repeat this computation 1 using Gauss quadrature. / Solution. After modifying the function, the following results are obtained: Two-point estimate = 290.0145 Three-point estimate = 289.4393 Four-pointestimate = 289.4352 Five-point estimate = 289.4351 Six-point estimate = 289.4351 1 Thus, the five- and six-point estimates yield results that are exact to seven significant t ' figures. i 22.3.4 Error Analysis For Gauss Quadrature The error for the Gauss-Legendreformulas is specified generallyby (Carnahanet al., 1969) where n = the number of points minus one andf (2n+2)(t) = the (2n +2)th derivative of the function after the change of variable with 6located somewhere on the interval from -1 to 1.Comparison of Eq. (22.26) with Table 21.2 indicates the superiority of Gauss quadra- ture to Newton-Cotes formulas, provided the higher-order derivatives do not increase sub- stantially with increasing n. Problem 22.8 at the end of this chapter illustrates a case where the Gauss-Legendre formulas perform poorly. In these situations, the multiple-application Simpson's rule or Romberg integration would be preferable. However, for many functions confronted in engineering practice, Gauss quadratureprovides an efficientmeans for eval- uating integrals. 2 2 . 4 IMPROPER INTEGRALS - - - To this point, we have dealt exclusively with integrals having finite limits and bounded in- tegrands. Although these types are commonplace in engineering, there will be times when improper integrals must be evaluated. In this section we will focus on one type of improper integral-that is, one with a lower limit of -m or an upper limit of +m. Suchintegralsusually can be evaluatedby making a change of variable that transforms the infinite range to one that is finite. The following identity serves this purpose and works
  • 61. 22.4 I M P R O P E R INTEGRALS 625 for any functionthat decreasestoward zeroat leastas fastas1/.x2asx approachesinfinity: for ab > 0. Therefore, it can be used only when a is positive and b is a,or when a is -00 and b is negative. For cases where the limits are from -cm to a positive value or from a negative value to cm,the integral can be implemented in two steps. For example, (22.28) where -A is chosen as a sufficientlylarge negative value so that the function has begun to approach zero asymptotically at least as fast as 1/x2.After the integral has been divided into two parts, the first can be evaluated with Eq. (22.27) and the second with a Newton- Cotes closed formula such as Simpson's 1/3 rule. One problem with using Eq. (22.27) to evaluate an integral is that the transformed function will be singular at one of the limits. The open integration formulas can be used to circumvent this dilemma as they allow evaluation of the integral withoutemployingdata at the end points of the integration interval. To allow the maximum flexibility, a multiple- application version of one of the open formulas from Table 21.4 is required. Multiple-applicationversions of the open formulas can be concocted by using closed formulasfortheinteriorsegmentsandopen formrllasfortheends.Forexample,themultiple- segment trapezoidal rule and the midpoint rule can be combined to give In addition, semiopenformulas can be developed for cases where one or the other end of the interval is closed. For example, a formula that is open at the lower limit and closed at the upper limit is given as Although these relationships can be used, a preferred formula is (Press et at., 1986) which is called the extended midpointrule. Notice that this formula is based on limits of in- tegration that are h/2 after and before the first and last data points (Fig. 22.8). FIGURE 22.8 Placement of data points relative to integration limits for the extended midpoint rule.
  • 62. INTEGRATIONO F EQUATIONS EXAMPLE 22.6 Evaluation of an Improper Integral : Problem Statement. The cumulative normal distribution is an important formula in statistics (see Fig. 22.9): FIGURE 22.9 (a)The normal d~strlbutlon, (b)the transformed abscissa ~nterms of the standardized normal devi- ate, and (c)the cumulative normal distr~butionThe shaded area in (a)and the po~nt ~n(c)repre sent the probab~llty that a ra~dom event will be less than the mean plus one standard dev~atron
  • 63. 22.4 IMPROPERINTEGRALS 621 where x = (y - E;)/sy is called the normalized standard deviate. It represents a change of variable to scale the normal distribution so that it is centered on zero and the distance along the abscissa is measured in multiples of the standard deviation (Fig. 22.9b). Equation (E22.6.1) represents the probability that an event will be less than x. For ex- ample, if x = 1,Eq. (E22.6.1) can be used to determine that the probability that an event will occur that is less than one standard deviation above the mean is N(l) = 0.8413. In other words,if 100events occur,approximately84will be less than the mean plus one stan- dard deviation. Because Eq. (E22.6.1) cannot be evaluated in a simple functional form, it is solved numerically and listed in statistical tables. Use Eq. (22.28) in conjunction with Simpson's 1/3 rule and the extended midpoint rule to determine N(l) numerically. Solution. Equation (E22.6.1) can be re-expressed in terms of Eq. (22.28) as The first integral can be evaluated by applying Eq. (22.27) to give Then the extended midpoint rule with h = 1/8 can be employed to estimate Simpson's 1/3 rule with h = 0.5 can be used to estimate the second integral as Therefore, the final result can be computed as which represents an error of E* = 0.046 percent. The foregoing computation can be improved in a number of ways. First, higher-order formulas could be used. For example, a Romberg integration could be employed. Second, more points could be used. Press et al. (1986) explore both options in depth. Aside from infinite limits, there are other ways in which an integral can be improper. Common examples include cases where the integral is singular at either the limits or at a point within the integral. Press et al. (1986) provide a nice discussion of ways to handle these situations.