# NAG CL Interfaced01tec (dim1_​gauss_​recm)

Settings help

CL Name Style:

## 1Purpose

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

## 2Specification

 #include
 void d01tec (Integer n, const double mu[], double a[], double b[], double c[], NagError *fail)
The function may be called by the names: d01tec, nag_quad_dim1_gauss_recm or nag_quad_1d_gauss_recm.

## 3Description

d01tec 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]$const double 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]$double Output
On exit: values helping define the three term recurrence used by d01tdc.
4: $\mathbf{b}\left[{\mathbf{n}}\right]$double Output
On exit: values helping define the three term recurrence used by d01tdc.
5: $\mathbf{c}\left[{\mathbf{n}}\right]$double Output
On exit: values helping define the three term recurrence used by d01tdc.
6: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
On entry, argument $⟨\mathit{\text{value}}⟩$ had an illegal value.
NE_DATA_ILL_CONDITIONED
The problem is too ill conditioned, it breaks down at row $⟨\mathit{\text{value}}⟩$.
NE_INT
The number of weights and abscissae requested (n) is less than $1$: ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.

## 7Accuracy

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

## 8Parallelism and Performance

d01tec is not threaded in any implementation.

Because the function 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 d01tec and subsequently d01tdc, to compare answers.

## 10Example

This example program uses d01tec 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 d01tdc.

### 10.1Program Text

Program Text (d01tece.c)

### 10.2Program Data

Program Data (d01tece.d)

### 10.3Program Results

Program Results (d01tece.r)