hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_quad_1d_gauss_wres (d01tb)

Purpose

nag_quad_1d_gauss_wres (d01tb) 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.

Syntax

[weight, abscis, ifail] = d01tb(key, a, b, n)
[weight, abscis, ifail] = nag_quad_1d_gauss_wres(key, a, b, n)

Description

nag_quad_1d_gauss_wres (d01tb) returns the weights and abscissae for use in the Gaussian quadrature of a function f(x)f(x). The quadrature takes the form
n
S = wif(xi)
i = 1
S=i=1nwif(xi)
where wiwi are the weights and xixi 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 nn (see Section [Parameters]).
(a) Gauss–Legendre Quadrature:
b
Sf(x)dx
a
Sabf(x)dx
where aa and bb are finite and it will be exact for any function of the form
2n1
f(x) = cixi.
i = 0
f(x)=i=0 2n-1cixi.
(b) Rational Gauss quadrature, adjusted weights:
a
Sf(x)dx(a + b > 0)  or  Sf(x)dx(a + b < 0)
a
Saf(x) dx (a+b> 0)   or   S-a f(x) dx (a+b< 0)
and will be exact for any function of the form
2n + 1
f(x) = (ci)/((x + b)i) = (i = 02n1c2n + 1i(x + b)i)/((x + b)2n + 1).
i = 2
f(x)=i=2 2n+1ci(x+b)i=i=0 2n-1c2n+1-i(x+b)i(x+b)2n+1.
(c) Gauss–Laguerre quadrature, adjusted weights:
a
Sf(x)dx(b > 0)  or  Sf(x)dx(b < 0)
a
Saf(x) dx (b> 0)   or   S-a f(x) dx (b< 0)
and will be exact for any function of the form
2n1
f(x) = ebxcixi.
i = 0
f(x)=e-bxi=0 2n-1cixi.
(d) Gauss–Hermite quadrature, adjusted weights:
+
Sf(x)dx
S- + f(x) dx
and will be exact for any function of the form
2n1
f(x) = eb(xa)2cixi(b > 0).
i = 0
f(x)=e-b (x-a) 2i=0 2n-1cixi(b>0).
(e) Gauss–Laguerre quadrature, normal weights:
a
Sebxf(x)dx(b > 0)  or  Sebxf(x)dx(b < 0)
a
Sae-bxf(x) dx (b> 0)   or   S-a e-bxf(x) dx (b< 0)
and will be exact for any function of the form
2n1
f(x) = cixi.
i = 0
f(x)=i=0 2n-1cixi.
(f) Gauss–Hermite quadrature, normal weights:
+
Seb(xa)2f(x)dx
S- + e-b (x-a) 2f(x) dx
and will be exact for any function of the form
2n1
f(x) = cixi.
i = 0
f(x)=i=0 2n-1cixi.
Note:  the Gauss–Legendre abscissae, with a = 1a=-1, b = + 1b=+1, are the zeros of the Legendre polynomials; the Gauss–Laguerre abscissae, with a = 0a=0, b = 1b=1, are the zeros of the Laguerre polynomials; and the Gauss–Hermite abscissae, with a = 0a=0, b = 1b=1, are the zeros of the Hermite polynomials.

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

Parameters

Compulsory Input Parameters

1:     key – int64int32nag_int scalar
Indicates the quadrature formula.
key = 0key=0
Gauss–Legendre quadrature on a finite interval, using normal weights.
key = 3key=3
Gauss–Laguerre quadrature on a semi-infinite interval, using normal weights.
key = -3key=-3
Gauss–Laguerre quadrature on a semi-infinite interval, using adjusted weights.
key = 4key=4
Gauss–Hermite quadrature on an infinite interval, using normal weights.
key = -4key=-4
Gauss–Hermite quadrature on an infinite interval, using adjusted weights.
key = -5key=-5
Rational Gauss quadrature on a semi-infinite interval, using adjusted weights.
Constraint: key = 0key=0, 33, -3-3, 44, -4-4 or -5-5.
2:     a – double scalar
3:     b – double scalar
The quantities aa and bb as described in the appropriate sub-section of Section [Description].
Constraints:
  • Rational Gauss: a + b0.0a+b0.0;
  • Gauss–Laguerre: b0.0b0.0;
  • Gauss–Hermite: b > 0b>0.
4:     n – int64int32nag_int scalar
nn, the number of weights and abscissae to be returned.
Constraint: n = 1n=1, 22, 33, 44, 55, 66, 88, 1010, 1212, 1414, 1616, 2020, 2424, 3232, 4848 or 6464.
Note: if n > 0n>0 and is not a member of the above list, the maxmium value of nn stored below nn will be used, and all subsequent elements of abscis and weight will be returned as zero.

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     weight(n) – double array
The n weights.
2:     abscis(n) – double array
The n abscissae.
3:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

W ifail = 1ifail=1
The n-point rule is not among those stored.
W ifail = 2ifail=2
Underflow occurred in calculation of normal weights.
W ifail = 3ifail=3
No nonzero weights were generated for the provided parameters.
  ifail = 11ifail=11
Constraint: key = 0key=0, 33, -3-3, 44, -4-4 or -5-5.
  ifail = 12ifail=12
The value of a and/or b is invalid for the chosen key. Either:
  • Constraint: |a + b| > 0.0|a+b|>0.0.
  • Constraint: |b| > 0.0|b|>0.0.
  • Constraint: b > 0.0b>0.0.
  ifail = 14ifail=14
Constraint: n > 0n>0.

Accuracy

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

Further Comments

Timing is negligible.

Example

function nag_quad_1d_gauss_wres_example
key = int64(-3);
a = 0;
b = 1;
n = int64(6);
[weight, abscis, ifail] = nag_quad_1d_gauss_wres(key, a, b, n)

function [fv, iflag, user] = f(x, nx, iflag, user)
  fv = sin(x)./x.*log(10*(1-x));
 

weight =

    0.5735
    1.3693
    2.2607
    3.3505
    4.8868
    7.8490


abscis =

    0.2228
    1.1889
    2.9927
    5.7751
    9.8375
   15.9829


ifail =

                    0


function d01tb_example
key = int64(-3);
a = 0;
b = 1;
n = int64(6);
[weight, abscis, ifail] = d01tb(key, a, b, n)

function [fv, iflag, user] = f(x, nx, iflag, user)
  fv = sin(x)./x.*log(10*(1-x));
 

weight =

    0.5735
    1.3693
    2.2607
    3.3505
    4.8868
    7.8490


abscis =

    0.2228
    1.1889
    2.9927
    5.7751
    9.8375
   15.9829


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013