NAG Library Routine Document
D01TDF
1 Purpose
D01TDF computes the weights and abscissae of a Gaussian quadrature rule using the method of Golub and Welsch.
2 Specification
INTEGER 
N, IFAIL 
REAL (KIND=nag_wp) 
A(N), B(N), C(N), MUZERO, WEIGHT(N), ABSCIS(N) 

3 Description
A tridiagonal system of equations is formed from the coefficients of an underlying threeterm recurrence formula:
for a set of othogonal polynomials
$p\left(j\right)$ induced by the quadrature. This is described in greater detail in the
D01 Chapter Introduction. The user is required to specify the threeterm recurrence and the value of the integral of the chosen weight function over the chosen interval.
As described in
Golub and Welsch (1969) the abscissae are computed from the eigenvalues of this matrix and the weights from the first component of the eigenvectors.
LAPACK routines are used for the linear algebra to speed up computation.
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 Gauss points required. The resulting quadrature rule will be exact for all polynomials of degree $2n1$.
Constraint:
${\mathbf{N}}>0$.
 2: $\mathrm{A}\left({\mathbf{N}}\right)$ – REAL (KIND=nag_wp) arrayInput

On entry:
A contains the coefficients
$a\left(j\right)$.
 3: $\mathrm{B}\left({\mathbf{N}}\right)$ – REAL (KIND=nag_wp) arrayInput/Output

On entry:
B contains the coefficients
$b\left(j\right)$.
On exit: elements of
B are altered to make the underlying eigenvalue problem symmetric.
 4: $\mathrm{C}\left({\mathbf{N}}\right)$ – REAL (KIND=nag_wp) arrayInput/Output

On entry:
C contains the coefficients
$c\left(j\right)$.
On exit: elements of
C are altered to make the underlying eigenvalue problem symmetric.
 5: $\mathrm{MUZERO}$ – REAL (KIND=nag_wp)Input

On entry:
MUZERO contains the definite integral of the weight function for the interval of interest.
 6: $\mathrm{WEIGHT}\left({\mathbf{N}}\right)$ – REAL (KIND=nag_wp) arrayOutput

On exit: ${\mathbf{WEIGHT}}\left(j\right)$ contains the weight corresponding to the $j$th abscissa.
 7: $\mathrm{ABSCIS}\left({\mathbf{N}}\right)$ – REAL (KIND=nag_wp) arrayOutput

On exit: ${\mathbf{ABSCIS}}\left(j\right)$ the $j$th abscissa.
 8: $\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}}=\u2329\mathit{\text{value}}\u232a$.
 ${\mathbf{IFAIL}}=4$

Unexpected failure in eigenvalue computation. Please contact
NAG.
 ${\mathbf{IFAIL}}=5$

The algorithm failed to converge. The $i$th diagonal was not zero: $i=\u2329\mathit{\text{value}}\u232a$.
 ${\mathbf{IFAIL}}=99$
An unexpected error has been triggered by this routine. Please
contact
NAG.
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
In general the computed weights and abscissae are accurate to a reasonable multiple of machine precision.
8 Parallelism and Performance
D01TDF is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
D01TDF makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the
Users' Note for your implementation for any additional implementationspecific information.
The weight function must be nonnegative to obtain sensible results. This and the validity of
MUZERO are not something that the routine can check, so please be particularly careful. If possible check the computed weights and abscissae by integrating a function with a function for which you already know the integral.
10 Example
This example program generates the weights and abscissae for the $4$point Gauss rules: Legendre, Chebyshev1, Chebyshev2, Jacobi, Laguerre and Hermite.
10.1 Program Text
Program Text (d01tdfe.f90)
10.2 Program Data
None.
10.3 Program Results
Program Results (d01tdfe.r)