Function: dim1_gauss_wres
NAG CPP Interface
nagcpp::quad::dim1_gauss_wres (d01tb)
Function: dim1_gauss_wres
1
Purpose
dim1_gauss_wres 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 "d01/nagcpp_d01tb.hpp"
template <typename WEIGHT, typename ABSCIS>
void function dim1_gauss_wres(const types::f77_integer key, const double a, const double b, const types::f77_integer n, WEIGHT &&weight, ABSCIS &&abscis, OptionalD01TB opt)
template <typename WEIGHT, typename ABSCIS>
void function dim1_gauss_wres(const types::f77_integer key, const double a, const double b, const types::f77_integer n, WEIGHT &&weight, ABSCIS &&abscis)
3
Description
dim1_gauss_wres returns the weights and abscissae for use in the Gaussian quadrature of a function
. The quadrature takes the form
where
are the weights and
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
(see
Section 5).
-
(a)Gauss–Legendre Quadrature:
where and are finite and it will be exact for any function of the form
-
(b)Rational Gauss quadrature, adjusted weights:
and will be exact for any function of the form
-
(c)Gauss–Laguerre quadrature, adjusted weights:
and will be exact for any function of the form
-
(d)Gauss–Hermite quadrature, adjusted weights:
and will be exact for any function of the form
-
(e)Gauss–Laguerre quadrature, normal weights:
and will be exact for any function of the form
-
(f)Gauss–Hermite quadrature, normal weights:
and will be exact for any function of the form
Note: the Gauss–Legendre abscissae, with
,
, are the zeros of the Legendre polynomials; the Gauss–Laguerre abscissae, with
,
, are the zeros of the Laguerre polynomials; and the Gauss–Hermite abscissae, with
,
, 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:
– types::f77_integer
Input
-
On entry: indicates the quadrature formula.
- Gauss–Legendre quadrature on a finite interval, using normal weights.
- Gauss–Laguerre quadrature on a semi-infinite interval, using normal weights.
- Gauss–Laguerre quadrature on a semi-infinite interval, using adjusted weights.
- Gauss–Hermite quadrature on an infinite interval, using normal weights.
- Gauss–Hermite quadrature on an infinite interval, using adjusted weights.
- Rational Gauss quadrature on a semi-infinite interval, using adjusted weights.
Constraint:
, , , , or .
-
2:
– double
Input
-
On entry: the parameters
and
which occur in the quadrature formulae described in
Section 3.
Constraints:
- if , ;
- if or , ;
- if or , .
Constraints:
- Rational Gauss: ;
- Gauss–Laguerre: ;
- Gauss–Hermite: .
-
3:
– double
Input
-
On entry: the parameters
and
which occur in the quadrature formulae described in
Section 3.
Constraints:
- if , ;
- if or , ;
- if or , .
Constraints:
- Rational Gauss: ;
- Gauss–Laguerre: ;
- Gauss–Hermite: .
-
4:
– types::f77_integer
Input
-
On entry: , the number of weights and abscissae to be returned.
Constraint:
,
,
,
,
,
,
,
,
,
,
,
,
,
,
or
.
Note: if
and is not a member of the above list, the maxmium value of
stored below
will be used, and all subsequent elements of
abscis and
weight will be returned as zero.
-
5:
– double array
Output
-
-
6:
– double array
Output
-
On exit: the
n abscissae.
-
7:
– OptionalD01TB
Input/Output
-
Optional parameter container, derived from
Optional.
6
Exceptions and Warnings
Errors or warnings detected by the function:
All errors and warnings have an associated numeric error code field,
errorid, stored either as a member of the thrown exception object (see
errorid), or as a member of
opt.
ifail, depending on how errors
and warnings are being handled (see
Error Handling for more details).
- Raises: WarningException
-
- The n-point rule is not among those stored.
On entry: .
n-rule used: .
- Underflow occurred in calculation of normal weights.
Reduce n or use adjusted weights: .
- No nonzero weights were generated for the provided parameters.
- Raises: ErrorException
-
- On entry, .
Constraint: .
- The value of a and/or b is invalid for Gauss-Laguerre quadrature.
On entry, .
On entry, and .
Constraint: .
- The value of a and/or b is invalid for Gauss-Hermite quadrature.
On entry, .
On entry, and .
Constraint: .
- The value of a and/or b is invalid for rational Gauss quadrature.
On entry, .
On entry, and .
Constraint: .
- On entry, .
Constraint: .
- On entry, argument must be a vector of size array.
Supplied argument has dimensions.
- On entry, argument must be a vector of size array.
Supplied argument was a vector of size .
- On entry, argument must be a vector of size array.
The size for the supplied array could not be ascertained.
- On entry, the raw data component of is null.
- On entry, unable to ascertain a value for .
- An unexpected error has been triggered by this routine.
- Your licence key may have expired or may not have been installed correctly.
- Dynamic memory allocation failed.
7
Accuracy
The weights and abscissae are stored for standard values of
a and
b to full machine accuracy.
8
Parallelism and Performance
Please see the description for the underlying computational routine in this section of the
FL Interface documentation.
Timing is negligible.
10
Example
Examples of the use of this method may be found in the examples for:
md_gauss.
Function: dim1_gauss_wres