NAG C Library Function Document

nag_quad_1d_gauss_recm (d01tec)

1
Purpose

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

2
Specification

#include <nag.h>
#include <nagd01.h>
void  nag_quad_1d_gauss_recm (Integer n, const double mu[], double a[], double b[], double c[], NagError *fail)

3
Description

nag_quad_1d_gauss_recm (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 IntegerInput
On entry: n, the number of weights and abscissae required.
Constraint: n>0.
2:     mu[0:2*n] const doubleInput
On entry: mui must contain the value of the moment with respect to xi i.e., wxxi dx, for i=0,1,,2n.
3:     a[n] doubleOutput
On exit: values helping define the three term recurrence used by nag_quad_1d_gauss_wrec (d01tdc).
4:     b[n] doubleOutput
On exit: values helping define the three term recurrence used by nag_quad_1d_gauss_wrec (d01tdc).
5:     c[n] doubleOutput
On exit: values helping define the three term recurrence used by nag_quad_1d_gauss_wrec (d01tdc).
6:     fail NagError *Input/Output
The NAG error argument (see Section 3.7 in How to Use the NAG Library and its Documentation).

6
Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 2.3.1.2 in How to Use the NAG Library and its Documentation 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 2.7.6 in How to Use the NAG Library and its Documentation for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.

7
Accuracy

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

8
Parallelism and Performance

nag_quad_1d_gauss_recm (d01tec) is not threaded in any implementation.

9
Further Comments

Because the function cannot check the validity of all the data presented, the user is advised to independently check the result, perhaps by integrating a function whose integral is known, using nag_quad_1d_gauss_recm (d01tec) and subsequently nag_quad_1d_gauss_wrec (d01tdc), to compare answers.

10
Example

This example program uses nag_quad_1d_gauss_recm (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 nag_quad_1d_gauss_wrec (d01tdc).

10.1
Program Text

Program Text (d01tece.c)

10.2
Program Data

None.

10.3
Program Results

Program Results (d01tece.r)