GNU Scientific Library Reference Manual - Third Edition (v1.12)by M. Galassi, J. Davies, J. Theiler, B. Gough, G. Jungman, P. Alken, M. Booth, F. Rossi Paperback (6"x9"), 592 pages, 60 figures ISBN 0954612078 RRP £24.95 ($39.95) |

## 16.3 QAG adaptive integration

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.

__Function:__gsl_integration_workspace ***gsl_integration_workspace_alloc***(size_t*`n`)- This function allocates a workspace sufficient to hold
`n`double precision intervals, their integration results and error estimates.

__Function:__void**gsl_integration_workspace_free***(gsl_integration_workspace **`w`)- This function frees the memory associated with the workspace
`w`.

__Function:__int**gsl_integration_qag***(const gsl_function **`f`, double`a`, double`b`, double`epsabs`, double`epsrel`, size_t`limit`, int`key`, gsl_integration_workspace *`workspace`, double *`result`, double *`abserr`)- This function applies an integration rule adaptively until an estimate
of the integral of f over (a,b) 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.

ISBN 0954612078 | GNU Scientific Library Reference Manual - Third Edition (v1.12) | See the print edition |