D01 Chapter Contents
D01 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentD01TBF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

D01TBF 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

 SUBROUTINE D01TBF ( KEY, A, B, N, WEIGHT, ABSCIS, IFAIL)
 INTEGER KEY, N, IFAIL REAL (KIND=nag_wp) A, B, WEIGHT(N), ABSCIS(N)

## 3  Description

D01TBF returns the weights and abscissae for use in the Gaussian quadrature of a function $f\left(x\right)$. The quadrature takes the form
 $S=∑i=1nwifxi$
where ${w}_{i}$ are the weights and ${x}_{i}$ 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).
 $S≃∫abfxdx$
where $a$ and $b$ are finite and it will be exact for any function of the form
 $fx=∑i=0 2n-1cixi.$
 $S≃∫a∞fx dx a+b> 0 or S≃∫-∞a fx dx a+b< 0$
and will be exact for any function of the form
 $fx=∑i=2 2n+1cix+bi=∑i=0 2n-1c2n+1-ix+bix+b2n+1.$
 $S≃∫a∞fx dx b> 0 or S≃∫-∞a fx dx b< 0$
and will be exact for any function of the form
 $fx=e-bx∑i=0 2n-1cixi.$
 $S≃∫-∞ +∞ fx dx$
and will be exact for any function of the form
 $fx=e-b x-a 2∑i=0 2n-1cixi b>0.$
 $S≃∫a∞e-bxfx dx b> 0 or S≃∫-∞a e-bxfx dx b< 0$
and will be exact for any function of the form
 $fx=∑i=0 2n-1cixi.$
 $S≃∫-∞ +∞ e-b x-a 2fx dx$
and will be exact for any function of the form
 $fx=∑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.
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  Parameters

1:     KEY – INTEGERInput
On entry: indicates the quadrature formula.
${\mathbf{KEY}}=0$
Gauss–Legendre quadrature on a finite interval, using normal weights.
${\mathbf{KEY}}=3$
Gauss–Laguerre quadrature on a semi-infinite interval, using normal weights.
${\mathbf{KEY}}=-3$
${\mathbf{KEY}}=4$
Gauss–Hermite quadrature on an infinite interval, using normal weights.
${\mathbf{KEY}}=-4$
${\mathbf{KEY}}=-5$
Constraint: ${\mathbf{KEY}}=0$, $3$, $-3$, $4$, $-4$ or $-5$.
2:     A – REAL (KIND=nag_wp)Input
3:     B – REAL (KIND=nag_wp)Input
On entry: the quantities $a$ and $b$ as described in the appropriate sub-section of Section 3.
Constraints:
• Rational Gauss: ${\mathbf{A}}+{\mathbf{B}}\ne 0.0$;
• Gauss–Laguerre: ${\mathbf{B}}\ne 0.0$;
• Gauss–Hermite: ${\mathbf{B}}>0$.
4:     N – INTEGERInput
On entry: $n$, the number of weights and abscissae to be returned.
Constraint: ${\mathbf{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) – REAL (KIND=nag_wp) arrayOutput
On exit: the N weights.
6:     ABSCIS(N) – REAL (KIND=nag_wp) arrayOutput
On exit: the N abscissae.
7:     IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
The N-point rule is not among those stored.
On entry: ${\mathbf{N}}=⟨\mathit{\text{value}}⟩$.
N-rule used: ${\mathbf{N}}=⟨\mathit{\text{value}}⟩$.
${\mathbf{IFAIL}}=2$
Underflow occurred in calculation of normal weights.
Reduce N or use adjusted weights: ${\mathbf{N}}=⟨\mathit{\text{value}}⟩$.
${\mathbf{IFAIL}}=3$
No nonzero weights were generated for the provided parameters.
${\mathbf{IFAIL}}=11$
On entry, ${\mathbf{KEY}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{KEY}}=0$, $3$, $-3$, $4$, $-4$ or $-5$.
${\mathbf{IFAIL}}=12$
The value of A and/or B is invalid for the chosen KEY. Either:
• The value of A and/or B is invalid for Gauss-Hermite quadrature.
On entry, ${\mathbf{KEY}}=⟨\mathit{\text{value}}⟩$.
On entry, ${\mathbf{A}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{B}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{B}}>0.0$.
• The value of A and/or B is invalid for Gauss-Laguerre quadrature.
On entry, ${\mathbf{KEY}}=⟨\mathit{\text{value}}⟩$.
On entry, ${\mathbf{A}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{B}}=⟨\mathit{\text{value}}⟩$.
Constraint: $\left|{\mathbf{B}}\right|>0.0$.
• The value of A and/or B is invalid for rational Gauss quadrature.
On entry, ${\mathbf{KEY}}=⟨\mathit{\text{value}}⟩$.
On entry, ${\mathbf{A}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{B}}=⟨\mathit{\text{value}}⟩$.
Constraint: $\left|{\mathbf{A}}+{\mathbf{B}}\right|>0.0$.
${\mathbf{IFAIL}}=14$
On entry, ${\mathbf{N}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{N}}>0$.

## 7  Accuracy

The weights and abscissae are stored for standard values of A and B to full machine accuracy.

Timing is negligible.

## 9  Example

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

### 9.1  Program Text

Program Text (d01tbfe.f90)

None.

### 9.3  Program Results

Program Results (d01tbfe.r)