The IMSL_GQUAD procedure computes a Gauss, Gauss-Radau, or Gauss-Lobatto quadrature rule with various classical weight functions.
This routine requires an IDL Advanced Math and Stats license. For more information, contact your sales or technical support representative.
The IMSL_GQUAD procedure produces the points and weights for the Gauss, Gauss-Radau, or Gauss-Lobatto quadrature formulas for some of the most popular weights. The default weight is the weight function identically equal to 1 on the interval (–1, 1). In fact, it is slightly more general than this suggests because the extra one or two points that can be specified do not have to lie at the endpoints of the interval. This procedure is a modification of the subroutine GAUSSQUADRULE (Golub and Welsch 1969).
In the default case, the procedure returns points in x = Points and weights in w = Weights so that:
for all functions f that are polynomials of degree less than 2N.
If the keyword FIXED_POINTS is specified, then one or two of the above xi is equal to the values specified by FIXED_POINTS. In general, the accuracy of the above quadrature formula degrades when n increases. The quadrature rule integrates all functions f that are polynomials of degree less than 2N – F, where F is the number of fixed points.
Example
This example computes the three-point Gauss Legendre quadrature points and weights, then uses them to approximate the integrals as follows:
Notice that the integrals are exact for the first six monomials, but the last approximation is in error. In general, the Gauss rules with k-points integrate polynomials with degree less than 2k exactly.
IMSL_GQUAD, 3, weights, points
error = FLTARR(7)
FOR i = 0, 6 DO error(i) = $
(TOTAL(weights*(points^i))-(1-(i MOD 2))*2./(i+1))
PM, 'Error:', error
IDL prints:
Error:
-2.38419e-07
2.68221e-07
-5.96046e-08
2.08616e-07
2.98023e-08
1.78814e-07
-0.0457142
Syntax
Result = IMSL_GQUAD, n, Weights, Points [, /CHEBY_FIRST] [, /CHEBY_SECOND] [, /COSH] [, /DOUBLE] [, /HERMITE] [, JACOBI=vector] [, LAGUERRE=parameter] [, FIXED_POINTS=vector]
Return Value
See the discussion above for the returned value.
If no value can be computed, the floating-point value NaN (Not a Number) is returned.
Arguments
N
The number of quadrature points.
Weights
A named variable in the form of an array of length n containing the quadrature weights.
Points
A named variable in the form of an array of length n containing quadrature points. The default action of this routine is to produce the Gauss Legendre points and weights.
Keywords
CHEBY_FIRST (optional)
Set this keyword to compute the Gauss points and weights using the weight function:
on the interval (–1, 1).
CHEBY_SECOND (optional)
Set this keyword to compute the Gauss points and weights using the weight function:
on the interval (–1, 1).
COSH (optional)
Set this keyword to computes the Gauss points and weights using the weight function 1/cosh (x) on the interval (–∞, ∞).
DOUBLE (optional)
Set this keyword to perform computations using double precision.
HERMITE (optional)
Set this keyword to compute the Gauss points and weights using the weight function exp (–x2) on the interval (–∞, ∞).
JACOBI (optional)
Set this keyword equal to a two-element vector containing the parameters α and β to be used in the weight function (1 – x )α( 1 + x)β . If this keyword is present, IMSL_GQUAD computes the Gauss points and weights using the weight function (1 – x )α(1 + x )β on the interval (–1, 1).
LAGUERRE (optional)
Set this keyword equal to a scalar parameter α to be used in the weight function exp (–x) xα. If this keyword is present, IMSL_GQUAD computes the Gauss points and weights using the weight function exp (–x) xa on the interval (0, ∞).
FIXED_POINTS (optional)
Set this keyword equal to a one- or two-element vector specifying the fixed points.
- If FIXED_POINTS is a scalar or one-element vector, IMSL_GQUAD computes the Gauss-Radau points and weights using the specified weight function and the fixed point. This formula integrates polynomials of degree less than 2N–1 exactly.
- If FIXED_POINTS is a two-element vector, IMSL_GQUAD computes the Gauss-Lobatto points and weights using the specified weight function and the fixed points. This formula integrates polynomials of degree less than 2N–2 exactly.
Version History