NAG CL Interface
d01tec (dim1_​gauss_​recm)

Settings help

CL Name Style:


1 Purpose

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

2 Specification

#include <nag.h>
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.

3 Description

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.

4 References

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

5 Arguments

1: n Integer Input
On entry: n, the number of weights and abscissae required.
Constraint: n>0.
2: mu[0:2*n] const double Input
On entry: mu[i] must contain the value of the moment with respect to xi i.e., w(x)xi dx, for i=0,1,,2n.
3: a[n] double Output
On exit: values helping define the three term recurrence used by d01tdc.
4: b[n] double Output
On exit: values helping define the three term recurrence used by d01tdc.
5: c[n] double Output
On exit: values helping define the three term recurrence used by d01tdc.
6: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error 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.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_DATA_ILL_CONDITIONED
The problem is too ill conditioned, it breaks down at row value.
NE_INT
The number of weights and abscissae requested (n) is less than 1: n=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.

7 Accuracy

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

8 Parallelism and Performance

d01tec is not threaded in any implementation.

9 Further Comments

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.

10 Example

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

Program Text (d01tece.c)

10.2 Program Data

Program Data (d01tece.d)

10.3 Program Results

Program Results (d01tece.r)