# NAG FL Interfaced01tdf (dim1_​gauss_​wrec)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

d01tdf computes the weights and abscissae of a Gaussian quadrature rule using the method of Golub and Welsch.

## 2Specification

Fortran Interface
 Subroutine d01tdf ( n, a, b, c,
 Integer, Intent (In) :: n Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: a(n), muzero Real (Kind=nag_wp), Intent (Inout) :: b(n), c(n) Real (Kind=nag_wp), Intent (Out) :: weight(n), abscis(n)
#include <nag.h>
 void d01tdf_ (const Integer *n, const double a[], double b[], double c[], const double *muzero, double weight[], double abscis[], Integer *ifail)
The routine may be called by the names d01tdf or nagf_quad_dim1_gauss_wrec.

## 3Description

A tri-diagonal system of equations is formed from the coefficients of an underlying three-term recurrence formula:
 $p(j)(x)=(a(j)x+b(j))p(j-1)(x)-c(j)p(j-2)(x)$
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 three-term 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.
Golub G H and Welsch J H (1969) Calculation of Gauss quadrature rules Math. Comput. 23 221–230

## 5Arguments

1: $\mathbf{n}$Integer Input
On entry: $n$, the number of Gauss points required. The resulting quadrature rule will be exact for all polynomials of degree $2n-1$.
Constraint: ${\mathbf{n}}>0$.
2: $\mathbf{a}\left({\mathbf{n}}\right)$Real (Kind=nag_wp) array Input
On entry: a contains the coefficients $a\left(j\right)$.
3: $\mathbf{b}\left({\mathbf{n}}\right)$Real (Kind=nag_wp) array Input/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: $\mathbf{c}\left({\mathbf{n}}\right)$Real (Kind=nag_wp) array Input/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: $\mathbf{muzero}$Real (Kind=nag_wp) Input
On entry: muzero contains the definite integral of the weight function for the interval of interest.
6: $\mathbf{weight}\left({\mathbf{n}}\right)$Real (Kind=nag_wp) array Output
On exit: ${\mathbf{weight}}\left(j\right)$ contains the weight corresponding to the $j$th abscissa.
7: $\mathbf{abscis}\left({\mathbf{n}}\right)$Real (Kind=nag_wp) array Output
On exit: ${\mathbf{abscis}}\left(j\right)$ the $j$th abscissa.
8: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ 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).

## 6Error 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}}=4$
${\mathbf{ifail}}=5$
The algorithm failed to converge. The $i$th diagonal was not zero: $i=⟨\mathit{\text{value}}⟩$.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

## 7Accuracy

In general the computed weights and abscissae are accurate to a reasonable multiple of machine precision.

## 8Parallelism 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 implementation-specific information.

The weight function must be non-negative 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.

## 10Example

This example program generates the weights and abscissae for the $4$-point Gauss rules: Legendre, Chebyshev1, Chebyshev2, Jacobi, Laguerre and Hermite.

### 10.1Program Text

Program Text (d01tdfe.f90)

None.

### 10.3Program Results

Program Results (d01tdfe.r)