NAG Library Function Document
nag_quad_1d_gauss_wrec (d01tdc)
1
Purpose
nag_quad_1d_gauss_wrec (d01tdc) computes the weights and abscissae of a Gaussian quadrature rule using the method of Golub and Welsch.
2
Specification
#include <nag.h> 
#include <nagd01.h> 
void 
nag_quad_1d_gauss_wrec (Integer n,
const double a[],
double b[],
double c[],
double muzero,
double weight[],
double abscis[],
NagError *fail) 

3
Description
A tridiagonal system of equations is formed from the coefficients of an underlying threeterm recurrence formula:
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 threeterm 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 functions are used for the linear algebra to speed up computation.
4
References
Golub G H and Welsch J H (1969) Calculation of Gauss quadrature rules Math. Comput. 23 221–230
5
Arguments
 1:
$\mathbf{n}$ – IntegerInput

On entry: $n$, the number of Gauss points required. The resulting quadrature rule will be exact for all polynomials of degree $2n1$.
Constraint:
${\mathbf{n}}>0$.
 2:
$\mathbf{a}\left[{\mathbf{n}}\right]$ – const doubleInput

On entry:
a contains the coefficients
$a\left(j\right)$.
 3:
$\mathbf{b}\left[{\mathbf{n}}\right]$ – doubleInput/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]$ – doubleInput/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}$ – doubleInput

On entry:
muzero contains the definite integral of the weight function for the interval of interest.
 6:
$\mathbf{weight}\left[{\mathbf{n}}\right]$ – doubleOutput

On exit: ${\mathbf{weight}}\left(j\right)$ contains the weight corresponding to the $j$th abscissa.
 7:
$\mathbf{abscis}\left[{\mathbf{n}}\right]$ – doubleOutput

On exit: ${\mathbf{abscis}}\left(j\right)$ the $j$th abscissa.
 8:
$\mathbf{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 $\u2329\mathit{\text{value}}\u232a$ had an illegal value.
 NE_INT

On entry, ${\mathbf{n}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{n}}\ge 1$.
 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
In general the computed weights and abscissae are accurate to a reasonable multiple of machine precision.
8
Parallelism and Performance
nag_quad_1d_gauss_wrec (d01tdc) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
nag_quad_1d_gauss_wrec (d01tdc) 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 function. Please also consult the
Users' Note for your implementation for any additional implementationspecific information.
The weight function must be nonnegative to obtain sensible results. This and the validity of
muzero are not something that the function 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.
10
Example
This example program generates the weights and abscissae for the $4$point Gauss rules: Legendre, Chebyshev1, Chebyshev2, Jacobi, Laguerre and Hermite.
10.1
Program Text
Program Text (d01tdce.c)
10.2
Program Data
None.
10.3
Program Results
Program Results (d01tdce.r)