Usage Notes

Univariate Quadrature

The first ten functions in this chapter section are designed to compute approximations to integrals of the form

\[\int_c^b f(x)w(x)dx\]

The weight function w is used to incorporate known singularities (either algebraic or logarithmic) or to incorporate oscillations. For general-purpose integration, we recommend the use of intFcnSing (even if no endpoint singularities are present). If more efficiency is desired, then the use of one of the more specialized functions should be considered. These functions are organized as follows:

  • \(w = 1\)

    intFcnSing

    intFcnSing1d

    intFcn

    intFcnSingPts

    intFcnInf

    intFcnSmooth

  • \(w(x) = \sin \omega x\) or \(w(x) = \cos \omega x\)

    intFcnTrig (for a finite interval)

    intFcnFourier (for an infinite interval)

  • \(w(x) = (x − a)^a (b − x)^b \ln(x − a) \ln(b − x)\) where the ln factors are optional

    intFcnAlgLog

  • \(w(x) = 1/(x − c)\)

    intFcnCauchy

The calling sequences for these functions are very similar. The function to be integrated is always fcn, and the lower and upper limits are a and b, respectively. The requested absolute error ɛ is errAbs, while the requested relative error ρ is errRel. These quadrature functions return the estimated answer R. An optional value errEst = E estimates the error. These numbers are related as follows:

\[\left|\int_a^b f(x)w(x)dx - R\right| \leq E \leq \max \left\{\varepsilon,\rho\left| \int_a^b f(x)w(x)dx \right|\right\}\]

One situation that occasionally arises in univariate quadrature concerns the approximation of integrals when only tabular data are given. The functions described above do not directly address this question. However, the standard method for handling this problem is first to interpolate the data, and then to integrate the interpolant. This can be accomplished by using the PyIMSL spline interpolation functions with one of the spline integration functions, which can be found in Interpolation and Approximation

Multivariate Quadrature

Four functions have been included in this chapter that are of use in approximating certain multivariate integrals. In particular, the functions intFcn2d and intFcnSing2d return an approximation to an iterated two-dimensional integral of the form

\[\int_a^b \int_{g(x)}^{h(x)} f(x,y) dy dx\]

while intFcnSing3d returns an approximation to an iterated three-dimensional integral of the form

\[\int_a^b \int_{g(x)}^{h(x)} \int_{p(x,y)}^{q(x,y)} f(x,y,z) dz dy dx\]

The fourth function, intFcnHyperRect, returns an approximation to the integral of a function of n variables over a hyper-rectangle

\[\int_{a_1}^{b_1} \ldots \int_{a_n}^{b_n} f\left(x_1,\ldots,x_n\right) dx_n \ldots dx_1\]

When working with two-dimensional tensor-product tabular data, use the IMSL spline interpolation function spline2dInterp, followed by the PyIMSL spline integration function spline2dIntegral described in Chapter 3, “Interpolation and Approximation”.

Gauss Quadrature

Before computing Gauss quadratures, you must compute so-called Gauss quadrature rules that integrate polynomials of as high degree as possible. These quadrature rules can be easily computed using the function gaussQuadRule, which produces the points \(\{w_i\}\) for \(i = 1, ..., N\) that satisfy

\[\int_a^b f(x)w(x)dx = \sum_{i=1}^{N} f\left(x_i\right)w_i\]

for all functions f that are polynomials of degree less than 2N. The weight functions w may be selected from the following table.

\(w(x)\) Interval Name
1 (-1, 1) Legendre
\(1 / \left( \sqrt{1 - x^2} \right)\) (-1, 1) Chebyshev 1st kind
\(\sqrt{1 - x^2}\) (-1, 1) Chebyshev 2nd kind
\(e^{-x^2}\) (-∞, ∞) Hermite
\((1 + x)^a (1 - x)^b\) (-1, 1) Jacobi
\(e^{-x}x^a\) (0, ∞) Generalized Laguerre
\(1/\cosh(x)\) (-∞, ∞) Hyperbolic cosine

Where permissible, gaussQuadRule also computes Gauss-Radau and Gauss-Lobatto quadrature rules.