Numerical Integration

Contents:

  1. Introduction

  2. QNG non-adaptive Gauss-Kronrod integration

  3. QAG adaptive integration

    1. GSL::Integration::Workspace class

    2. Methods

  4. QAGS adaptive integration with singularities

  5. QAGP adaptive integration with known singular points

  6. QAGI adaptive integration on infinite intervals

  7. QAWC adaptive integration for Cauchy principal values

  8. QAWS adaptive integration for singular functions

  9. QAWO adaptive integration for oscillatory functions

  10. QAWF adaptive integration for Fourier integrals

Introduction

This section describes how to compute numerical integration of a function in one dimension. In Ruby/GSL, all the GSL routines for numerical integration is provided as methods of GSL::Function objects. For example, a GSL::Function object which represents the sine function sin(x) can be expressed as

f = GSL::Function.alloc { |x| sin(x) }

To compute numerical integration of sin(x) over the range (a, b), one can use the methods integrate_xxx or simply xxx, as

QNG non-adaptive Gauss-Kronrod integration


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 object, which handles the memory for the subinterval ranges, results and error estimates.

Workspace class



Algorithms which require the workspace

The algorithms described below require gsl_integration_workspace struct in C. In Ruby/GSL, the corresponding methods require a GSL::Integration::Workspace object in their arguments. But it is also possible to use these methods without workspace arguments: if it is not given, a workspace is created/destroyed internally. Thus method calls are as

f = GSL::Function.alloc { |x| Math::sin(x)/x }
p f.qag([a, b])

or

w = GSL::Integration::Workspace.alloc(limit)
p f.qag([a, b], w)

Explicit uses of a Workspace object reduce C function calls for memory allocations of workspace objects.

Methods


QAGS adaptive integration with singularities

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.


QAGP adaptive integration with known singular points


QAGI adaptive integration on infinite intervals




QAWC adaptive integration for Cauchy principal values


QAWS adaptive integration for singular functions

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.


QAWO adaptive integration for oscillatory functions

The QAWO algorithm is designed for integrands with an oscillatory factor, sin(omega x) or cos(omega x). In order to work efficiently the algorithm requires a table of Chebyshev moments.


QAWF adaptive integration for Fourier integrals


Gauss-Legendre integration

(GSL-1.14) The fixed-order Gauss-Legendre integration routines are provided for fast integration of smooth functions with known polynomial order. The n-point Gauss-Legendre rule is exact for polynomials of order 2*n-1 or less. For example, these rules are useful when integrating basis functions to form mass matrices for the Galerkin method. Unlike other numerical integration routines within the library, these routines do not accept absolute or relative error bounds.



prev next

Reference index top