NAG Library Routine Document

d01bcf  (dim1_gauss_wgen)

 Contents

    1  Purpose
    7  Accuracy

1
Purpose

d01bcf 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.

2
Specification

Fortran Interface
Subroutine d01bcf ( itype, a, b, c, d, n, weight, abscis, ifail)
Integer, Intent (In):: itype, n
Integer, Intent (Inout):: ifail
Real (Kind=nag_wp), Intent (In):: a, b, c, d
Real (Kind=nag_wp), Intent (Out):: weight(n), abscis(n)
C Header Interface
#include nagmk26.h
void  d01bcf_ ( const Integer *itype, const double *a, const double *b, const double *c, const double *d, const Integer *n, double weight[], double abscis[], Integer *ifail)

3
Description

d01bcf returns the weights wi and abscissae xi 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
Sab fxdx,   exact for ​fx=P2n- 1x.  
Constraint: b>a.
(b) Gauss–Jacobi
normal weights:
Sabb-xcx-adfxdx,   exact for ​fx=P2n-1x,  
adjusted weights:
Sab fxdx,   exact for ​fx=b-xcx-ad P2n- 1x.  
Constraint: c>-1, d>-1, b>a.
(c) Exponential Gauss
normal weights:
S ab x- a+b 2 c fxdx,   exact for ​fx=P2n-1x,  
adjusted weights:
S ab fxdx,   exact for ​fx = x-a+b2 c P2n- 1 x.  
Constraint: c>-1, b>a.
(d) Gauss–Laguerre
normal weights:
S ax-ace-bxfxdxb>0, -ax-ace-bxfxdxb<0,   exact for ​fx=P2n-1x,  
adjusted weights:
S a fx dx b> 0, -a fx dx b< 0,   exact for ​fx=x-ace-bxP2n- 1x.  
Constraint: c>-1, b0.
(e) Gauss–Hermite
normal weights:
S- +x-ace-b x-a 2fxdx,   exact for ​fx=P2n-1x,  
adjusted weights:
S- + fxdx,   exact for ​fx=x-ac e-b x-a 2 P2n- 1x.  
Constraint: c>-1, b>0.
(f) Rational Gauss
normal weights:
S ax-acx+bdfxdxa+b>0, -ax-acx+bdfxdxa+b<0,   exact for ​fx=P2n-1 1x+b ,  
adjusted weights:
S a fx dx a+b> 0, -a fx dx a+b< 0,   exact for ​fx=x-acx+bd P2n- 1 1x+b .  
Constraint: c>-1, d>c+1, a+b0.
In the above formulae, P2n-1x 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=0 n-1Pj* xi 2 -1  
where Pj*x is the jth orthogonal polynomial with respect to the weight function over the appropriate interval.
The weights and abscissae produced by d01bcf may be passed to d01fbf, which will evaluate the summations in one or more dimensions.

4
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

5
Arguments

1:     itype – IntegerInput
On entry: indicates the type of quadrature rule.
itype=0
Gauss–Legendre, with normal weights.
itype=1
Gauss–Jacobi, with normal weights.
itype=-1
Gauss–Jacobi, with adjusted weights.
itype=2
Exponential Gauss, with normal weights.
itype=-2
Exponential Gauss, with adjusted weights.
itype=3
Gauss–Laguerre, with normal weights.
itype=-3
Gauss–Laguerre, with adjusted weights.
itype=4
Gauss–Hermite, with normal weights.
itype=-4
Gauss–Hermite, with adjusted weights.
itype=5
Rational Gauss, with normal weights.
itype=-5
Rational Gauss, with adjusted weights.
Constraint: itype=0, 1, -1, 2, -2, 3, -3, 4, -4, 5 or -5.
2:     a – Real (Kind=nag_wp)Input
3:     b – Real (Kind=nag_wp)Input
4:     c – Real (Kind=nag_wp)Input
5:     d – Real (Kind=nag_wp)Input
On entry: the parameters a, b, c and d which occur in the quadrature formulae. c is not used if itype=0; d is not used unless itype=1, -1, 5 or -5. For some rules c and d must not be too large (see Section 6).
6:     n – IntegerInput
On entry: n, the number of weights and abscissae to be returned. If itype=-2 or -4 and c0.0, an odd value of n may raise problems (see ifail=6).
Constraint: n>0.
7:     weightn – Real (Kind=nag_wp) arrayOutput
On exit: the n weights.
8:     abscisn – Real (Kind=nag_wp) arrayOutput
On exit: the n abscissae.
9:     ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1​ or ​1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this argument, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6
Error Indicators and Warnings

If on entry ifail=0 or -1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
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.
ifail=2
On entry,n<1,
oritype<-5,
oritype>5.
If the soft fail option is used, weights and abscissae are returned as zero.
ifail=3
a, b, c or d is not in the allowed range:
  • if itype=0, ab;
  • if itype=±1, ab or c-1.0 or d-1.0 or c+d+2.0>gmax;
  • if itype=±2, ab or c-1.0;
  • if itype=±3, b=0.0 or c-1.0 or c+1.0>gmax;
  • if itype=±4, b0.0 or c-1.0 or c+1.0/2.0>gmax;
  • if itype=±5, a+b=0.0 or c-1.0 or dc+1.0.
Here gmax is the (machine-dependent) largest integer value such that Γgmax can be computed without overflow (see the Users' Note for your implementation for s14aaf).
If the soft fail option is used, weights and abscissae are returned as zero.
ifail=4
One or more of the weights are larger than rmax, the largest floating-point number on this machine. rmax is given by the function x02alf. If the soft fail option is used, the overflowing weights are returned as rmax. Possible solutions are to use a smaller value of n; or, if using adjusted weights, to change to normal weights.
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.
ifail=6
Exponential Gauss or Gauss–Hermite adjusted weights with n odd and c0.0. Theoretically, in these cases:
  • for c>0.0, the central adjusted weight is infinite, and the exact function fx is zero at the central abscissa.
  • for c<0.0, the central adjusted weight is zero, and the exact function fx 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  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 fx is involved.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

7
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 n20, and three or four decimal digits may be lost for n100.

8
Parallelism and Performance

d01bcf 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 routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

9
Further Comments

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 n3.

10
Example

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

10.1
Program Text

Program Text (d01bcfe.f90)

10.2
Program Data

None.

10.3
Program Results

Program Results (d01bcfe.r)

GnuplotProduced by GNUPLOT 4.6 patchlevel 3 0 1 2 3 4 5 6 7 8 9 −5 0 5 10 15 20 25 Weights at Abscissae x Example Program Abscissae and Weights for the 7-point Gauss-Laguerre Formula (a=0, b=1) gnuplot_plot_1
© The Numerical Algorithms Group Ltd, Oxford, UK. 2017