NAG Library Routine Document
d01fbf (md_gauss)
1
Purpose
d01fbf computes an estimate of a multidimensional integral (from to dimensions), given the analytic form of the integrand and suitable Gaussian weights and abscissae.
2
Specification
Fortran Interface
Real (Kind=nag_wp) | :: | d01fbf | Integer, Intent (In) | :: | ndim, nptvec(ndim), lwa | Integer, Intent (Inout) | :: | ifail | Real (Kind=nag_wp), External | :: | fun | Real (Kind=nag_wp), Intent (In) | :: | weight(lwa), abscis(lwa) |
|
C Header Interface
#include <nagmk26.h>
double |
d01fbf_ (const Integer *ndim, const Integer nptvec[], const Integer *lwa, const double weight[], const double abscis[], double (NAG_CALL *fun)(const Integer *ndim, const double x[]), Integer *ifail) |
|
3
Description
d01fbf approximates a multidimensional integral by evaluating the summation
given the weights
and abscissae
for a multidimensional product integration rule (see
Davis and Rabinowitz (1975)). The number of dimensions may be anything from
to
.
The weights and abscissae for each dimension must have been placed in successive segments of the arrays
weight and
abscis; for example, by calling
d01bcf or
d01tbf
once for each dimension using a quadrature formula and number of abscissae appropriate to the range of each
and to the functional dependence of
on
.
If normal weights are used, the summation will approximate the integral
where
is the weight function associated with the quadrature formula chosen for the
th dimension; while if adjusted weights are used, the summation will approximate the integral
You must supply a subroutine to evaluate
at any values of
within the range of integration.
4
References
Davis P J and Rabinowitz P (1975) Methods of Numerical Integration Academic Press
5
Arguments
- 1: – IntegerInput
-
On entry: , the number of dimensions of the integral.
Constraint:
.
- 2: – Integer arrayInput
-
On entry: must specify the number of points in the th dimension of the summation, for .
- 3: – IntegerInput
-
On entry: the dimension of the arrays
weight and
abscis as declared in the (sub)program from which
d01fbf is called.
Constraint:
.
- 4: – Real (Kind=nag_wp) arrayInput
-
On entry: must contain in succession the weights for the various dimensions, i.e.,
contains the
th weight for the
th dimension, with
- 5: – Real (Kind=nag_wp) arrayInput
-
On entry: must contain in succession the abscissae for the various dimensions, i.e.,
contains the
th abscissa for the
th dimension, with
- 6: – real (Kind=nag_wp) Function, supplied by the user.External Procedure
-
fun must return the value of the integrand
at a specified point.
The specification of
fun is:
Fortran Interface
Real (Kind=nag_wp) | :: | fun | Integer, Intent (In) | :: | ndim | Real (Kind=nag_wp), Intent (In) | :: | x(ndim) |
|
C Header Interface
#include <nagmk26.h>
double |
fun (const Integer *ndim, const double x[]) |
|
- 1: – IntegerInput
-
On entry: , the number of dimensions of the integral.
- 2: – Real (Kind=nag_wp) arrayInput
-
On entry: the coordinates of the point at which the integrand must be evaluated.
fun must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which
d01fbf is called. Arguments denoted as
Input must
not be changed by this procedure.
Note: fun should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by
d01fbf. If your code inadvertently
does return any NaNs or infinities,
d01fbf is likely to produce unexpected results.
- 7: – IntegerInput/Output
-
On entry:
ifail must be set to
,
. 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
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this argument, the recommended value is
.
When the value is used it is essential to test the value of ifail on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6
Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Errors or warnings detected by the routine:
-
On entry,
lwa is too small.
. Minimum possible dimension:
.
On entry, .
Constraint: .
On entry, .
Constraint: .
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.
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.
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 of the computed multidimensional sum depends on the weights and the integrand values at the abscissae. If these numbers vary significantly in size and sign then considerable accuracy could be lost. If these numbers are all positive, then little accuracy will be lost in computing the sum.
8
Parallelism and Performance
d01fbf is not threaded in any implementation.
The total time taken by
d01fbf will be proportional to
where
is the time taken for one evaluation of
fun.
10
Example
This example evaluates the integral
using adjusted weights. The quadrature formulae chosen are:
- : Gauss–Legendre, , ,
- : Gauss–Laguerre, , ,
- : Gauss–Hermite, , ,
- : rational Gauss, , .
Four points are sufficient in each dimension, as this integral is in fact a product of four one-dimensional integrals, for each of which the chosen four-point formula is exact.
10.1
Program Text
Program Text (d01fbfe.f90)
10.2
Program Data
None.
10.3
Program Results
Program Results (d01fbfe.r)