﻿ d01bc Method
d01bc returns the weights (normal or adjusted) and abscissae for a Gaussian integration rule with a specified number of abscissae. Six different types of Gauss rule are allowed.

# Syntax

C#
```public static void d01bc(
int itype,
double a,
double b,
double c,
double d,
int n,
double[] weight,
double[] abscis,
out int ifail
)```
Visual Basic
```Public Shared Sub d01bc ( _
itype As Integer, _
a As Double, _
b As Double, _
c As Double, _
d As Double, _
n As Integer, _
weight As Double(), _
abscis As Double(), _
<OutAttribute> ByRef ifail As Integer _
)```
Visual C++
```public:
static void d01bc(
int itype,
double a,
double b,
double c,
double d,
int n,
array<double>^ weight,
array<double>^ abscis,
[OutAttribute] int% ifail
)```
F#
```static member d01bc :
itype : int *
a : float *
b : float *
c : float *
d : float *
n : int *
weight : float[] *
abscis : float[] *
ifail : int byref -> unit
```

#### Parameters

itype
Type: System..::..Int32
On entry: indicates the type of quadrature rule.
${\mathbf{itype}}=0$
Gauss–Legendre, with normal weights.
${\mathbf{itype}}=1$
Gauss–Jacobi, with normal weights.
${\mathbf{itype}}=-1$
${\mathbf{itype}}=2$
Exponential Gauss, with normal weights.
${\mathbf{itype}}=-2$
${\mathbf{itype}}=3$
Gauss–Laguerre, with normal weights.
${\mathbf{itype}}=-3$
${\mathbf{itype}}=4$
Gauss–Hermite, with normal weights.
${\mathbf{itype}}=-4$
${\mathbf{itype}}=5$
Rational Gauss, with normal weights.
${\mathbf{itype}}=-5$
Constraint: ${\mathbf{itype}}=0$, $1$, $-1$, $2$, $-2$, $3$, $-3$, $4$, $-4$, $5$ or $-5$.
a
Type: System..::..Double
On entry: the parameters $a$, $b$, $c$ and $d$ which occur in the quadrature formulae. c is not used if ${\mathbf{itype}}=0$; d is not used unless ${\mathbf{itype}}=1$, $-1$, $5$ or $-5$. For some rules c and d must not be too large (see [Error Indicators and Warnings]).
b
Type: System..::..Double
On entry: the parameters $a$, $b$, $c$ and $d$ which occur in the quadrature formulae. c is not used if ${\mathbf{itype}}=0$; d is not used unless ${\mathbf{itype}}=1$, $-1$, $5$ or $-5$. For some rules c and d must not be too large (see [Error Indicators and Warnings]).
c
Type: System..::..Double
On entry: the parameters $a$, $b$, $c$ and $d$ which occur in the quadrature formulae. c is not used if ${\mathbf{itype}}=0$; d is not used unless ${\mathbf{itype}}=1$, $-1$, $5$ or $-5$. For some rules c and d must not be too large (see [Error Indicators and Warnings]).
d
Type: System..::..Double
On entry: the parameters $a$, $b$, $c$ and $d$ which occur in the quadrature formulae. c is not used if ${\mathbf{itype}}=0$; d is not used unless ${\mathbf{itype}}=1$, $-1$, $5$ or $-5$. For some rules c and d must not be too large (see [Error Indicators and Warnings]).
n
Type: System..::..Int32
On entry: $n$, the number of weights and abscissae to be returned. If ${\mathbf{itype}}=-2$ or $-4$ and ${\mathbf{c}}\ne 0.0$, an odd value of n may raise problems (see ${\mathbf{ifail}}={6}$).
Constraint: ${\mathbf{n}}>0$.
weight
Type: array<System..::..Double>[]()[][]
An array of size [n]
On exit: the n weights.
abscis
Type: array<System..::..Double>[]()[][]
An array of size [n]
On exit: the n abscissae.
ifail
Type: System..::..Int32%
On exit: ${\mathbf{ifail}}={0}$ unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

# Description

d01bc returns the weights ${w}_{i}$ and abscissae ${x}_{i}$ for use in the summation
 $S=∑i=1nwifxi$
which approximates a definite integral (see Davis and Rabinowitz (1975) or Stroud and Secrest (1966)). The following types are provided:
(a) Gauss–Legendre
 $S≃∫abfxdx, exact for ​fx=P2n-1x.$
Constraint: $b>a$.
(b) Gauss–Jacobi
normal weights:
 $S≃∫abb-xcx-adfxdx, exact for ​fx=P2n-1x,$
 $S≃∫abfxdx, exact for ​fx=b-xcx-adP2n-1x.$
Constraint: $c>-1$, $d>-1$, $b>a$.
(c) Exponential Gauss
normal weights:
 $S≃∫abx-a+b2cfxdx, exact for ​fx=P2n-1x,$
 $S≃∫abfxdx, exact for ​fx=x-a+b2cP2n-1x.$
Constraint: $c>-1$, $b>a$.
(d) Gauss–Laguerre
normal weights:
 $S≃∫a∞x-ace-bxfxdx b>0,≃∫-∞ax-ace-bxfxdx b<0, exact for ​fx=P2n-1x,$
 $S≃∫a∞fxdx b>0,≃∫-∞afxdx b<0, exact for ​fx=x-ace-bxP2n-1x.$
Constraint: $c>-1$, $b\ne 0$.
(e) Gauss–Hermite
normal weights:
 $S≃∫-∞+∞x-ace-bx-a2fxdx, exact for ​fx=P2n-1x,$
 $S≃∫-∞+∞fxdx, exact for ​fx=x-ace-bx-a2P2n-1x.$
Constraint: $c>-1$, $b>0$.
(f) Rational Gauss
normal weights:
 $S≃∫a∞x-acx+bdfxdx a+b>0,≃∫-∞ax-acx+bdfxdx a+b<0, exact for ​fx=P2n-11x+b,$
 $S≃∫a∞fxdx a+b>0,≃∫-∞afxdx a+b<0, exact for ​fx=x-acx+bdP2n-11x+b.$
Constraint: $c>-1$, $d>c+1$, $a+b\ne 0$.
In the above formulae, ${P}_{2n-1}\left(x\right)$ stands for any polynomial of degree $2n-1$ or less in $x$.
The method used to calculate the abscissae involves finding the eigenvalues of the appropriate tridiagonal matrix (see Golub and Welsch (1969)). The weights are then determined by the formula
 $wi=∑j=0n-1Pj*xi2-1$
where ${P}_{j}^{*}\left(x\right)$ is the $j$th orthogonal polynomial with respect to the weight function over the appropriate interval.
The weights and abscissae produced by d01bc may be passed to (D01FBF not in this release), which will evaluate the summations in one or more dimensions.

# References

Davis P J and Rabinowitz P (1975) Methods of Numerical Integration Academic Press
Golub G H and Welsch J H (1969) Calculation of Gauss quadrature rules Math. Comput. 23 221–230
Stroud A H and Secrest D (1966) Gaussian Quadrature Formulas Prentice–Hall

# Error Indicators and Warnings

Errors or warnings detected by the method:
${\mathbf{ifail}}=1$
The algorithm for computing eigenvalues of a tridiagonal matrix has failed to obtain convergence. If the soft fail option is used, the values of the weights and abscissae on return are indeterminate.
${\mathbf{ifail}}=2$
 On entry, ${\mathbf{n}}<1$, or ${\mathbf{itype}}<-5$, or ${\mathbf{itype}}>5$.
If the soft fail option is used, weights and abscissae are returned as zero.
${\mathbf{ifail}}=3$
a, b, c or d is not in the allowed range:
• if ${\mathbf{itype}}=0$, ${\mathbf{a}}\ge {\mathbf{b}}$;
• if ${\mathbf{itype}}=±1$, ${\mathbf{a}}\ge {\mathbf{b}}$ or ${\mathbf{c}}\le -1.0$ or ${\mathbf{d}}\le -1.0$ or ${\mathbf{c}}+{\mathbf{d}}+2.0>\mathit{gmax}$;
• if ${\mathbf{itype}}=±2$, ${\mathbf{a}}\ge {\mathbf{b}}$ or ${\mathbf{c}}\le -1.0$;
• if ${\mathbf{itype}}=±3$, ${\mathbf{b}}=0.0$ or ${\mathbf{c}}\le -1.0$ or ${\mathbf{c}}+1.0>\mathit{gmax}$;
• if ${\mathbf{itype}}=±4$, ${\mathbf{b}}\le 0.0$ or ${\mathbf{c}}\le -1.0$ or $\left({\mathbf{c}}+1.0/2.0\right)>\mathit{gmax}$;
• if ${\mathbf{itype}}=±5$, ${\mathbf{a}}+{\mathbf{b}}=0.0$ or ${\mathbf{c}}\le -1.0$ or ${\mathbf{d}}\le {\mathbf{c}}+1.0$.
Here $\mathit{gmax}$ is the (machine-dependent) largest integer value such that $\Gamma \left(\mathit{gmax}\right)$ can be computed without overflow.
If the soft fail option is used, weights and abscissae are returned as zero.
${\mathbf{ifail}}=4$
One or more of the weights are larger than $\mathit{rmax}$, the largest floating-point number on this machine. $\mathit{rmax}$ is given by the function x02al. If the soft fail option is used, the overflowing weights are returned as $\mathit{rmax}$. Possible solutions are to use a smaller value of n; or, if using adjusted weights, to change to normal weights.
${\mathbf{ifail}}=5$
One or more of the weights are too small to be distinguished from zero on this machine. If the soft fail option is used, the underflowing weights are returned as zero, which may be a usable approximation. Possible solutions are to use a smaller value of n; or, if using normal weights, to change to adjusted weights.
${\mathbf{ifail}}=6$
Exponential Gauss or Gauss–Hermite adjusted weights with n odd and ${\mathbf{c}}\ne 0.0$. Theoretically, in these cases:
• for ${\mathbf{c}}>0.0$, the central adjusted weight is infinite, and the exact function $f\left(x\right)$ is zero at the central abscissa.
• for ${\mathbf{c}}<0.0$, the central adjusted weight is zero, and the exact function $f\left(x\right)$ is infinite at the central abscissa.
In either case, the contribution of the central abscissa to the summation is indeterminate.
In practice, the central weight may not have overflowed or underflowed, if there is sufficient rounding error in the value of the central abscissa.
If the soft fail option is used, the weights and abscissa returned may be usable; you must be particularly careful not to ‘round’ the central abscissa to its true value without simultaneously ‘rounding’ the central weight to zero or $\infty$ as appropriate, or the summation will suffer. It would be preferable to use normal weights, if possible.
Note:  remember that, when switching from normal weights to adjusted weights or vice versa, redefinition of $f\left(x\right)$ is involved.
${\mathbf{ifail}}=-9000$
An error occured, see message report.
${\mathbf{ifail}}=-8000$
Negative dimension for array $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-6000$
Invalid Parameters $〈\mathit{\text{value}}〉$

# Accuracy

The accuracy depends mainly on $n$, with increasing loss of accuracy for larger values of $n$. Typically, one or two decimal digits may be lost from machine accuracy with $n\simeq 20$, and three or four decimal digits may be lost for $n\simeq 100$.

# Parallelism and Performance

None.

The major portion of the time is taken up during the calculation of the eigenvalues of the appropriate tridiagonal matrix, where the time is roughly proportional to ${n}^{3}$.

# Example

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

Example program (C#): d01bce.cs

Example program results: d01bce.r