Download as pdf or txt
Download as pdf or txt
You are on page 1of 41

ESDU

TM

85046
Issued December 1985
Engineering Sciences Data Unit
An IHS GROUP Company With Amendments A to C
July 2002
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

Quadrature methods for the


evaluation of definite integrals

Associated software: ESDUpac A8546


VIEWpac 8546A

Endorsed by
The Royal Aeronautical Society
ESDU 85046
TM

Engineering Sciences Data Unit

ESDU DATA ITEMS

Data Items provide validated information in engineering design and analysis for use by, or under the supervision of,
professionally qualified engineers. The data are founded on an evaluation of all the relevant information, both published and
unpublished, and are invariably supported by original work of ESDU staff engineers or consultants. The whole process is
subject to independent review for which crucial support is provided by industrial companies, government research
laboratories, universities and others from around the world through the participation of some of their leading experts on ESDU
Technical Committees. This process ensures that the results of much valuable work (theoretical, experimental and
operational), which may not be widely available or in a readily usable form, can be communicated concisely and accurately
to the engineering community.
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

We are constantly striving to develop new work and review data already issued. Any comments arising out of your use of our
data, or any suggestions for new topics or information that might lead to improvements, will help us to provide a better service.

THE PREPARATION OF THIS DATA ITEM

The work on this particular Data Item was monitored and guided by the Dynamics Committee. This Committee first met in
1962 and now has the following membership:

Chairman
Dr H.H.B.M. Thomas — Independent

Members
Prof. G.T.S. Done — The City University, London
Prof. N.D. Ham — MIT, Cambridge, Mass., USA
Prof. G.J. Hancock — Queen Mary College, London University
Mr M.R. Heath — British Aerospace Dynamics Group, Stevenage
Dr M.A. Woodhead — University of Salford.

The construction and subsequent development of the Data Item was undertaken by

Mr C.J. Loughton — Group Head.

The person with overall responsibility for the work in this subject area is Mr C.J. Loughton, Head of Mechanical Motion and
System Dynamics Group.
ESDU 85046
TM

Engineering Sciences Data Unit

QUADRATURE METHODS FOR THE EVALUATION OF DEFINITE INTEGRALS

CONTENTS
Page

1. INTRODUCTION 1
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

2. NOTATION 2

3. QUADRATURE FORMULAE FOR FINITE INTEGRALS 3


3.1 Newton-Cotes Formulae 5
3.2 Gauss-Legendre Formulae 8
3.3 Multiple Integrals 9

4. ADAPTIVE QUADRATURE 11

5. IMPROPER INTEGRALS 14
5.1 Infinite Integrand 14
5.2 Infinite Limits 15
5.2.1 Gauss-Laguerre formulae 15
5.2.2 Gauss-Hermite formulae 16

6. REFERENCES 18

7. DESCRIPTION OF COMPUTER PROGRAM 19


7.1 Executable VIEWpac Program 8546A 20
7.2 Fortran Executable Program A8546 20
7.3 Fortran Source Code Program A8546 20
7.3.1 Compiling and linking program A8546 21
7.3.2 Running program A8546 21
7.4 Program Input Data 22
7.4.1 Arithmetic operators and intrinsic functions 23
7.4.2 Program control settings 24
7.5 Program Output Data 24
7.5.1 Program error messages 24
7.6 Program Application 27

8. EXAMPLES 28
8.1 Example 1 – Single Definite Integral 28
8.2 Example 2 – Double Definite Integral 30
8.3 Example 3 – Double Integral with Definite Outer and Variable Inner Limits 32

This page Amendment C


i
ESDU 85046
TM

Engineering Sciences Data Unit

9. PROGRAM ACCESSIBILITY AND INSTALLATION 35


9.1 Hardware Requirements 35
9.2 Accessibility 35
9.3 Installation 35
9.3.1 Executable VIEWpac program 8546A 35
9.3.2 Fortran executable program A8546 35
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

This page Amendment C


ii
ESDU 85046
TM

Engineering Sciences Data Unit

QUADRATURE METHODS FOR THE EVALUATION OF DEFINITE INTEGRALS

1. INTRODUCTION

The present Item considers the numerical evaluation of a definite integral of the form

b
∫ a f ( x ) dx ,
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

where the function f ( x ) is known analytically.

In cases where the indefinite integral, ∫ f ( x ) dx , can be expressed in terms of well-known simple algebraic
or trigonometrical functions, evaluation of the definite integral is straightforward. In other cases it may be
difficult or indeed impossible to evaluate an integral by analytical means and for such cases numerical
methods are used. The extension of these methods to multiple integrals is also considered.

Frequently the function to be integrated is only specified by a number of discrete values of the function at
stations within the range of integration. Such cases usually arise from experimental data and can be treated,
for example, by fitting a least-squares curve through the data and integrating the resulting curve. This
general topic, and others associated with curve fitting, is not considered in this Item.

Numerous numerical integration formulae have been devised. Those finding most common application are
formulae in which the definite integral is expressed solely in terms of the integrand, f(x), at selected values
of the variable, x. A common feature of these methods is the essential approximation of the function, f(x),
by a polynomial of a certain degree over the range of integration or a part thereof.

Two main classes of formulae worthy of more detailed description are described in the text. The first
comprises the Newton-Cotes formulae wherein the selected values of the independent variable are usually
chosen to be equally spaced across the integration range. The second class of formulae are termed Gaussian,
in which the intervals in x are determined by the condition that the integration formulae have the highest
possible degree of accuracy within the limits set by the total number of stations. Selected sources of
information supplementary to that in this Item are References 1 to 4 and 6 to 11.

The compromise between effort expended and accuracy of results is of considerable importance and so is
discussed in this Item.

A problem that may occasionally arise is that it is desired to integrate up to or across a singularity of the
integrand. No general method of coping with this is forthcoming, but some guidance is given in the Item.

Organisations having access to reasonably powerful computation facilities may have ready access to some
suitable library programs for evaluating definite integrals. However, to cater for the needs of people not so
placed, a computer program is provided and is described in Section 7 of this Item. Examples illustrating
the use of the program are given in Section 8.

Issued December 1985 - 40 pages


With Amendments A to C, July 2002 – 35 pages
This page Amendment C
1
ESDU 85046
TM

Engineering Sciences Data Unit

2. NOTATION

a, b constant limits of definite single integral or constant outer limits of double integral

a, b constant limits of part of definite single integral

c, d constant inner limits of double integral

c( x), d(x) variable inner limits of double integral


ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

(i )
f ith derivative of function f

f, g general functions

Hn ( x ) nth order Hermite polynomial as function of x

h step length

i, j, k variable integers

Li ( x ) ith order Lagrangian interpolation polynomial as function of x

Ln ( x ) nth order Laguerre polynomial as a function of x

l, m, n general integers

Pn ( x ) nth order Legendre polynomial as function of x

Rn remainder or error term used for nth order formula

S Simpson approximation

wi ith weighting factor

x, y, u independent variables

ε tolerance of approximation

ξ general variable

This page Amendment C

2
ESDU 85046
TM

Engineering Sciences Data Unit

3. QUADRATURE FORMULAE FOR FINITE INTEGRALS

The value of a definite integral of the form,

b
∫ a f ( x ) dx ,
is defined by the geometrical area bounded by the curve f(x), the ordinates at x = a and x = b and the x-axis
and is illustrated by the shaded area of Sketch 3.1.
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

60 f (x)
55
f (x) 50
45
40
35
30

I
b
25 f (x) dx
20 a

15
10
5
0
0 a
20 40 60 80 b
100 120 x 140

Sketch 3.1 Geometric illustration of single definite integral

Numerical integration or numerical quadrature approximates an integral by a properly weighted sum of the
values of the integrand at particular points on the interval of integration. The approximation is of the form

n
b
∫ a
f ( x ) dx ≈ ∑ wi f ( xi ) , (3.1)
i = 0

where it is required to specify the abscissae, x i , and the weights, wi , such that the right-hand side of
Equation (3.1) represents a good approximation to the left-hand side of the equation.

The basis of the approximation of Equation (3.1) is that the function f(x) is replaced by a function g(x)
where the functions f(x) and g(x) have identical values at the abscissae points, x i . The following may then
be written

n
b
∫ a
f ( x ) dx ≈ b g ( x ) dx =
∫a ∑ wi f ( xi ) , (3.2)
i = 0

in which the w i values are then evaluated such that the integral involving g(x) is exact. An illustration of
f(x) and its approximating function g(x) is given in Sketch 3.2 where the shaded area is the integral of g(x)
between x = a and x = b .

Any quadrature formulae, of the form of Equation (3.1), should be capable of approximating definite
This page Amendment C

3
ESDU 85046
TM

Engineering Sciences Data Unit

integrals of any function within a margin of error that will diminish, in general, as n is increased. In fact if
f(x) is a polynomial of a certain degree then Equation (3.1) can be made exact.

60

50
f (x) and g(x)
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

40

f (x)
30

I
b
20 g(x) dx g(x)
a

10

0
0 a 20 x1 40 x2 60 80 100 120b x
140

Sketch 3.2 Illustration of f(x) and g(x)

Two general approaches are possible when applying the quadrature formula of Equation (3.1) for an integral
of a function on the interval (a, b). Either a single formula may be used over the complete interval or the
interval may be subdivided and a single formula used in each subinterval. In the latter case, if it is assumed
that the subintervals are equal and that the same formula is used in each, the right-hand side of Equation (3.1)
may be re-expressed in a COMPOSITE form as

n m–1 l
∑ wi f ( xi ) = ∑ ∑ wk f ( x k + jh ) , (3.3)
i = 0 j = 0 k = 0

where m is the number of subintervals, h = (b – a)/m and (l + 1) is the number of points used in each
subinterval.

The quadrature formulae in this Item are presented, in general, for integration over a subinterval, or element
( a, b ) , of a complete integration interval (a, b). The use of such an element recognises the “building-block”
approach, where quadrature formulae are usually applied to subintervals of the complete interval (a, b).

A quadrature formula is defined as one for which the particular choice of the weights and abcissae is such
that, when f(x) is a polynomial of order n, the formula is exact. The simplest approach to the choice is to
specify evenly-spaced abscissae values along the integration interval (a, b) and choose weight values to
give the best approximation. The formulae that result are commonly termed Newton-Cotes formulae and
are discussed in Section 3.1. Section 3.2 presents an alternative approach where the abscissae are chosen
in such a way that the accuracy is improved.

This page Amendment C

4
ESDU 85046
TM

Engineering Sciences Data Unit

3.1 Newton-Cotes Formulae

For equally-spaced abscissae values for an element ( a, b ) , Equation (3.1) may be rewritten as

n

b
a
f ( x ) d( x ) ≈ ∑ w i f ( a + ih ) , (3.4)
i = 0

where the abscissa interval or step length, h, is given by h = ( b – a )/n .


ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

From Equation (3.4) it can be seen that ( n + 1 ) w i values are calculated assuming that the approximate
function g(x) is a polynomial of order n. When g(x) is any function the terms of which are of the form

g( x ) = xj , j = 0, 1, 2, ...., n

and is substituted into Equation (3.4), then the (n + 1) unknown weights can be found from the (n + 1)
equations given by

n
b j j
∫a x dx = ∑ w i ( a + ih ) , j = 0, 1, 2 , … , n . (3.5)
i = 0

An alternative expression for the weights that is easier to solve is

n ( x – xj )
∫a ∏
b b
wi =
∫a L i ( x ) dx = --------------------- dx ,
( xi – xj )
(3.6)
j = 0
j ≠ i

where i = 0, 1, 2, ...., n and L ( x ) is the Lagrangian interpolation polynomial corresponding to the


abscissae a, a + h, a + 2h, ...., b .

The two most frequently used classes of integration formulae are termed CLOSED formulae, which use
information about f(x) at both the extreme points, a and b , and OPEN formulae, which do not require
information on f(x) at either of these points; for this latter class the weights w 0 and w n are both zero.

Comparison of the open and closed formulae, which use the same number of computed function evaluations,
indicates that the closed formulae are considerably more accurate and so they are almost always used in
preference to the open type. For this reason only the Newton-Cotes closed formulae are presented in this
Item.

Table 3.1 gives these formulae for n values from 1 to 7 and includes the error or remainder term, R n , for
each formula.

It can be seen from Table 3.1 that the Newton-Cotes formulae of closed type for n values of 1 and 2 are the
familiar Trapezoidal and Simpson’s Rules respectively, which, it can be noted, may be obtained by
approximating the function by fitting a linear function and a quadratic function respectively to the
integration interval ( a, b ) . When the complete integration interval, (a, b), is segmented into equal
subintervals and the same formula is used in each, an Extended or Composite formula is obtained. For the

This page Amendment C

5
ESDU 85046
TM

Engineering Sciences Data Unit

Trapezoidal Rule the composite formula is found to be

n–1
h  

b
a
f ( x ) dx ≈ ---  f ( x 0 ) + f ( x n ) + 2
2  ∑ f ( xi )  .

(3.7)
i = 1

The Extended or Composite Simpson’s Rule may similarly be shown to be

n–1 n–1
b h  
∫ f( x) dx ≈ ---  f ( x 0 ) + f ( x 2n ) + 4 ∑ f ( x 2i – 1 ) + 2 ∑ f ( x 2i )  , (3.8)
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

a 3 
i = 1 i = 1 

where it should be noted that the total abscissa interval has, for notation convenience, been subdivided into
2n equal parts, of step length h = (b – a)/2n. Similar composite expressions can be derived for any of the
Newton-Cotes formulae. The advantage of using a composite formula is that the approximation is
continually improved with each successive interval halving and the formula is, consequently, ideally suited
to computerisation.

Study of the error term for formulae that use an odd number of function evaluations, say n, and formulae
for (n + 1), show that both have the same order of accuracy. Thus the Simpson's rule (n = 2) has an accuracy
of degree 3. Similarly the Simpson's 3/8 rule (n = 3) has the same degree of precision but requires an extra
function evaluation. Consequently formulae using an odd number of function evaluations are normally to
be preferred.

Considering only the truncation error terms of the formulae, and ignoring rounding error, the use of a
high-order formula is, in general, more efficient than the use of a lower-order formula with more
subintervals. However, there is a limit to the accuracy achievable, since as the order of formula is increased
the higher derivatives of many functions tend to grow rapidly, for example exponential functions, ultimately
faster than the powers of h decrease, and so the use of the higher-order formulae is not recommended for
general work. Formulae employing more than seven points are rarely used.

Another class of formulae commonly encountered is derived by combining different order Newton-Cotes
formulae. Weddle's formula is an example of one of this class that involves the combination of Simpson's
rule (n = 2) and Simpson's 3/8 rule (n = 3). This rule uses seven weighted coefficients and will give exact
results if f(x) is a polynomial whose degree does not exceed 5. This is a much lower precision formula than
the corresponding formula of Newton-Cotes involving seven functional evaluations (n = 6). Weddle’s
formula has in the past been popular because of the simplicity of its coefficients. Although this formula is
not a member of the Newton-Cotes class it has been included for comparison in Table 3.1.

In the quadrature formulae discussed so far, values of the abscissae were chosen at equally spaced intervals.
The next section will discuss Gauss-Legendre quadrature, a commonly used class of Gaussian formulae,
which places no restriction on the values of the weights or abscissae that are used in Equation (3.1).

This page Amendment C

6
ESDU 85046
TM

Engineering Sciences Data Unit

TABLE 3.1 Newton-Cotes quadrature formulae (closed type)

n
b
∫ a
f ( x ) dx = ∑ w i f ( a + ih ) + R n
i = 0

b xn n ( x – xj )
wi =
∫a L i ( x ) dx =
∫x ∏
0
--------------------- dx
( xi – xj )
j = 0
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

j ≠ i

n
b
Name a b n ∫ a
f ( x ) dx ≈ ∑ w i f ( xi ) Rn
i = 0

3 (2)
Trapezoidal x0 x1 1 ( h/2 ) { f ( x0 ) + f ( x 1 ) } – ( h /12 )f ( ξ )
Rule a≤ξ≤b
5 (4)
Simpson’s x0 x2 2 ( h/3 ) { f ( x0 ) + 4f ( x 1 ) + f ( x2 ) } – ( h /90 )f ( ξ )
Rule a≤ξ≤b
5 (4)
Simpson’s x0 x3 3 ( 3h/8 ) { f ( x 0 ) + 3f ( x1 ) + 3f ( x 2 ) + f ( x3 ) } – ( 3h /80 )f ( ξ )
3/8 a≤ξ≤b

( 2h/45 ) { 7f ( x 0 ) + 32f ( x1 ) + 12f ( x2 ) 7 (6)


Bode’s 4 –( 8h /945 )f ( ξ )
x0 x4 + 32f ( x3 ) + 7f ( x4 ) }
Rule a≤ξ≤b
7 (6)
x0 x5 5 ( 5h/288 ) { 19f ( x0 ) + 75f ( x1 ) + 50f ( x2 ) –( 275h /12096 )f (ξ)
–––
+ 50f ( x3 ) + 75f ( x 4 ) + 19f ( x5 ) } a≤ξ≤b
9 (8)
x0 x6 6 ( h/140 ) { 41f ( x0 ) + 216f ( x1 ) + 27f ( x2 ) –( 9h /1400 )f (ξ)
––– + 272f ( x3 ) + 27f ( x4 ) + 216f ( x5 ) a≤ξ≤b
+ 41f ( x 6 ) }
9 (8)
( 7h/17280 ) { 751f ( x0 ) + 3577f ( x1 ) + 1323f ( x2 ) } –( 8183h /518400 )f ( ξ)
––– x0 x7 7 + 2989f ( x3 ) + 2989f ( x4 ) + 1323f ( x 5 ) a≤ξ≤b
+ 3577f ( x6 ) + 751f ( x7 ) }

Weddle’s x0 x6 5 ( 3h/10 ) { f ( x0 ) + 5f ( x1 ) + f ( x2 ) –
Rule + 6f ( x 3 ) + f ( x4 ) + 5 ( x5 ) + f ( x6 ) }

This page Amendment C

7
ESDU 85046
TM

Engineering Sciences Data Unit

3.2 Gauss-Legendre Formulae

The right-hand side of Equation (3.1) contains (2n + 2) unknowns, ( n + 1 ) w i 's and ( n + 1 ) xi 's , which is
sufficient to specify completely a polynomial of degree (2n + 1). When the approximating polynomial,
g(x), is of degree (2n + 1), then the constants, wi , i = 1 to (n + 1) and xi , i = 1 to (n + 1), are uniquely defined.

In a similar manner to the derivation of the Newton-Cotes formulae, g(x) is chosen to be any function the
terms of which are of the form

g( x ) = xj , j = 0, 1, 2, ......2n + 1 ,
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

which when substituted into Equation (3.1) gives


n
b
∫a x j dx = ∑ w i x ij , j = 0, 1, 2, ...., 2n + 1 . (3.9)
i = 0

Equation (3.9) provides (2n + 2) equations for evaluation of the (2n + 2) w i and xi unknowns. Gauss has
shown that if the integration interval ( a, b ) is converted to (–1, 1) by a suitable change of variable, then
the x i 's are roots of the Legendre polynomial of degree (n + 1). Consequently, if the weights are chosen to
satisfy Equation (3.9), then Equation (3.9) is exact for polynomials of degree (2n + 1).

Thus the Gauss-Legendre formula of degree n is given by

n–1
1
∫–1 f ( x ) dx ≈ ∑ wi f ( x i ) + R n , (3.10)
i = 0

where xi is the ith root of the Legendre polynomial, P n , of degree n, w i is the weight at the ith root and
Rn is the error term or remainder.

In practice it is not necessary to evaluate the weights and zeros of the Legendre polynomials since they are
extensively tabulated in the general literature. However for ease of reference Table 3.2 presents the roots
of the Legendre polynomials and the values of the corresponding weights for values of n up to 6.

TABLE 3.2 Gauss-Legendre weights and abscissae


n xi wi
2 ± 1/ 3 1
0 8/9
3
± 3/5 5/9
± 0.86113631 0.3478548451
4
± 0.33998104 0.6521451549
± 0.90617985 0.2369268851
5 ± 0.53846931 0.4786286705
0.0 0.5688888889
± 0.93246951 0.1713244924
6 ± 0.66120939 0.3607615730
± 0.23861919 0.4679139346

This page Amendment C

8
ESDU 85046
TM

Engineering Sciences Data Unit

The error term or remainder, Rn , of the Gauss-Legendre formulae is given by

2n + 1 4
(2) ( n! ) ( 2n )
R n = --------------------------------------------- f ( ξ ), – 1 ≤ ξ ≤ 1 . (3.11)
3
( 2n + 1 ) [ ( 2n )! ]

To convert an integral between limits ( a, b ) to those required for the Gaussian integration (–1, 1), a linear
transformation is used. Thus, for the following integral

1
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

b
∫a g ( u ) du =
∫–1 f ( x ) dx ,

the variable u is mapped by x = [ 2u – ( b + a ) ] / ( b – a ) , where

 
f ( x ) = 0.5 ( b – a ) g  0.5 ( b – a )x + 0.5 ( b + a )  .
 

The error terms of these Gaussian formulae involve derivatives of higher-order than the Newton-Cotes
formulae and so will suffer even more from truncation error. Consequently only the low-order formulae
are normally of practical interest. The Gaussian formulae do have the advantage of high accuracy and
provided the magnitudes of the high-order derivatives decrease, or do not increase substantially with
increasing n, the Gauss-Legendre formulae can be significantly more accurate than the equal-interval
Newton-Cotes formulae for comparable order of n. As was the case for the Newton-Cotes formulae, a
composite form of the Gauss-Legendre formulae can be derived for use over the complete integration
interval (a, b). The disadvantages inherent in this procedure are a consequence of the irregular spacing of
the abscissae values used in the formulae. Firstly, because the end points of a subinterval are not the values
used in the formula, the advantage gained in the Newton-Cotes formulae of having abscissae common to
two or more subintervals is not possible. Secondly, a linear transformation of the integration interval is
required each time an interval is subdivided and so, although the number of functional evaluations will be
smaller for a particular accuracy, the time needed to perform the transformation may well override these
advantages.

For satisfactory integration a compromise is consequently needed between the accuracy of the formula,
which leads to the use of high-order formulae, and the ease with which a formula can be applied to achieve
a specified accuracy, suggesting the use of a low-order composite rule. A better approach, that allows an
estimate of the error to be made automatically and distinguishes between the areas in which an accuracy
criterion has been met or not met, is called an adaptive procedure and is treated in Section 4.

3.3 Multiple Integrals

All the formulae presented in the earlier parts of this Section 3 may be adapted for the approximation of
multiple integrals. The simplest multiple integral is the double integral of the form

∫R ∫ f ( x, y ) dA .
If the region R is rectangular and defined by

a≤x≤b, c≤y≤d,

This page Amendment C

9
ESDU 85046
TM

Engineering Sciences Data Unit

then the integral may be rewritten as

b d 
∫R ∫ f ( x, y ) dA =
∫ a  ∫ c f ( x, y ) dy dx . (3.12)

In quadrature form the integral is

m n
b d   
∫ ∫ f ( x, y ) dy d x = wj  ∑ ∑
wi f ( xj , yi )  . (3.13)
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

a c
  j = 0 i = 0 

This double integral can be tackled by using one of the formulae described previously for the inner integral
and then applying the same, or another, formula to the resulting terms for the outer integral.

The same procedure can be used for the approximation of higher integrals involving 3 or more variables.
For multi-dimensional integrals the time taken for evaluation can be costly and in such cases a Monte Carlo
method may be more appropriate. For a discussion of this method see Reference 11.

The above procedure has assumed that the region, R, over which the integral is approximated is rectangular,
i.e the limits of integration of both the inner and outer integrals are constants. The procedure can be easily
modified to cope with an integral in which the inner integral limits are functions of the variable of the outer
integral, non-rectangular region, for example, an evaluation of

b d( x ) 
∫ a  ∫ c ( x ) f ( x, y ) dy dx .
The step size for the variable of the outer integral is given by hx = ( b – a )/2 , and the step size for y varies
with x and is given by

h y ( x ) =  d ( x ) – c ( x ) /2 .
 

This page Amendment C

10
ESDU 85046
TM

Engineering Sciences Data Unit

4. ADAPTIVE QUADRATURE

Many functions contain regions of both high and low functional variations and in such cases it is more
appropriate if the step size is changed accordingly. Thus, a smaller step size would ideally be required for
regions of high functional variation and a larger step size for regions of low variation.

A scheme which distinguishes between high and low functional variation and adapts the step size
accordingly is termed an ADAPTIVE method. There are a number of adaptive methods but only one will
be described in this Item. It will be described using Simpson's rule.
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

Consider the following integral

b
∫ a f ( x ) dx ,
which is required to a specified tolerance, ε . The first step in the procedure is to estimate the integral across
the whole interval, (a, b), where the step length is given by h = (b – a)/2. The following approximation
results.

4
b ( b – a )h ( 4 )
∫ a
f ( x ) dx = S ( a, b ) – ------------------------- f ( ξ )
180
(4.1)

h  
where S ( a, b ) = ---  f ( a ) + 4f ( a + h ) + f ( b )  .
3  

The error in the approximation of the integral by S(a, b) is seen from the error term to be proportional to
( b – a )h 4 . The next step is to subdivide the integral into two halves of abscissa (step) length h/2, where the
new step length, (b – a)/4, and use Simpson's rule over each half.

Thus, the following approximation results

4
b a+b a+b (b – a)  h  (4)
f ( x ) dx = S  a, ------------- + S  -------------, b – ------------------  ---  f ( ξ 1 ) ,
∫ a  2   2  180  2 
(4.2)

a+b h  h 
where S  a, ------------- = ---  f ( a ) + 4f  a + --- + f ( a + h ) 
 2  6   2 

a+b h  3h 
and S  ------------- , b = ---  f ( a + h ) + 4f  a + ------ + f ( b )  .
 2  6   2 

The error in this approximation is seen to be proportional to ( b – a ) ( h/2 )4 . To compare the relative accuracy
of Equations (4.1) and (4.2) it is assumed that the quantities in the error terms f ( 4 ) ( ξ ) and f ( 4 ) ( ξ 1 ) are equal.

This page Amendment C

11
ESDU 85046
TM

Engineering Sciences Data Unit

With this assumption the following expressions can be found

a+b a+b 15 ( b – a ) 4 ( 4 )
S ( a, b ) – S  a, ------------- – S  ------------- , b = ------ ------------------ h f ( ξ )/180 ,
 2   2  16 180

b  a + b a+b
– S  -------------, b
or
∫ a f ( x ) dx – S  a, -------------
2   2 
=

1 a+b a+b
------ S ( a, b ) – S  a, ------------- – S  ------------- , b .
15  2   2 
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

Consequently, if

a+b
S ( a, b ) – S  ------------- , b < 15 ε ,
 2 

the estimate of the integral may be accepted. If this inequality is not true the same procedure is applied to
each half-interval using a tolerance of ε/2 for each half. The integral of each half-interval is thus compared
independently and accepted if it is within tolerance. In regions where the functional variations are high,
greater subdivision will be required to satisfy the specified tolerance. This adaptive procedure approximates
the integral to the same tolerance level throughout the integration interval. Thus, although this procedure
can be looked upon as an alternative way of applying a composite rule it has a number of advantages.

An advantage that can be reaped from this scheme is in the number of functional evaluations that need to
be made. Provided previously computed evaluations can be stored and re-used when an interval is halved,
then, in general, fewer evaluations are needed to evaluate the integral to a specified tolerance. This will be
particularly advantageous when evaluation of an integral is costly. This advantage cannot be achieved from
the Gauss-Legendre formulae since the abscissae used over one interval are not common with those required
for a subinterval.

The choice of a particular quadrature formula will depend to a large extent on the particular integral to be
solved and on the experience that the user has about the behaviour of the function, or similar functions, to
be integrated. It should be noted that if the function to be integrated is known to be a polynomial of order
n then an nth-order formula will be exact. For a general purpose method, however, it is recommended that
a low-order Newton-Cotes formula be used together with an adaptive scheme.

The choice of the particular general purpose Newton-Cotes low-order formula for an adaptive scheme is
purely a matter of preference since there is an obvious trade-off between the accuracy of a higher-order
method, when fewer subdivisions are needed, and the simplicity of the rule, where fewer functional
evaluations are required. Certainly Simpson's rule (n = 2) is preferred to Simpson's 3/8 rule (n = 3) since
they both have the same order of truncation error term.

In this Item, Simpson's rule has been chosen as the basis for a general purpose adaptive program, a general
description of which is given in Section 7. The program deals with three types of definite integral.

The first type deals with the approximation of a single definite integral of a known user-defined function,
f(x), and Example 1 of Section 8 provides an example of its use.

This page Amendment C

12
ESDU 85046
TM

Engineering Sciences Data Unit

The second and third types deal with the approximation of a double definite integral of a user-defined
function, f(x,y) for a rectangular region of integration and a non-rectangular region, respectively, and
Examples 2 and 3 of Section 8 provide examples of their use.

The procedures used in the program approximate the integral(s) in the leftmost region first and use an
efficient stacking procedure for storing and recalling previously computed function values. It should be
noted that the tolerance level has been conservatively set to 10ε instead of 15ε to compensate for the error
in the assumption that f ( 4 ) ( ξ ) = f ( 4 ) ( ξ 1 ) . In some integrals in which the derivative is particularly widely
varying a reduction of this error bound is desirable. It can be noted that for cases where the major
contributions to an integral come from a small part of the range, the criterion for acceptance of a given
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

value is quite conservative and the result produced may be considerably more accurate than that suggested
by the requested tolerance.

The adaptive procedure that has been presented is an extremely efficient method of evaluating an integral,
but care must be exercised when a coarse subdivision is found to be sufficient to produce the accuracy
required and little is known about the variation of the function within the integration interval. If the function
is peaky, then the subdivision used may be large enough for such peaks to be within the interval and missed
therefore from the integration even though they may contain a significant proportion of the integral. Other
cases may be visualised, such as a function that frequently crosses the abscissa, where the method of simply
halving the integration interval and comparing the results may not produce satisfactory results. In order to
cater for such effects of the variation of the function it is recommended that a sensibly fine subdivision
interval be used. This may produce a result whose accuracy far exceeds the level that would normally be
needed in practice. Such a facility is provided in the programs in this Item where the input of a “maximum
step length allowed” forces the program to subdivide the interval to a level where the step length is never
greater than the value input.

This page Amendment C

13
ESDU 85046
TM

Engineering Sciences Data Unit

5. IMPROPER INTEGRALS

An improper integral is one in which the integrand becomes infinite at some point in the integration interval
or one or both of the limits of integration are infinite. In either of these cases the integral may still exist,
but the methods described in the earlier sections of this Item cannot be directly applied.

5.1 Infinite Integrand

In those cases when a singularity occurs in the integral, i.e. the integrand becomes infinite, particular
attention must be given to the handling of the integral near the singular point. Often it may be possible by
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

a change of variable or integration by parts, or some other geometrical re-organisation, to transform the
integral into one which is no longer singular. For example the following integral

π cos x
∫ 0 -----------
x
- dx ,

is singular at the lower integration limit, but integrating by parts yields

π cos x π π
------------ dx =  2 x cos x
∫ 0
x
 
0
+
∫0 2 x sin x .

The remaining integral is nonsingular and may be evaluated using any of previous methods that have been
described in the earlier sections of this Item.

As a further example consider

1 x3
∫ -------------------------
0 ( 1 – x2 )
dx ,

which is singular at the upper limit but, by using the substitution x = sin θ , is transformed into a nonsingular
integral.

An alternative method is to split the integral into two parts by introducing the first term of a Taylor's series
expansion about the singularity point. Consider the following general integral.

a g ( x ) dx
∫ b ----------------------
(x – x )
-,
n
a < x 1 < b and n < 1 .
1

The integral can be re-expressed as

a g ( x ) dx b g ( x ) – g ( x1 ) dx
--------------------------------- dx + g ( x 1 ) b ----------------------- ,
∫ b
----------------------- =
( x – x1 )
n ∫ a
( x – x1 )
n ∫
a
( x – x1 )
n

where g ( x 1 ) is the first term of the Taylor’s series expansion about the point x1 . Both terms on the
right-hand side of this equation are well behaved throughout the interval (a, b), provided that the successive
derivatives of g(x) are finite, and so they may be evaluated by any of the methods previously described. In
this case the second integral on the right-hand side of the above equation may be evaluated analytically.

This page Amendment C

14
ESDU 85046
TM

Engineering Sciences Data Unit

Computationally, care must be taken not to choose x = x1 as an abcissae value for the formula chosen.

A similar approach can be adopted for integrals of the form

b
∫0 g(x ) ln ( x ) dx .

5.2 Infinite Limits

There are essentially only two approaches for the approximation of integrals involving an infinite interval
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

of integration.

The first approach is similar to the last method used for the infinite integrand case. Thus, if that part of an
integral for x > a (where a is finite) can be assumed small or can be estimated analytically, then one of the
previously described formulae can be employed for the region x < a .

The second approach is to employ a quadrature formula derived specifically for use over the complete
interval. Two well-known formulae for the semi-infinite and infinite cases are known as Gauss-Laguerre
and Gauss-Hermite formulae respectively.

5.2.1 Gauss-Laguerre formulae

For the semi-infinite case the weight function e –x assumes convergence of the integral when f(x) is of less
than exponential order and the Gauss-Laguerre formula of degree n takes the form

n–1

∫ 0
exp ( – x ) f ( x ) dx = ∑ wi f ( x i ) . (5.1)
i = 0

These formulae may be re-expressed as

n–1

∫ 0
g ( x ) dx ≈ ∑ wi exp ( x i ) g ( x i ) . (5.2)
i = 0

The abscissae values, x i , are roots of the Laguerre polynomials, L n , of degree n, and the weights, wi , can
be obtained from

( n! ) 2
w i = ----------------------------------- . (5.3)
x i [ L n( 1 ) ( x i ) ] 2

Table 5.1 presents the weights and abscissae for formulae up to sixth-order. For higher-order values
Reference 1 may be consulted.

This page Amendment C

15
ESDU 85046
TM

Engineering Sciences Data Unit

TABLE 5.1 Gauss-Laguerre weights and abscissae

n xi wi wi exp ( xi )

2 0.585786437627 8.53553390593 × 10–1 1.53332603312


3.414213562373 1.46446609407 × 10–1 4.45095733505
3 0.415774556783 7.11093009929 × 10–1 1.07769285927
2.294280360279 2.78517733569 × 10–1 2.76214296190
6.289945082937 1.03892565016 × 10–2 5.60109462543
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

4 0.322547689619 6.03154104342 × 10–1 0.832739123838


1.745761101158 3.57418692438 × 10–1 2.04810243845
4.536620296921 3.88879085150 × 10–2 3.63114630582
9.395070912301 5.39294705561 × 10–4 6.48714508441
5 0.263560319718 5.21755610583 × 10–1 0.679094042208
1.413403059107 3.98666811083 × 10–1 1.63848787360
3.596425771041 7.59424496817 × 10–2 2.76944324237
7.085810005859 3.61175867992 × 10–3 4.31565690092
12.640800844276 2.33699723858 × 10–5 7.21918635435
6 0.222846604179 4.58964673950 × 10–1 0.573535507423
1.188932101673 4.17000830772 × 10–1 1.36925259071
2.992736326059 1.13373382074 × 10–1 2.26068459338
5.775143569105 1.03991974531 × 10–2 3.35052458236
9.837467418383 2.61017202815 × 10–4 4.88682680021
15.982873980602 8.98547906430 × 10–7 7.84901594560

5.2.2 Gauss-Hermite formulae

The Gauss-Hermite formulae, H n , of degree n, take the form

n–1
∞ 2
∫ –∞
exp ( – x ) f ( x ) dx = ∑ wi f ( xi ) (5.4)
i = 0

These formulae may be re-expressed as

n–1
∞ 2
∫ –∞
g( x) dx = ∑ w i exp ( x i ) g ( x i ) . (5.5)
i = 0

The abscissae values, xi , are roots of the Hermite polynomials, H n , of degree n , and the weights, wi , are
given by

n+1
2 n! π
w i = ------------------------------ .
(1) 2
[ Hn ( xi ) ]

This page Amendment C

16
ESDU 85046
TM

Engineering Sciences Data Unit

Table 5.2 presents the weights and abscissae for formulae up to sixth-order. For higher-order values
Reference 1 may be consulted.

TABLE 5.2 Gauss-Hermite weights and abscissae

n xi wi w i exp ( xi2)
2 0.7071067811865 8.862269254528 × 10–1 1.461141182661
3 0.0000000000000 1.181635900604 × 10–0 1.181635900604
1.2247448713916 2.954089751509 × 10–1 1.323931175214
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

4 0.5246476232753 8.049140900055 × 10–1 1.059964482895


1.6506801238858 8.131283544725 × 10–1 1.240225817696
5 0.0000000000000 9.453087204829 × 10–1 0.945308720483
0.9585724646138 3.936193231522 × 10–1 0.986580996751
2.0201828704561 1.995324205905 × 10–2 1.181488625536
6 0.4360774119276 7.246295952244 × 10–1 0.876401334436
1.3358490740137 1.570673203229 × 10–1 0.935580557631
2.3506049736745 4.530009905509 × 10–3 1.136908332675

This page Amendment C

17
ESDU 85046
TM

Engineering Sciences Data Unit

6. REFERENCES

1. ABRAMOWITZ, M. Handbook of mathematical functions. National Bureau of Standards,


STEGUN, I.A. AMS 55, June 1964.
(Editors)
2. BAJPAI, A.C. Advanced engineering mathematics. John Wiley and Sons, London,
MUSTOE, L.R. 1977.
WALKER, D.
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

3. BURDEN, R.L. Numerical analysis. Prindle, Weber and Schmidt, Boston, 1981.
FAIRES, J.D.
REYNOLDS, A.C.
4. CARNAHAN, B. Applied numerical methods. John Wiley and Sons, New York, 1969.
LUTHER, H.A.
WILKES, J.O.
5. ESDU ESDUview user manual. Item No. 00009, ESDU International, London,
2000.
6. FERZIGER, J.H. Numerical methods for engineering application. John Wiley and Sons,
New York, 1981.
7. GERALD, C.F. Applied numerical analysis. Addison-Wesley Publishing, New York,
1978.
8. KOPAL, Z. Numerical analysis. Chapman and Hall, London, 1955.
9. KREYSZIG, E. Advanced engineering mathematics. John Wiley and Sons, New York,
1983.
10. PENNINGTON, R.H. Introductory computer methods and numerical analysis. The Macmillan
Company, New York, 1965.
11. RALSTON, A. Mathematical methods for digital computers. John Wiley and Sons,
WILF, H.S. New York, 1960.

This page Amendment C

18
ESDU 85046
TM

Engineering Sciences Data Unit

7. DESCRIPTION OF COMPUTER PROGRAM

The computer program issued with this Item, implements the adaptive quadrature method based on the
standard Simpson's Rule, as described in Section 4, for the following definite integrals:

(i) a single definite integral of a known, user-defined, function, f(x), taking the form

b
∫ a f ( x ) dx ,
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

where a and b are constant limits,

(ii) a double integral with definite inner and outer limits of a known, user-defined function,
f(x,y), taking the form

 d
b
f ( x,y ) dy dx ,
∫a  ∫ c 

where a, b, c and d are constant limits

and (iii) a double integral with definite outer limits and variable inner limits of a known, user-defined
function, f(x,y), taking the form

b d(x)  dx ,
∫ a  ∫ c ( x ) f ( x,y ) dy
where a and b are the constant limits and c(x) and d(x) are user-defined functions of x.

The user-defined functions, f(x), f(x,y), c(x) and d(x), are input to the program as alphanumeric strings that
are interpreted by the computer program at run time with the use of an expression parser.

The computer program is supplied in three forms:

(i) an executable VIEWpac† program, 8546Av##‡

(ii) a Fortran executable program, A8546v##.EXE‡

(iii) a Fortran ASCII source code program, A8546v##.FOR‡

For program accessibility and installation, see Section 9.

† The term VIEWpac is here used to describe an interface program that runs within ESDUview (see Data Item 00009, Reference 5)
‡ The symbols ## refer to an encoded version number of the program: for example if the version number is 2.1 then ## is equal to 21. Thus
the full name of Version 1.0 of the executable program A8546 will be A8546v21.EXE and this name must be used when accessing the file.

This page Amendment C

19
ESDU 85046
TM

Engineering Sciences Data Unit

7.1 Executable VIEWpac Program 8546A

This version of the program, named 8546Av##, contains the Fortran executable code, A8546v##.EXE,
wrapped within an interface called ESDUview and is for use on computers running Microsoft Windows
95, or later, operating systems. The main purpose of ESDUview is to allow:

(i) input files to be created following descriptive screen prompts,


(ii) embedded help to be available for every input quantity,
(iii) program runs to be launched within the interface
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

and (iv) automatic view of the main output file.

Other features of ESDUview include an editor, that may be used to view all files, and a calculator. A guide
to the use of ESDUview (see Data Item 00009, Reference 5) is also available. The ESDUview interface is
included within the ESDU web site, www.esdu.com and within the Series CD-ROM installation.

7.2 Fortran Executable Program A8546

This version of the program, named A8546v##.EXE, is a 32-bit executable code compiled with Salford
Fortran 77, Version 4.x, for use on a PC running MS-DOS (Microsoft© - Disk Operating System) Windows
95 (or later) operating system. This file has been obtained by directly compiling and linking the Fortran
source code, A8546v##.FOR, see Section 7.3.

The program accepts the main input file as an “externally directed” file, i.e. its name is allocated at run
time externally to the program (see Section 7.3.2). The input data are entered into the named input file with
the use of a text editor in the data entry order as detailed in Section 7.4.1.

Running instructions for the program are given in Section 7.3.2.

7.3 Fortran Source Code Program A8546

This form of the program is an ASCII file, named ESDUpac A8546v##.FOR, and contains the Fortran
source code that allows users to:

(i) incorporate all or part of the code in their own programs


and/or (ii) compile the program using their own Fortran compiler to avoid problems with
system-specific compilers.

The program is written in Fortran 77 and was tested using the following compilers.

1. The Microsoft 16-bit Fortran compiler, Version 5.x, for which the compiler options used were:
/4Ys for “STRICT” compliance with ANSI Fortran 77
and /4Yd to check that all variables within the program have been declared.
2. The Salford 32-bit Fortran compiler Version 4.x, for which the compiler options used were:
/ANSI for compliance with ANSI Fortran 77,
/IMPLICIT_NONE to check that all variables have been declared,
/UNDEF to check that all variables, including array elements, have been assigned a value
and /CHECK in order to cause a run-time error when arithmetic overflow occurs.

This page Amendment C

20
ESDU 85046
TM

Engineering Sciences Data Unit

7.3.1 Compiling and linking program A8546

Although an executable version of the program is supplied (see Section 7.2) for a PC operating Microsoft
Windows 95 (or later), users may wish to modify the supplied code or produce an executable version for
their own operating system.

The source code is stored in a file named

A8546v##.FOR
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

The Salford command to compile and link this program is

FTN77 ∇ A8546v##.FOR∇/LΙΝΚ

and the Microsoft command to compile and link the program is

FL ∇ /F ∇ 1400 ∇ /FPi ∇ A8546v##.FOR

where ∇ denotes a space and where ## relates to the version number of the program, as noted earlier.

The result of either command will be the creation of an executable file, namely A8546v##.EXE.

If the source code is to be compiled and linked using another Fortran 77 compiler then the appropriate
compiler manual should be consulted for the equivalent commands.

7.3.2 Running program A8546

The program accepts the input file as an “externally directed” file, i.e. its name is allocated at run time
externally to the program. The input data are entered into the named input data file with the use of a text
editor in the data entry order as detailed in Section 7.4. The output file is named within the main input file
(see Section 7.4).

The program is run by entering the following command at the DOS prompt

A8546v##.EXE < MAIN.IN

where MAIN.IN is an example name of a main input file. (The inclusion of the extension.EXE is optional.)

If the main input file name is excluded from the command line (undirected input), i.e. the command

A8546v##.EXE

is entered, then the program will prompt the user to enter the name of the input file from the keyboard.

This page Amendment C

21
ESDU 85046
TM

Engineering Sciences Data Unit

7.4 Program Input Data

This section describes the data entry order for the input file. The data required in the main input file by the
VIEWpac program are identical with those shown here but are entered using the ESDUview interface.

Program Notation
Entry
Entry Instructions Input Symbol(s) Variable type
Number
Symbol(s) Equivalent
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

Enter Program Identifier: ESDU85046 PRNAME – CHARACTER


(This identifier must be the only string other
1
than spaces in the first 256 characters of the
first line of the file)
Enter run title – 1st line TITLE(1) – CHARACTER
2
(75 characters allowed)
Enter run title – 2nd line TITLE(2) – CHARACTER
3
(75 characters allowed)
Enter run title – 3rd line TITLE(3) – CHARACTER
4
(75 characters allowed)
Enter file name for output data OUTFN – CHARACTER
5
(256 characters allowed)
Enter parameter for integral type ITYPE – INTEGER
1 Single definite integral
2 Double integral with definite inner and
6
outer limits
3 Double integral with definite outer
limits and variable inner limits
If ITYPE = 1
Enter integrand (as an alphanumeric string EXPRES f(x) CHARACTER
7†
given as a function of x only – 256 characters
allowed)
If ITYPE = 2 or 3
Enter integrand (as an alphanumeric string EXPRES f(x,y) CHARACTER
8†
given as a function of x and y – 256
characters allowed)

9 Enter upper limit of outer integral B b REAL

10 Enter lower limit of outer integral A a REAL

If ITYPE = 2
11 Enter upper limit of inner integral D d REAL

If ITYPE = 2
12 Enter lower limit of inner integral C c REAL
† See end of table

This page Amendment C

22
ESDU 85046
TM

Engineering Sciences Data Unit

Program Notation
Entry
Entry Instructions Input Symbol(s) Variable type
Number
Symbol(s) Equivalent

If ITYPE = 3
Enter upper limit of inner integral (as an USTR d(x) CHARACTER
13†
alphanumeric string given as a function of x
or a constant – 256 characters allowed)
If ITYPE = 3
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

Enter lower limit of inner integral (as an LSTR c(x) CHARACTER


14†
alphanumeric string given as a function of x
or a constant – 256 characters allowed)
Enter Maximum number of levels of ILEVEL – INTEGER
15‡
subdivision to be allowed

16‡ Enter Tolerance of approximation allowed TOL – REAL

17‡ Enter Maximum step length allowed HMAX – REAL

† Description of the arithmetic operators and intrinsic functions allowed as part of alphanumeric strings is given in Section 7.4.1.

‡ Further description of these controlling inputs may be found in Section 7.4.2.

7.4.1 Arithmetic operators and intrinsic functions

The computer program incorporates an expression parser that is used to interpret the alphanumeric strings
used for the integrand and for the inner integral variable upper and lower limits for the double integral.

The usual arithmetic operators +, -, *, / and ^ represent, respectively, addition, subtraction, multiplication,
division and exponentiation. Expressions are evaluated with the following precedence applied.

Highest ^ exponentiation
* / multiplication and division
Lowest + - addition and subtraction

As is usual, parentheses, (...), allow the precedence of expression evaluation to be explicitly specified.
Numbers within the expression can be specified in a variety of formats. All of the following forms, for
example, are equivalent 1234.0, 1234., 1234, 1.234E3, .1234E4, 0.1234E4, 0.1234E+4, 0.1234E+04. The
following intrinsic functions are supported.

INT (arg) whole number conversion of arg


NINT (arg) rounded whole number of arg
ABS (arg) absolute value of arg
LOG (arg) natural logarithm of arg
LOG10 (arg) logarithm to the base 10 of arg
LOG2 (arg) logarithm to the base 2 of arg
EXP (arg) exponential of arg (i.e. e^arg)
EXP10 (arg) exponential to base 10 of arg (i.e. 10^arg)
EXP2 (arg) exponential to base 2 of arg (i.e. 2^arg)
SQRT (arg) square root of arg
This page Amendment C

23
ESDU 85046
TM

Engineering Sciences Data Unit

SIN (arg) sine of arg


COS (arg) cosine of arg
TAN (arg) tangent of arg
SEC (arg) secant of arg
CSEC (arg) cosecant of arg
COT (arg) cotangent of arg
ASIN (arg) arc sine of arg
ACOS (arg) arc cosine of arg
ATAN (arg) arc tangent of arg
ASEC (arg) arc secant of arg
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

ACSEC (arg) arc cosecant of arg


ACOT (arg) arc cotangent of arg
SINH (arg) hyperbolic sine of arg
COSH (arg) hyperbolic cosine of arg
TANH (arg) hyperbolic tangent of arg
SECH (arg) hyperbolic secant of arg
CSECH (arg) hyperbolic cosecant of arg
COTH (arg) hyperbolic cotangent of arg

7.4.2 Program control settings

The settings required to control the integration process consist of the following three parameters.

(i) ILEVEL is the maximum number of subdivisions allowed. This variable has been introduced
simply to restrict the computer run time for an integral in which an inappropriately low tolerance
level, ‘TOL’, has been specified for the complete integral.
(ii) TOL is the tolerance of approximation required. This value is an absolute value and specifies the
accuracy with which the integral is required.
(iii) HMAX is the maximum step length allowed. This variable forces the routine to subdivide the
integration interval to a level where the step length is at least this value. The value chosen may
result in overriding the tolerance specified but will not override the ILEVEL value chosen if it is
inappropriate for the HMAX allowed. Further discussion of this variable may be found in Section
4. (It should be noted that the “step length” is the Simpson’s step length which is half of the
subdivided integration interval.)

7.5 Program Output Data

The program output contains a listing of the input data entered and the integration approximation when the
program has been successful. Failure of the program results in zero being returned as the approximation to
the integral together with an appropriate error message. A list of error messages that may be returned by
the program appears in Section 7.5.1.

7.5.1 Program error messages

Error messages provided by the program are of two sorts; those due to the input and the integration process
that are given in Table 7.1 and those due to the expression parser used to interpret the alphanumeric strings,
f(x), f(x,y), c(x) and d(x), that are given in Table 7.2.

This page Amendment C

24
ESDU 85046
TM

Engineering Sciences Data Unit

TABLE 7.1 Error messages associated with input and integration process
Error
Error Condition Error Message
No.

- Blank line encountered in input file. Missing Input Filename (undirected input), or missing
1
Program Identifier (directed input).
-
2 Incorrect Input Filename, or incorrect Program Identifier.

-
3 Incorrect Program Identifier. 'ESDU85046' expected.
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

-
4 Blank line or end of file encountered. Program Identifier 'ESDU85046' expected.

-
5 Error encountered within input file. Incorrect name of output file.

6 - Blank line encountered in input file. Missing name of output file.

7 - End of file reached prematurely.

8 - Blank line or input error associated with parameter for integral type.

9 1 > ITYPE > 3 Parameter for integral type out of range. ITYPE should = 1, 2 or 3.

10 - Blank line or input error associated with expression for integral.

11 - The string for the expression for integration is null.

12 - Blank line or input error associated with upper limit of integral.

13 - Blank line or input error associated with lower limit of integral.

14 B#A The upper limit of integration, B, must be larger than lower limit, A.

15 - Blank line or input error associated with upper limit of outer integral.

16 - Blank line or input error associated with lower limit of outer integral.

17 B#A The upper limit of outer integration, B, must be larger than lower limit, A.

18 - Blank line or input error associated with upper limit of inner integral.

19 - Blank line or input error associated with lower limit of inner integral.

20 D#C The upper limit of inner integration, D, must be larger than lower limit, C.

21 - The string for the upper limit of inner integration is null.

22 - Blank line or input error associated with string for upper limit of integral.

23 - The string for the lower limit of inner integration is null.

24 - Blank line or input error associated with string for lower limit of integral.

25 - Blank line or input error associated with 'ILEVEL'.

26 ILEVEL#0 The number of levels of sub-division, ILEVEL, must be greater than zero.

This page Amendment C


25
ESDU 85046
TM

Engineering Sciences Data Unit

TABLE 7.1 (continued) Error messages associated with input and integration process

27 - Blank line or input error associated with tolerance 'TOL'.

28 TOL#0 The tolerance of the approximation required must be greater than zero.

29 - Blank line or input error associated with maximum step length 'HMAX'.

30 0 > HMAX $B–A The maximum step length 'HMAX' must be greater than zero and less than (B–A).

If ITYPE = 1. Number of levels of subdivision exceeded in Subroutine AH8546


31
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

- If ITYPE = 2. Number of levels of subdivision exceeded in Subroutine AJ8546


If ITYPE = 3. Number of levels of subdivision exceeded in Subroutine AL8546
If ITYPE = 1. Dimension of arrays exceeded in Subroutine AH8546
32 - If ITYPE = 2. Dimension of arrays exceeded in Subroutine AJ8546
If ITYPE = 3. Dimension of arrays exceeded in Subroutine AL8546

TABLE 7.2 Error messages associated with expression parser


Number Error Message Error Description

ERROR EP01 No expression present The expression was blank (all space)

The expression was longer than the current maximum


ERROR EP02 Expression too long
allowable length of 256 characters.

The expression could not be understood but the reason for


ERROR EP03 Expression not understood
failure could not be determined.

ERROR EP04 Empty parentheses A pair of empty parentheses, (), was found in the expression.

Unbalanced parentheses (i.e. missing or extra closing


ERROR EP05 Unbalanced parentheses
parantheses) were found in the expression.

A variable, ABC in this example, that had not been defined was
ERROR EP06 Unknown variable, ABC
referred to in the expression.

ERROR EP07 Syntax error The expression was syntactically incorrect.

The closing parentheses of the arguments to an intrinsic


ERROR EP08 Unclosed function parentheses
function, such as TAN, could not be found.

The opening parentheses of the arguments to an intrinsic


ERROR EP09 Parentheses, "(", expected
function, such as TAN, could not be found.

A character that is not alphabetic, numeric or a delimitor was


ERROR EP10 Bad character, £
found in the expression.

The character string passed to a parser routine was declared in


the calling unit with a length that is not sufficient to hold the
ERROR EP11 Expression truncated
processed expression without truncation (the expression can
expand during processing).

ERROR EP12 Unknown function, SING A name has been used as a function that cannot be recognised
as one of the intrinsic functions supported.

ERROR EP13 Invalid argument to function LOG10 An invalid argument was used with an intrinsic function,
LOG10 in this example.

This page Amendment C

26
ESDU 85046
TM

Engineering Sciences Data Unit

TABLE 7.2 (continued) Error messages associated with expression parser


The value of the function, SQRT in this case, could not be
ERROR EP14 Arithmetic failure with function SQRT computed because the value of the argument was outside the
valid range for the function.

The result of an arithmetic operation, exponentiation in this


ERROR EP15 Arithmetic failure with operator, ^ example, could not be computed because one or more operands
were outside the valid range for the operation.

ERROR EP16† Unknown arithmetic operator, = An unknown arithmetic operator, = in this example, was used
in the expression.
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

An invalid number, perhaps a number that cannot be converted


ERROR EP19† Invalid operand with operator, * to single precision, was used as an operand in an arithmetic
operation, multiplication in this example.

Division by zero, or division of a large number by a small one,


ERROR EP22 Division by zero
has been attempted in the expression.

ERROR EP23 Integer division by zero. Integer division by zero has been attempted in the expression.

An invalid number, perhaps a number that cannot be converted


ERROR EP24 Invalid number.
to single precision, has been encountered in the expression.

† Error numbers EP17, EP18, EP20 and EP21 not used.

7.6 Program Application

General compiling, listing and running instructions, the input data required by the program and the program
output, which includes the failure error messages contained within the program, have been described.
However, if any difficulty is experienced in using this program please contact ESDU International.

Every reasonable effort has been made to ensure that the program performs the intended calculations
satisfactorily. However, in common with other providers of software no representation as to the suitability
or fitness of the program for any particular purpose is made and no liability for any loss occasioned by any
persons as a direct or indirect result of use of the program whether arising from negligence or otherwise
can be accepted. In no event shall ESDU or any individuals associated with the development of the program
be liable for any damages, including loss of profit or consequential loss arising out of or in connection with
the program.

This page Amendment C

27
ESDU 85046
TM

Engineering Sciences Data Unit

8. EXAMPLES

8.1 Example 1 – Single Definite Integral

This example considers the following integral


6 x
∫0 e cos x dx ,

which is required to a tolerance of 1.00E–4. It was decided to allow a maximum of 20 levels of subdivision
and a maximum step length of 0.5. The computer print-out of the input and output was as follows.
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

(a) Input file “Example1.IN”

ESDU85046
Example 1. Single definite integral
Function exp(x)*cos(x)
Limits 0 to 6
Example1.out
1
exp(x)*cos(x)
6.0
0.0
20
0.0001
0.5

(b) Output file “Example1.OUT”

----------------------------------------------------------------------
ESDU International Plc

PROGRAM A8546

ESDUpac Number: A8546


ESDUpac Title: An adaptive quadrature method for the evaluation
of single and double integrals
Data Item Number: 85046
Data Item Title: Quadrature methods for the evaluation
of definite integrals
ESDUpac Version: 2.1 July 2002 - Data Item Amendment C

(See Data Item for full input/output specification and interpretation)


----------------------------------------------------------------------

Input data
----------

Program identifier: ESDU85046

Run Titles:
Example 1. Single definite integral
Function exp(x)*cos(x)
Limits 0 to 6
continued

This page Amendment C

28
ESDU 85046
TM

Engineering Sciences Data Unit

Output file name:


EXAMPLE1.OUT

Parameter for integration type, ITYPE = 1

Expression to be integrated:
EXP(X)*COS(X)

Upper limit of integration, B = 0.60000E+01


ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

Lower limit of integration, A = 0.00000E+00

Maximum number of levels of


subdivision allowed, ILEVEL = 20

Tolerance of approximation
required, TOL = 0.10000E-03

Maximum step length


allowed, HMAX = 0.50000E+00

Output data
-----------

Integration approximation = 136.818

Program completed
----------------------------------------------------------------------
x
A plot of the function e cos x is shown in Sketch 8.1 and illustrates the number of subdivisions of the
independent variable, x, needed to approximate the integral to the tolerance that has been specified. The
tick marks on the abscissa show the end points of the Simpson’s rule steps needed to approximate the
integral. At the highest slopes of the function, i.e. x values between 5.25 and 6.0, the smallest subdivision
was needed for the approximation to be achieved to the specified tolerance. For this integral a total number
of 117 function evaluations was required.

400

350

300

250

200
ex cos x
150

100

50

0 I I I I I I I I I I I I I I I I I I II I I I I I I I I I I I I I I I I I I I I I I I II I I I I I I I I I I I I I

−50
-50 I I I I I I I I
0.75 1.5 2.25 3 3.75 4.5 5.25 6
x

Sketch 8.1 Plot of function ex cos x


This page Amendment C

29
ESDU 85046
TM

Engineering Sciences Data Unit

8.2 Example 2 – Double Definite Integral

This example considers the following double integral

1 4 xy
∫0 ∫ 2 e dy dx ,

which is required to a tolerance of 1.00E–4. It was decided to allow a maximum of 20 levels of subdivision
and a maximum step length of 0.5. The computer print-out of the input and output was as follows.
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

(a) Input file “Example2.IN”


ESDU85046
Example 2. Double definite integral
Function exp(x*y)
Outer limits 0 to 1. Inner limits 2 to 4.
Example2.out
2
exp(x*y)
1.0
0.0
4.0
2.0
20
0.0001
0.5

(b) Output file “Example2.OUT”

----------------------------------------------------------------------
ESDU International Plc

PROGRAM A8546

ESDUpac Number: A8546


ESDUpac Title: An adaptive quadrature method for the evaluation
of single and double integrals
Data Item Number: 85046
Data Item Title: Quadrature methods for the evaluation
of definite integrals
ESDUpac Version: 2.1 July 2002 - Data Item Amendment C

(See Data Item for full input/output specification and interpretation)


----------------------------------------------------------------------

Input data
----------

Program identifier: ESDU85046

Run Titles:
Example 2. Double definite integral
Function exp(x*y)
Outer limits 0 to 1. Inner limits 2 to 4.
continued

This page Amendment C

30
ESDU 85046
TM

Engineering Sciences Data Unit

Output file name:


EXAMPLE2.OUT

Parameter for integration type, ITYPE = 2

Expression to be integrated:
EXP(X*Y)

Upper limit of outer integration, B = 0.10000E+01


ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

Lower limit of outer integration, A = 0.00000E+00

Upper limit of inner integration, D = 0.40000E+01


Lower limit of inner integration, C = 0.20000E+01

Maximum number of levels of


subdivision allowed, ILEVEL = 20

Tolerance of approximation
required, TOL = 0.10000E-03

Maximum step length


allowed, HMAX = 0.50000E+00

Output data
-----------

Integration approximation = 13.9835

Program completed
----------------------------------------------------------------------

As an illustration of the number of subdivisions of the independent variables, x and y, used to find the
volume under the surface defined by exy, Sketch 8.2 is shown. The grid on the surface indicates the end
points of the Simpson’s approximation that were needed to find the double integral to the tolerance required.
The sketch shows that at the higher x and y values a greater number of subdivisions was needed. For the
approximation of this double integral the total number of function evaluations required was 373. The
tolerance specified was chosen purely to illustrate the adaptive procedure and is not meant to represent the
tolerance that would normally be required in a practical example.

This page Amendment C

31
ESDU 85046
TM

Engineering Sciences Data Unit

f (x,y)

60

50
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

40

exy
30

20
x

10

1.0
0.75
0
2.0 0.5
2.5
3.0 0.25
3.5
4.0
y
Sketch 8.2 Plot of the function e xy

8.3 Example 3 – Double Integral with Definite Outer and Variable Inner Limits

This example considers the following integral

2 3x xy
∫ 1 ∫ 2x e dy dx ,

which is required to a tolerance of 1.00E–4. It was decided to allow a maximum of 20 levels of subdivision
and a maximum step length of 0.5. The computer print-out of the input and output was as follows

This page Amendment C

32
ESDU 85046
TM

Engineering Sciences Data Unit

(a) Input file “Example3.IN”


ESDU85046
Example 3. Double integral with definite outer & variable inner limits
Function exp(x*y)
Outer limits 1 to 2. Inner limits from 2*x to 3*x
Example3.out
3
exp(x*y)
2.0
1.0
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

3.0*x
2.0*x
20
0.0001
0.5

(b) Output file “Example3.OUT”

----------------------------------------------------------------------
ESDU International Plc

PROGRAM A8546

ESDUpac Number: A8546


ESDUpac Title: An adaptive quadrature method for the evaluation
of single and double integrals
Data Item Number: 85046
Data Item Title: Quadrature methods for the evaluation
of definite integrals
ESDUpac Version: 2.1 July 2002 - Data Item Amendment C

(See Data Item for full input/output specification and interpretation)


----------------------------------------------------------------------

Input data
----------

Program identifier: ESDU85046

Run Titles:
Example 3. Double integral with definite outer & variable inner limits
Function exp(x*y)
Outer limits 1 to 2. Inner limits from 2*x to 3*x

Output file name:


EXAMPLE3.OUT

Parameter for integration type, ITYPE = 3

Expression to be integrated:
EXP(X*Y)

Upper limit of outer integration, B = 0.20000E+01


Lower limit of outer integration, A = 0.10000E+01

continued

This page Amendment C

33
ESDU 85046
TM

Engineering Sciences Data Unit

String for upper limit of inner integral:


3.0*X
String for lower limit of inner integral:
2.0*X

Maximum number of levels of


subdivision allowed, ILEVEL = 20

Tolerance of approximation
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

required, TOL = 0.10000E-03

Maximum step length


allowed, HMAX = 0.50000E+00

Output data
-----------

Integration approximation = 7257.09

Program completed
----------------------------------------------------------------------

This page Amendment C

34
ESDU 85046
TM

Engineering Sciences Data Unit

9. PROGRAM ACCESSIBILITY AND INSTALLATION

9.1 Hardware Requirements

The program requires a minimum of a 386 personal computer with at least 4MB of RAM and a maths
co-processor.

A printer is necessary if hardcopy output is required.

9.2 Accessibility
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

Three types of subsctiption to ESDU are available and they provide access to:

(i) the ESDU website, www.esdu.com, through a user name and password,

(ii) local or network Series on a CD-ROM, which installs as ESDUscope, and includes a
licence disk covering access to an electronic version of the Data Item and associated
software

and (iii) a hardcopy set of Data Items of the Series and a copy of Series CD-ROM which includes
a licence disk covering access solely to the software

9.3 Installation

9.3.1 Executable VIEWpac program 8546A

Series CD-ROM. The executable program, VIEWpac 8546A†, and associated files are automatically
installed once the Series CD-ROM and associated licence disk are installed.

Web Site. The executable program, VIEWpac 8546A†, and associated files are downloaded as
a zip file to a directory location specified in a user’s zip utility.

9.3.2 Fortran executable program A8546

Series CD-ROM. Assuming the CD-ROM has been installed onto hard disk, C:, under the main
directory location, ESDU, then the executable program A8546†, together with all
associated files including the Fortran source file, is found in the location

“C:\ESDU\ESDUPACS\A8546v##”

in which ## refers to an encoded version number of the program.

Web Site. The executable program, A8546†, and associated files, including the Fortran source
code, are downloaded as a zip file to a directory location specified in a user’s zip
utility.

† The full name of a program file depends upon the current version number of the program. Thus, for example, the full name of Version 2.1
of the executable program file A8546 will be A8546v21.EXE and must be used when accessing the file.

This page Amendment C

35
ESDU 85046
TM

Engineering Sciences Data Unit

KEEPING UP TO DATE

Whenever Items are revised, subscribers to the service automatically receive the material required to update the appropriate
Volumes. If you are in any doubt as to whether or not your ESDU holding is up to date, please contact us.

Please address all technical engineering enquiries and suggestions to:

ESDU International plc Tel: 020 7490 5151 (from the UK)
+44 20 7490 5151 (from outside the UK)
Fax: 020 7490 2701 (from the UK)
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

+44 20 7490 2701 (from outside the UK)


E-Mail: esdu@esdu.com
Website: www.esdu.com

For users in the USA, please address all Customer Service and Support enquiries and suggestions to:

IHS Engineering Products Tel: 1 800 525 7052 (toll free number)
and Fax: 1 303 397 2599
Global Engineering Documents Website: www.ihs.com
www.global.ihs.com
85046
Quadrature methods for the evaluation of definite integrals.
ESDU 85046 and associated computer software VIEWpac 8546A and
ESDUpac A8546

ISBN 0 85679 552 6, ISSN 0141-3988

Available as part of the ESDU Series on Dynamics. For information on all ESDU
validated engineering data contact ESDU International plc, 27 Corsham Street,
London N1 6UA.

This Item considers two classes of quadrature formulae that may be used for the
approximation of definite integrals. They are Newton-Cotes formulae, of both
the open and closed type, in which the abscissae are equally spaced across the
ESDU product release: 2005-03. For current status, contact ESDU. Observe Copyright.

integration interval, and Gauss-Legendre formulae, in which the abscissae are


unequally spaced and determined from the roots of the Legendre polynomials.
General expressions are given for these two classes and tables present the
abscissae and weights for formulae up to seventh-order. The integration error
and choice of formulae are discussed for each method.

This Item further considers an adaptive integration scheme which can distinguish
between regions of high and low functional variation and can adapt the abscissae
step lengths to meet a specified tolerance.

It is shown that all the methods can be modified in a straightforward manner for
the approximation of multiple integrals. It is also shown, through the example
of a double integral, that the integration limits can all be constants (i.e. giving a
rectangular region of integration in the case of a double integral), or the inner
integral limits may be functions of the variable of the outer integral (i.e. the region
of integration is non-rectangular). General guidance is given for coping with
integrals where it is desired to integrate up to or across a singularity of the
integrand.

The Item introduces a computer program together with a full specification for
the approximation of both a single definite integral and a double definite integral
where the region of integration can be rectangular or non-rectangular. The
program is written in Fortran 77 and uses an adaptive quadrature method based
on the standard Simpson’s rule. Examples illustrate the use of the computer
program.

© ESDU International plc, 2002

All rights are reserved. No part of any Data Item may be reprinted, reproduced, or transmitted
in any form or by any means, optical, electronic or mechanical including photocopying,
recording or by any information storage and retrieval system without permission from ESDU
International plc in writing. Save for such permission all copyright and other intellectual
property rights belong to ESDU International plc.

ESDU
TM

Engineering Sciences Data Unit


An IHS GROUP Company

You might also like