d01 Chapter Contents
d01 Chapter Introduction
NAG Library Manual

# NAG Library Function Documentnag_quad_1d_gauss_wset (d01tbc)

## 1  Purpose

nag_quad_1d_gauss_wset (d01tbc) returns the weights and abscissae appropriate to a Gaussian quadrature formula with a specified number of abscissae. The formulae provided are for Gauss–Legendre, rational Gauss, Gauss–Laguerre and Gauss–Hermite.

## 2  Specification

 #include #include

## 3  Description

nag_quad_1d_gauss_wset (d01tbc) returns the weights and abscissae for use in the Gaussian quadrature of a function $f\left(x\right)$. The quadrature takes the form
 $S=∑i=1nwifxi$
where ${w}_{i}$ are the weights and ${x}_{i}$ are the abscissae (see Davis and Rabinowitz (1975), Fröberg (1970), Ralston (1965) or Stroud and Secrest (1966)).
Weights and abscissae are available for Gauss–Legendre, rational Gauss, Gauss–Laguerre and Gauss–Hermite quadrature, and for a selection of values of $n$ (see Section 5).
 $S≃∫abfxdx$
where $a$ and $b$ are finite and it will be exact for any function of the form
 $fx=∑i=0 2n-1cixi.$
 $S≃∫a∞fx dx a+b> 0 or S≃∫-∞a fx dx a+b< 0$
and will be exact for any function of the form
 $fx=∑i=2 2n+1cix+bi=∑i=0 2n-1c2n+1-ix+bix+b2n+1.$
 $S≃∫a∞fx dx b> 0 or S≃∫-∞a fx dx b< 0$
and will be exact for any function of the form
 $fx=e-bx∑i=0 2n-1cixi.$
 $S≃∫-∞ +∞ fx dx$
and will be exact for any function of the form
 $fx=e-b x-a 2∑i=0 2n-1cixi b>0.$
 $S≃∫a∞e-bxfx dx b> 0 or S≃∫-∞a e-bxfx dx b< 0$
and will be exact for any function of the form
 $fx=∑i=0 2n-1cixi.$
 $S≃∫-∞ +∞ e-b x-a 2fx dx$
and will be exact for any function of the form
 $fx=∑i=0 2n-1cixi.$
Note:  the Gauss–Legendre abscissae, with $a=-1$, $b=+1$, are the zeros of the Legendre polynomials; the Gauss–Laguerre abscissae, with $a=0$, $b=1$, are the zeros of the Laguerre polynomials; and the Gauss–Hermite abscissae, with $a=0$, $b=1$, are the zeros of the Hermite polynomials.

## 4  References

Davis P J and Rabinowitz P (1975) Methods of Numerical Integration Academic Press
Fröberg C E (1970) Introduction to Numerical Analysis Addison–Wesley
Ralston A (1965) A First Course in Numerical Analysis pp. 87–90 McGraw–Hill
Stroud A H and Secrest D (1966) Gaussian Quadrature Formulas Prentice–Hall

## 5  Arguments

1:    $\mathbf{quad_type}$Nag_QuadTypeInput
On entry: indicates the quadrature formula.
${\mathbf{quad_type}}=\mathrm{Nag_Quad_Gauss_Legendre}$
Gauss–Legendre quadrature on a finite interval, using normal weights.
${\mathbf{quad_type}}=\mathrm{Nag_Quad_Gauss_Laguerre}$
Gauss–Laguerre quadrature on a semi-infinite interval, using normal weights.
${\mathbf{quad_type}}=\mathrm{Nag_Quad_Gauss_Laguerre_Adjusted}$
${\mathbf{quad_type}}=\mathrm{Nag_Quad_Gauss_Hermite}$
Gauss–Hermite quadrature on an infinite interval, using normal weights.
${\mathbf{quad_type}}=\mathrm{Nag_Quad_Gauss_Hermite_Adjusted}$
${\mathbf{quad_type}}=\mathrm{Nag_Quad_Gauss_Rational_Adjusted}$
Constraint: ${\mathbf{quad_type}}=\mathrm{Nag_Quad_Gauss_Legendre}$, $\mathrm{Nag_Quad_Gauss_Laguerre}$, $\mathrm{Nag_Quad_Gauss_Laguerre_Adjusted}$, $\mathrm{Nag_Quad_Gauss_Hermite}$, $\mathrm{Nag_Quad_Gauss_Hermite_Adjusted}$ or $\mathrm{Nag_Quad_Gauss_Rational_Adjusted}$.
2:    $\mathbf{a}$doubleInput
3:    $\mathbf{b}$doubleInput
On entry: the quantities $a$ and $b$ as described in the appropriate sub-section of Section 3.
Constraints:
• if ${\mathbf{quad_type}}=\mathrm{Nag_Quad_Gauss_Rational_Adjusted}$, ${\mathbf{a}}+{\mathbf{b}}\ne 0.0$;
• if ${\mathbf{quad_type}}=\mathrm{Nag_Quad_Gauss_Laguerre}$ or $\mathrm{Nag_Quad_Gauss_Laguerre_Adjusted}$, ${\mathbf{b}}\ne 0.0$;
• if ${\mathbf{quad_type}}=\mathrm{Nag_Quad_Gauss_Hermite}$ or $\mathrm{Nag_Quad_Gauss_Hermite_Adjusted}$, ${\mathbf{b}}>0.0$.
Constraints:
• Rational Gauss: ${\mathbf{a}}+{\mathbf{b}}\ne 0.0$;
• Gauss–Laguerre: ${\mathbf{b}}\ne 0.0$;
• Gauss–Hermite: ${\mathbf{b}}>0$.
4:    $\mathbf{n}$IntegerInput
On entry: $n$, the number of weights and abscissae to be returned.
Constraint: ${\mathbf{n}}=1$, $2$, $3$, $4$, $5$, $6$, $8$, $10$, $12$, $14$, $16$, $20$, $24$, $32$, $48$ or $64$.
Note: if $n>0$ and is not a member of the above list, the maxmium value of $n$ stored below $n$ will be used, and all subsequent elements of abscis and weight will be returned as zero.
5:    $\mathbf{weight}\left[{\mathbf{n}}\right]$doubleOutput
On exit: the n weights.
6:    $\mathbf{abscis}\left[{\mathbf{n}}\right]$doubleOutput
On exit: the n abscissae.
7:    $\mathbf{fail}$NagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.2.1.2 in the Essential Introduction for further information.
The value of a and/or b is invalid for the chosen quad_type. Either:
• On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
• The value of a and/or b is invalid for Gauss-Hermite quadrature.
On entry, ${\mathbf{quad_type}}=〈\mathit{\text{value}}〉$.
On entry, ${\mathbf{a}}=〈\mathit{\text{value}}〉$ and ${\mathbf{b}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{b}}>0.0$.
• The value of a and/or b is invalid for Gauss-Laguerre quadrature.
On entry, ${\mathbf{quad_type}}=〈\mathit{\text{value}}〉$.
On entry, ${\mathbf{a}}=〈\mathit{\text{value}}〉$ and ${\mathbf{b}}=〈\mathit{\text{value}}〉$.
Constraint: $\left|{\mathbf{b}}\right|>0.0$.
• The value of a and/or b is invalid for rational Gauss quadrature.
On entry, ${\mathbf{quad_type}}=〈\mathit{\text{value}}〉$.
On entry, ${\mathbf{a}}=〈\mathit{\text{value}}〉$ and ${\mathbf{b}}=〈\mathit{\text{value}}〉$.
Constraint: $\left|{\mathbf{a}}+{\mathbf{b}}\right|>0.0$.
NE_INT
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}>0$.
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 3.6.6 in the Essential Introduction for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 3.6.5 in the Essential Introduction for further information.
The n-point rule is not among those stored.
On entry: ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
n-rule used: ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
NE_TOO_SMALL
Underflow occurred in calculation of normal weights.
Reduce n or use adjusted weights: ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
NE_WEIGHT_ZERO
No nonzero weights were generated for the provided parameters.

## 7  Accuracy

The weights and abscissae are stored for standard values of a and b to full machine accuracy.

## 8  Parallelism and Performance

Not applicable.

Timing is negligible.

## 10  Example

This example returns the abscissae and (adjusted) weights for the six-point Gauss–Laguerre formula.

### 10.1  Program Text

Program Text (d01tbce.c)

None.

### 10.3  Program Results

Program Results (d01tbce.r)