# NAG FL Interfaced01tef (dim1_​gauss_​recm)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

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

## 2Specification

Fortran Interface
 Subroutine d01tef ( n, mu, a, b, c,
 Integer, Intent (In) :: n Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: mu(0:2*n) Real (Kind=nag_wp), Intent (Out) :: a(n), b(n), c(n)
#include <nag.h>
 void d01tef_ (const Integer *n, const double mu[], double a[], double b[], double c[], Integer *ifail)
The routine may be called by the names d01tef or nagf_quad_dim1_gauss_recm.

## 3Description

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.

## 4References

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 weights and abscissae required.
Constraint: ${\mathbf{n}}>0$.
2: $\mathbf{mu}\left(0:2*{\mathbf{n}}\right)$Real (Kind=nag_wp) array Input
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: $\mathbf{a}\left({\mathbf{n}}\right)$Real (Kind=nag_wp) array Output
On exit: values helping define the three term recurrence used by d01tdf.
4: $\mathbf{b}\left({\mathbf{n}}\right)$Real (Kind=nag_wp) array Output
On exit: values helping define the three term recurrence used by d01tdf.
5: $\mathbf{c}\left({\mathbf{n}}\right)$Real (Kind=nag_wp) array Output
On exit: values helping define the three term recurrence used by d01tdf.
6: $\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}}=2$
The problem is too ill conditioned, it breaks down at row $⟨\mathit{\text{value}}⟩$.
${\mathbf{ifail}}=-99$
An unexpected error has been triggered by this routine. Please contact NAG.
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

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

## 8Parallelism and Performance

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

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

## 10Example

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.1Program Text

Program Text (d01tefe.f90)

None.

### 10.3Program Results

Program Results (d01tefe.r)