NAG FL Interface
d01ubf (dim1_​inf_​exp_​wt)

1 Purpose

d01ubf returns the Gaussian quadrature approximation for the specific problem 0exp-x2fx dx. The degrees of precision catered for are: 1, 3, 5, 7, 9, 19, 29, 39 and 49, corresponding to values of n=1, 2, 3, 4, 5, 10, 15, 20 and 25, where n is the number of weights.

2 Specification

Fortran Interface
Subroutine d01ubf ( f, n, ans, iuser, ruser, ifail)
Integer, Intent (In) :: n
Integer, Intent (Inout) :: iuser(*), ifail
Real (Kind=nag_wp), Intent (Inout) :: ruser(*)
Real (Kind=nag_wp), Intent (Out) :: ans
External :: f
C Header Interface
#include <nag.h>
void  d01ubf_ (
void (NAG_CALL *f)(const double x[], double fv[], const Integer *n, Integer iuser[], double ruser[], Integer *istop),
const Integer *n, double *ans, Integer iuser[], double ruser[], Integer *ifail)
The routine may be called by the names d01ubf or nagf_quad_dim1_inf_exp_wt.

3 Description

d01ubf uses the weights wi and the abscissae xi such that 0exp-x2fx is approximated by i=1 n wifxi to maximum precision i.e., it is exact when fx is a polynomial of degree 2n-1.

4 References

Golub G H and Welsch J H (1969) Calculation of Gauss quadrature rules Math. Comput. 23 221–230

5 Arguments

1: f Subroutine, supplied by the user. External Procedure
f must return the integrand function values fxi for the given xi, for i=1,2,,n.
The specification of f is:
Fortran Interface
Subroutine f ( x, fv, n, iuser, ruser, istop)
Integer, Intent (In) :: n
Integer, Intent (Inout) :: iuser(*), istop
Real (Kind=nag_wp), Intent (In) :: x(n)
Real (Kind=nag_wp), Intent (Inout) :: ruser(*)
Real (Kind=nag_wp), Intent (Out) :: fv(n)
C Header Interface
void  f_ (const double x[], double fv[], const Integer *n, Integer iuser[], double ruser[], Integer *istop)
1: xn Real (Kind=nag_wp) array Input
On entry: the points at which the integrand function f must be evaluated.
2: fvn Real (Kind=nag_wp) array Output
On exit: fvi must contain the value of the integrand fxi evaluated at the point xi, for i=1,2,,n.
3: n Integer Input
On entry: n specifies the number of weights and abscissae to be used.
4: iuser* Integer array User Workspace
5: ruser* Real (Kind=nag_wp) array User Workspace
f is called with the arguments iuser and ruser as supplied to d01ubf. You should use the arrays iuser and ruser to supply information to f.
6: istop Integer Input/Output
On entry: istop=0.
On exit: you may set istop to a negative number if at any time it is impossible to evaluate the function fx. In this case d01ubf halts with ifail set to the value of istop and the value returned in ans will be that of a non-signalling NaN.
f must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which d01ubf is called. Arguments denoted as Input must not be changed by this procedure.
2: n Integer Input
On entry: n specifies the number of weights and abscissae to be used.
Constraint: n=1, 2, 3, 4, 5, 10, 15, 20 or 25.
3: ans Real (Kind=nag_wp) Output
On exit: if ifail=0, ans contains an approximation to the integral. Otherwise, ans will be a non-signalling NaN.
4: iuser* Integer array User Workspace
5: ruser* Real (Kind=nag_wp) array User Workspace
iuser and ruser are not used by d01ubf, but are passed directly to f and may be used to pass information to this routine.
6: ifail Integer Input/Output
On entry: ifail must be set to 0, -1 or 1. If you are unfamiliar with this argument you should refer to Section 4 in the Introduction to the NAG Library FL Interface 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<0
The user has halted the calculation.
ifail=1
On entry, n=value.
Constraint: 1n25.
ifail=2
On entry, n=value.
n is not one of the allowed values.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

7 Accuracy

The weights and abscissae have been calculated using quadruple precision arithmetic.

8 Parallelism and Performance

d01ubf is not threaded in any implementation.

9 Further Comments

None.

10 Example

This example computes an approximation to 0exp-x2x dx.

10.1 Program Text

Program Text (d01ubfe.f90)

10.2 Program Data

None.

10.3 Program Results

Program Results (d01ubfe.r)