| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This chapter describes routines for performing numerical integration (quadrature) of a function in one dimension. There are routines for adaptive and non-adaptive integration of general functions, with specialised routines for specific cases. These include integration over infinite and semi-infinite ranges, singular integrals, including logarithmic singularities, computation of Cauchy principal values and oscillatory integrals. The library reimplements the algorithms used in QUADPACK, a numerical integration package written by Piessens, Doncker-Kapenga, Uberhuber and Kahaner. Fortran code for QUADPACK is available on Netlib.
The functions described in this chapter are declared in the header file ‘gsl_integration.h’.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Each algorithm computes an approximation to a definite integral of the
form,
where
is a weight function (for general integrands
).
The user provides absolute and relative error bounds
which specify the following accuracy requirement,
where
is the numerical approximation obtained by the
algorithm. The algorithms attempt to estimate the absolute error
in such a way that the following inequality
holds,
The routines will fail to converge if the error bounds are too
stringent, but always return the best approximation obtained up to that
stage.
The algorithms in QUADPACK use a naming convention based on the following letters,
|
The algorithms are built on pairs of quadrature rules, a higher order rule and a lower order rule. The higher order rule is used to compute the best approximation to an integral over a small range. The difference between the results of the higher order rule and the lower order rule gives an estimate of the error in the approximation.
| 16.1.1 Integrands without weight functions | ||
| 16.1.2 Integrands with weight functions | ||
| 16.1.3 Integrands with singular weight functions |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The algorithms for general functions (without a weight function) are based on Gauss-Kronrod rules.
A Gauss-Kronrod rule begins with a classical Gaussian quadrature rule of
order
. This is extended with additional points between each of
the abscissae to give a higher order Kronrod rule of order
.
The Kronrod rule is efficient because it reuses existing function
evaluations from the Gaussian rule.
The higher order Kronrod rule is used as the best approximation to the integral, and the difference between the two rules is used as an estimate of the error in the approximation.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
For integrands with weight functions the algorithms use Clenshaw-Curtis quadrature rules.
A Clenshaw-Curtis rule begins with an
-th order Chebyshev
polynomial approximation to the integrand. This polynomial can be
integrated exactly to give an approximation to the integral of the
original function. The Chebyshev expansion can be extended to higher
orders to improve the approximation and provide an estimate of the
error.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The presence of singularities (or other behavior) in the integrand can cause slow convergence in the Chebyshev approximation. The modified Clenshaw-Curtis rules used in QUADPACK separate out several common weight functions which cause slow convergence.
These weight functions are integrated analytically against the Chebyshev polynomials to precompute modified Chebyshev moments. Combining the moments with the Chebyshev approximation to the function gives the desired integral. The use of analytic integration for the singular part of the function allows exact cancellations and substantially improves the overall convergence behavior of the integration.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The QNG algorithm is a non-adaptive procedure which uses fixed Gauss-Kronrod abscissae to sample the integrand at a maximum of 87 points. It is provided for fast integration of smooth functions.
This function applies the Gauss-Kronrod 10-point, 21-point, 43-point and
87-point integration rules in succession until an estimate of the
integral of
over
is achieved within the desired
absolute and relative error limits, epsabs and epsrel. The
function returns the final approximation, result, an estimate of
the absolute error, abserr and the number of function evaluations
used, neval. The Gauss-Kronrod rules are designed in such a way
that each rule uses all the results of its predecessors, in order to
minimize the total number of function evaluations.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The QAG algorithm is a simple adaptive integration procedure. The
integration region is divided into subintervals, and on each iteration
the subinterval with the largest estimated error is bisected. This
reduces the overall error rapidly, as the subintervals become
concentrated around local difficulties in the integrand. These
subintervals are managed by a gsl_integration_workspace struct,
which handles the memory for the subinterval ranges, results and error
estimates.
This function allocates a workspace sufficient to hold n double precision intervals, their integration results and error estimates.
This function frees the memory associated with the workspace w.
This function applies an integration rule adaptively until an estimate
of the integral of
over
is achieved within the
desired absolute and relative error limits, epsabs and
epsrel. The function returns the final approximation,
result, and an estimate of the absolute error, abserr. The
integration rule is determined by the value of key, which should
be chosen from the following symbolic names,
GSL_INTEG_GAUSS15 (key = 1) GSL_INTEG_GAUSS21 (key = 2) GSL_INTEG_GAUSS31 (key = 3) GSL_INTEG_GAUSS41 (key = 4) GSL_INTEG_GAUSS51 (key = 5) GSL_INTEG_GAUSS61 (key = 6) |
corresponding to the 15, 21, 31, 41, 51 and 61 point Gauss-Kronrod rules. The higher-order rules give better accuracy for smooth functions, while lower-order rules save time when the function contains local difficulties, such as discontinuities.
On each iteration the adaptive integration strategy bisects the interval with the largest error estimate. The subintervals and their results are stored in the memory provided by workspace. The maximum number of subintervals is given by limit, which may not exceed the allocated size of the workspace.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The presence of an integrable singularity in the integration region causes an adaptive routine to concentrate new subintervals around the singularity. As the subintervals decrease in size the successive approximations to the integral converge in a limiting fashion. This approach to the limit can be accelerated using an extrapolation procedure. The QAGS algorithm combines adaptive bisection with the Wynn epsilon-algorithm to speed up the integration of many types of integrable singularities.
This function applies the Gauss-Kronrod 21-point integration rule
adaptively until an estimate of the integral of
over
is achieved within the desired absolute and relative error
limits, epsabs and epsrel. The results are extrapolated
using the epsilon-algorithm, which accelerates the convergence of the
integral in the presence of discontinuities and integrable
singularities. The function returns the final approximation from the
extrapolation, result, and an estimate of the absolute error,
abserr. The subintervals and their results are stored in the
memory provided by workspace. The maximum number of subintervals
is given by limit, which may not exceed the allocated size of the
workspace.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This function applies the adaptive integration algorithm QAGS taking
account of the user-supplied locations of singular points. The array
pts of length npts should contain the endpoints of the
integration ranges defined by the integration region and locations of
the singularities. For example, to integrate over the region
with break-points at
(where
) the following pts array should be used
pts[0] = a pts[1] = x_1 pts[2] = x_2 pts[3] = x_3 pts[4] = b |
with npts = 5.
If you know the locations of the singular points in the integration
region then this routine will be faster than QAGS.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This function computes the integral of the function f over the
infinite interval
. The integral is mapped onto the
semi-open interval
using the transformation
,
It is then integrated using the QAGS algorithm. The normal 21-point
Gauss-Kronrod rule of QAGS is replaced by a 15-point rule, because the
transformation can generate an integrable singularity at the origin. In
this case a lower-order rule is more efficient.
This function computes the integral of the function f over the
semi-infinite interval
. The integral is mapped onto the
semi-open interval
using the transformation
,
and then integrated using the QAGS algorithm.
This function computes the integral of the function f over the
semi-infinite interval
. The integral is mapped onto the
semi-open interval
using the transformation
,
and then integrated using the QAGS algorithm.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This function computes the Cauchy principal value of the integral of
over
, with a singularity at c,
The adaptive bisection algorithm of QAG is used, with modifications to
ensure that subdivisions do not occur at the singular point
.
When a subinterval contains the point
or is close to
it then a special 25-point modified Clenshaw-Curtis rule is used to control
the singularity. Further away from the
singularity the algorithm uses an ordinary 15-point Gauss-Kronrod
integration rule.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The QAWS algorithm is designed for integrands with algebraic-logarithmic singularities at the end-points of an integration region. In order to work efficiently the algorithm requires a precomputed table of Chebyshev moments.
This function allocates space for a gsl_integration_qaws_table
struct describing a singular weight function
with the parameters
,
where
,
, and
,
. The weight function can take four different forms
depending on the values of
and
,
The singular points
do not have to be specified until the
integral is computed, where they are the endpoints of the integration
range.
The function returns a pointer to the newly allocated table
gsl_integration_qaws_table if no errors were detected, and 0 in
the case of error.
This function modifies the parameters
of
an existing gsl_integration_qaws_table struct t.
This function frees all the memory associated with the
gsl_integration_qaws_table struct t.
This function computes the integral of the function
over the
interval
with the singular weight function
. The parameters
of the weight function
are taken from the
table t. The integral is,
The adaptive bisection algorithm of QAG is used. When a subinterval
contains one of the endpoints then a special 25-point modified
Clenshaw-Curtis rule is used to control the singularities. For
subintervals which do not include the endpoints an ordinary 15-point
Gauss-Kronrod integration rule is used.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The QAWO algorithm is designed for integrands with an oscillatory
factor,
or
. In order to
work efficiently the algorithm requires a table of Chebyshev moments
which must be pre-computed with calls to the functions below.
This function allocates space for a gsl_integration_qawo_table
struct and its associated workspace describing a sine or cosine weight
function
with the parameters
,
The parameter L must be the length of the interval over which the
function will be integrated
. The choice of sine or
cosine is made with the parameter sine which should be chosen from
one of the two following symbolic values:
GSL_INTEG_COSINE GSL_INTEG_SINE |
The gsl_integration_qawo_table is a table of the trigonometric
coefficients required in the integration process. The parameter n
determines the number of levels of coefficients that are computed. Each
level corresponds to one bisection of the interval
, so that
n levels are sufficient for subintervals down to the length
. The integration routine gsl_integration_qawo
returns the error GSL_ETABLE if the number of levels is
insufficient for the requested accuracy.
This function changes the parameters omega, L and sine of the existing workspace t.
This function allows the length parameter L of the workspace t to be changed.
This function frees all the memory associated with the workspace t.
This function uses an adaptive algorithm to compute the integral of
over
with the weight function
or
defined
by the table wf,
The results are extrapolated using the epsilon-algorithm to accelerate
the convergence of the integral. The function returns the final
approximation from the extrapolation, result, and an estimate of
the absolute error, abserr. The subintervals and their results are
stored in the memory provided by workspace. The maximum number of
subintervals is given by limit, which may not exceed the allocated
size of the workspace.
Those subintervals with “large” widths
where
are
computed using a 25-point Clenshaw-Curtis integration rule, which handles the
oscillatory behavior. Subintervals with a “small” widths where
are computed using a 15-point Gauss-Kronrod integration.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This function attempts to compute a Fourier integral of the function
f over the semi-infinite interval
.
The parameter
and choice of
or
is
taken from the table wf (the length L can take any value,
since it is overridden by this function to a value appropriate for the
fourier integration). The integral is computed using the QAWO algorithm
over each of the subintervals,
where
. The width
is
chosen to cover an odd number of periods so that the contributions from
the intervals alternate in sign and are monotonically decreasing when
f is positive and monotonically decreasing. The sum of this
sequence of contributions is accelerated using the epsilon-algorithm.
This function works to an overall absolute tolerance of
abserr. The following strategy is used: on each interval
the algorithm tries to achieve the tolerance
where
and
.
The sum of the geometric series of contributions from each interval
gives an overall tolerance of abserr.
If the integration of a subinterval leads to difficulties then the
accuracy requirement for subsequent intervals is relaxed,
where
is the estimated error on the interval
.
The subintervals and their results are stored in the memory provided by workspace. The maximum number of subintervals is given by limit, which may not exceed the allocated size of the workspace. The integration over each subinterval uses the memory provided by cycle_workspace as workspace for the QAWO algorithm.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
In addition to the standard error codes for invalid arguments the functions can return the following values,
GSL_EMAXITERthe maximum number of subdivisions was exceeded.
GSL_EROUNDcannot reach tolerance because of roundoff error, or roundoff error was detected in the extrapolation table.
GSL_ESING a non-integrable singularity or other bad integrand behavior was found in the integration interval.
GSL_EDIVERGEthe integral is divergent, or too slowly convergent to be integrated numerically.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The integrator QAGS will handle a large class of definite
integrals. For example, consider the following integral, which has a
algebraic-logarithmic singularity at the origin,
The program below computes this integral to a relative accuracy bound of
1e-7.
|
The results below show that the desired accuracy is achieved after 8 subdivisions.
$ ./a.outresult = -3.999999999999973799 exact result = -4.000000000000000000 estimated error = 0.000000000000246025 actual error = 0.000000000000026201 intervals = 8 |
In fact, the extrapolation procedure used by QAGS produces an
accuracy of almost twice as many digits. The error estimate returned by
the extrapolation procedure is larger than the actual error, giving a
margin of safety of one order of magnitude.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The following book is the definitive reference for QUADPACK, and was written by the original authors. It provides descriptions of the algorithms, program listings, test programs and examples. It also includes useful advice on numerical integration and many references to the numerical integration literature used in developing QUADPACK.
| [ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by Autobuild on September, 26 2007 using texi2html 1.78.