IMSL_GQUAD

Syntax | Arguments | Keywords | Discussion | Example | Version History

The IMSL_GQUAD procedure computes a Gauss, Gauss-Radau, or Gauss-Lobatto quadrature rule with various classical weight functions.

Note
This routine requires an IDL Advanced Math and Stats license. For more information, contact your ITT Visual Information Solutions sales or technical support representative.

Syntax

IMSL_GQUAD, n, weights, points [, /CHEBY_FIRST] [, /CHEBY_SECOND] [, /COSH] [, /DOUBLE] [, /HERMITE] [, JACOBI=vector] [, LAGUERRE=parameter] [, FIXED_POINTS=vector]

Arguments

n

The number of quadrature points.

weights

A named variable that will contain an array of length n containing the quadrature weights.

points

A named variable that will contain 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

Set this keyword to compute the Gauss points and weights using the weight function:

IMSL_GQUAD-43.jpg

on the interval (–1, 1).

CHEBY_SECOND

Set this keyword to compute the Gauss points and weights using the weight function:

IMSL_GQUAD-44.jpg

on the interval (–1, 1).

COSH

Set this keyword to computes the Gauss points and weights using the weight function
1/cosh (x) on the interval ( –infinity, infinity ).

DOUBLE

Set this keyword to perform computations using double precision.

HERMITE

Set this keyword to compute the Gauss points and weights using the weight function exp (–x2) on the interval ( –infinity, infinity ).

JACOBI

Set this keyword equal to a two-element vector containing the parameters α and β to be used in the weight function IMSL_GQUAD-45.jpg. If this keyword is present, IMSL_GQUAD computes the Gauss points and weights using the weight function IMSL_GQUAD-46.jpg on the interval (–1, 1).

LAGUERRE

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, infinity).

FIXED_POINTS

Set this keyword equal to a one- or two-element vector specifying the fixed points.

Discussion

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:

IMSL_GQUAD-47.jpg

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 2NF, 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:

IMSL_GQUAD-48.jpg

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 
; Call IMSL_GQUAD to get the weights and points. 
error = FLTARR(7) 
; Define an array to hold the errors. 
FOR i = 0, 6 DO error(i) = $ 
   (TOTAL(weights*(points^i))-(1-(i MOD 2))*2./(i+1)) 
   ; Compute the errors for seven monomials. 
PM, 'Error:', error 
; Output the results. 
Error: 
    -2.38419e-07 
     2.68221e-07 
    -5.96046e-08 
     2.08616e-07 
     2.98023e-08 
     1.78814e-07 
    -0.0457142 

Version History

6.4

Introduced