D01 Chapter Contents
D01 Chapter Introduction
NAG Library Manual

NAG Library Routine DocumentD01TEF

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

Given the $2n+l$ moments of the weight function, D01TEF generates the recursion coefficients needed by D01TDF to calculate a Gaussian quadrature rule.

2  Specification

 SUBROUTINE D01TEF ( N, MU, A, B, C, IFAIL)
 INTEGER N, IFAIL REAL (KIND=nag_wp) MU(0:2*N), A(N), B(N), C(N)

3  Description

D01TEF should only be used if the three-term recurrence cannot be determined analytically. A system of equations are formed, using the moments provided. This set of equations becomes ill-conditioned for moderate values of $n$, the number of abscissae and weights required. In most implementations quadruple precision calculation is used to maintain as much accuracy as possible.

4  References

Golub G H and Welsch J H (1969) Calculation of Gauss quadrature rules Math. Comput. 23 221–230

5  Arguments

1:     $\mathrm{N}$ – INTEGERInput
On entry: $n$, the number of weights and abscissae required.
Constraint: ${\mathbf{N}}>0$.
2:     $\mathrm{MU}\left(0:2*{\mathbf{N}}\right)$ – REAL (KIND=nag_wp) arrayInput
On entry: ${\mathbf{MU}}\left(i\right)$ must contain the value of the moment with respect to ${x}^{i}$ i.e., , for $\mathit{i}=0,1,\dots ,2n$.
3:     $\mathrm{A}\left({\mathbf{N}}\right)$ – REAL (KIND=nag_wp) arrayOutput
On exit: values helping define the three term recurrence used by D01TDF.
4:     $\mathrm{B}\left({\mathbf{N}}\right)$ – REAL (KIND=nag_wp) arrayOutput
On exit: values helping define the three term recurrence used by D01TDF.
5:     $\mathrm{C}\left({\mathbf{N}}\right)$ – REAL (KIND=nag_wp) arrayOutput
On exit: values helping define the three term recurrence used by D01TDF.
6:     $\mathrm{IFAIL}$ – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation 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 argument, 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}}=0$ or $-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 number of weights and abscissae requested (N) is less than $1$: ${\mathbf{N}}=〈\mathit{\text{value}}〉$.
${\mathbf{IFAIL}}=2$
The problem is too ill conditioned, it breaks down at row $〈\mathit{\text{value}}〉$.
${\mathbf{IFAIL}}=-99$
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{IFAIL}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{IFAIL}}=-999$
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

7  Accuracy

Internally quadruple precision is used to minimize loss of accuracy as much as possible.

8  Parallelism and Performance

D01TEF is not threaded in any implementation.

Because the routine cannot check the validity of all the data presented, the user is advised to independently check the result, perhaps by integrating a function whose integral is known, using D01TEF and subsequently D01TDF, to compare answers.

10  Example

This example program uses D01TEF and moments to calculate a three-term recurrence relationship appropriate for Gauss–Legendre quadrature. It then uses the recurrence relationship to derive the weights and abscissae by calling D01TDF.

10.1  Program Text

Program Text (d01tefe.f90)

None.

10.3  Program Results

Program Results (d01tefe.r)