NAG CL Interface
d01tbc (dim1_​gauss_​wres)

Settings help

CL Name Style:


1 Purpose

d01tbc returns the weights and abscissae appropriate to a Gaussian quadrature formula with a specified number of abscissae. The formulae provided are for Gauss–Legendre, rational Gauss, Gauss–Laguerre and Gauss–Hermite.

2 Specification

#include <nag.h>
void  d01tbc (Nag_QuadType quad_type, double a, double b, Integer n, double weight[], double abscis[], NagError *fail)
The function may be called by the names: d01tbc, nag_quad_dim1_gauss_wres or nag_quad_1d_gauss_wset.

3 Description

d01tbc returns the weights and abscissae for use in the Gaussian quadrature of a function f(x). The quadrature takes the form
S=i=1nwif(xi)  
where wi are the weights and xi are the abscissae (see Davis and Rabinowitz (1975), Fröberg (1970), Ralston (1965) or Stroud and Secrest (1966)).
Weights and abscissae are available for Gauss–Legendre, rational Gauss, Gauss–Laguerre and Gauss–Hermite quadrature, and for a selection of values of n (see Section 5).
  1. (a)Gauss–Legendre Quadrature:
    Sabf(x)dx  
    where a and b are finite and it will be exact for any function of the form
    f(x)=i=0 2n-1cixi.  
  2. (b)Rational Gauss quadrature, adjusted weights:
    Saf(x) dx (a+b>0)   or   S-a f(x) dx (a+b<0)  
    and will be exact for any function of the form
    f(x)=i=2 2n+1ci(x+b)i=i=0 2n-1c2n+1-i(x+b)i(x+b)2n+1.  
  3. (c)Gauss–Laguerre quadrature, adjusted weights:
    Saf(x) dx (b>0)   or   S-a f(x) dx (b<0)  
    and will be exact for any function of the form
    f(x)=e-bxi=0 2n-1cixi.  
  4. (d)Gauss–Hermite quadrature, adjusted weights:
    S- + f(x) dx  
    and will be exact for any function of the form
    f(x)=e-b (x-a) 2i=0 2n-1cixi(b>0).  
  5. (e)Gauss–Laguerre quadrature, normal weights:
    Sae-bxf(x) dx (b>0)   or   S-a e-bxf(x) dx (b<0)  
    and will be exact for any function of the form
    f(x)=i=0 2n-1cixi.  
  6. (f)Gauss–Hermite quadrature, normal weights:
    S- + e-b (x-a) 2f(x) dx  
    and will be exact for any function of the form
    f(x)=i=0 2n-1cixi.  
Note:  the Gauss–Legendre abscissae, with a=−1, b=+1, are the zeros of the Legendre polynomials; the Gauss–Laguerre abscissae, with a=0, b=1, are the zeros of the Laguerre polynomials; and the Gauss–Hermite abscissae, with a=0, b=1, are the zeros of the Hermite polynomials.

4 References

Davis P J and Rabinowitz P (1975) Methods of Numerical Integration Academic Press
Fröberg C E (1970) Introduction to Numerical Analysis Addison–Wesley
Ralston A (1965) A First Course in Numerical Analysis pp. 87–90 McGraw–Hill
Stroud A H and Secrest D (1966) Gaussian Quadrature Formulas Prentice–Hall

5 Arguments

1: quad_type Nag_QuadType Input
On entry: indicates the quadrature formula.
quad_type=Nag_Quad_Gauss_Legendre
Gauss–Legendre quadrature on a finite interval, using normal weights.
quad_type=Nag_Quad_Gauss_Laguerre
Gauss–Laguerre quadrature on a semi-infinite interval, using normal weights.
quad_type=Nag_Quad_Gauss_Laguerre_Adjusted
Gauss–Laguerre quadrature on a semi-infinite interval, using adjusted weights.
quad_type=Nag_Quad_Gauss_Hermite
Gauss–Hermite quadrature on an infinite interval, using normal weights.
quad_type=Nag_Quad_Gauss_Hermite_Adjusted
Gauss–Hermite quadrature on an infinite interval, using adjusted weights.
quad_type=Nag_Quad_Gauss_Rational_Adjusted
Rational Gauss quadrature on a semi-infinite interval, using adjusted weights.
Constraint: quad_type=Nag_Quad_Gauss_Legendre, Nag_Quad_Gauss_Laguerre, Nag_Quad_Gauss_Laguerre_Adjusted, Nag_Quad_Gauss_Hermite, Nag_Quad_Gauss_Hermite_Adjusted or Nag_Quad_Gauss_Rational_Adjusted.
2: a double Input
3: b double Input
On entry: the parameters a and b which occur in the quadrature formulae described in Section 3.
Constraints:
  • if quad_type=Nag_Quad_Gauss_Rational_Adjusted, a+b0.0;
  • if quad_type=Nag_Quad_Gauss_Laguerre or Nag_Quad_Gauss_Laguerre_Adjusted, b0.0;
  • if quad_type=Nag_Quad_Gauss_Hermite or Nag_Quad_Gauss_Hermite_Adjusted, b>0.0.
Constraints:
  • Rational Gauss: a+b0.0;
  • Gauss–Laguerre: b0.0;
  • Gauss–Hermite: b>0.
4: n Integer Input
On entry: n, the number of weights and abscissae to be returned.
Constraint: n=1, 2, 3, 4, 5, 6, 8, 10, 12, 14, 16, 20, 24, 32, 48 or 64.
Note: if n>0 and is not a member of the above list, the maxmium value of n stored below n will be used, and all subsequent elements of abscis and weight will be returned as zero.
5: weight[n] double Output
On exit: the n weights.
6: abscis[n] double Output
On exit: the n abscissae.
7: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_BAD_PARAM
The value of a and/or b is invalid for the chosen quad_type. Either:
  • On entry, argument value had an illegal value.
  • The value of a and/or b is invalid for Gauss-Hermite quadrature.
    On entry, quad_type=value.
    On entry, a=value and b=value.
    Constraint: b>0.0.
  • The value of a and/or b is invalid for Gauss-Laguerre quadrature.
    On entry, quad_type=value.
    On entry, a=value and b=value.
    Constraint: |b|>0.0.
  • The value of a and/or b is invalid for rational Gauss quadrature.
    On entry, quad_type=value.
    On entry, a=value and b=value.
    Constraint: |a+b|>0.0.
NE_INT
On entry, n=value.
Constraint: n>0.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
NE_QUAD_GAUSS_NPTS_RULE
The n-point rule is not among those stored.
On entry: n=value.
n-rule used: n=value.
NE_TOO_SMALL
Underflow occurred in calculation of normal weights.
Reduce n or use adjusted weights: n=value.
NE_WEIGHT_ZERO
No nonzero weights were generated for the provided parameters.

7 Accuracy

The weights and abscissae are stored for standard values of a and b to full machine accuracy.

8 Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
d01tbc is not threaded in any implementation.

9 Further Comments

Timing is negligible.

10 Example

This example returns the abscissae and (adjusted) weights for the six-point Gauss–Laguerre formula.

10.1 Program Text

Program Text (d01tbce.c)

10.2 Program Data

Program Data (d01tbce.d)

10.3 Program Results

Program Results (d01tbce.r)