PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_quad_withdraw_md_gauss (d01fb)
Purpose
nag_quad_md_gauss (d01fb) computes an estimate of a multidimensional integral (from to dimensions), given the analytic form of the integrand and suitable Gaussian weights and abscissae.
Syntax
Description
nag_quad_md_gauss (d01fb) 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
nag_quad_1d_gauss_wgen (d01bc) or
nag_quad_1d_gauss_wres (d01tb)
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 function to evaluate
at any values of
within the range of integration.
References
Davis P J and Rabinowitz P (1975) Methods of Numerical Integration Academic Press
Parameters
Compulsory Input Parameters
- 1:
– int64int32nag_int array
-
must specify the number of points in the th dimension of the summation, for .
- 2:
– double array
-
Must contain in succession the weights for the various dimensions, i.e.,
contains the
th weight for the
th dimension, with
- 3:
– double array
-
Must contain in succession the abscissae for the various dimensions, i.e.,
contains the
th abscissa for the
th dimension, with
- 4:
– function handle or string containing name of m-file
-
fun must return the value of the integrand
at a specified point.
[result] = fun(ndim, x)
Input Parameters
- 1:
– int64int32nag_int scalar
-
, the number of dimensions of the integral.
- 2:
– double array
-
The coordinates of the point at which the integrand must be evaluated.
Output Parameters
- 1:
– double scalar
-
The value of
evaluated at
x.
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the array
nptvec.
, the number of dimensions of the integral.
Constraint:
.
- 2:
– int64int32nag_int scalar
-
Default:
the dimension of the arrays
weight,
abscis. (An error is raised if these dimensions are not equal.)
The dimension of the arrays
weight and
abscis.
Constraint:
.
Output Parameters
- 1:
– double scalar
The result of the function.
- 2:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
On entry, | , |
or | , |
or | . |
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
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.
Further Comments
The total time taken by
nag_quad_md_gauss (d01fb) will be proportional to
where
is the time taken for one evaluation of
fun.
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.
Open in the MATLAB editor:
d01fb_example
function d01fb_example
fprintf('d01fb example results\n\n');
nptvec = [int64(4), 4, 4, 4];
a = [1, 0, 0 , 1];
b = [2, 2, 0.5, 2];
key = [int64(0), -3, -4, -5];
j = 1;
for i = 1:4
[wgt, absc, ifail] = d01tb(key(i), a(i), b(i), nptvec(i));
weight(j:j+nptvec(i)-1) = wgt;
abscis(j:j+nptvec(i)-1) = absc;
j = j + nptvec(i);
end
[result, ifail] = d01fb( ...
nptvec, weight, abscis, @fun);
fprintf('Result = %13.5f\n', result);
function result = fun(ndim,x)
result = ((x(1)*x(2)*x(3))^6/(x(4)+2)^8)*exp(-2*x(2)-x(3)^2/2);
d01fb example results
Result = 0.25065
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015