PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_quad_md_simplex (d01pa)
Purpose
nag_quad_md_simplex (d01pa) returns a sequence of approximations to the integral of a function over a multidimensional simplex, together with an error estimate for the last approximation.
Syntax
[
vert,
minord,
finvls,
esterr,
ifail] = d01pa(
ndim,
vert,
functn,
minord,
finvls, 'sdvert',
sdvert, 'maxord',
maxord)
[
vert,
minord,
finvls,
esterr,
ifail] = nag_quad_md_simplex(
ndim,
vert,
functn,
minord,
finvls, 'sdvert',
sdvert, 'maxord',
maxord)
Description
nag_quad_md_simplex (d01pa) computes a sequence of approximations
, for
, to an integral
where
is an
-dimensional simplex defined in terms of its
vertices.
is an approximation which will be exact (except for rounding errors) whenever the integrand is a polynomial of total degree
or less.
The type of method used has been described in
Grundmann and Moller (1978), and is implemented in an extrapolated form using the theory from
de Doncker (1979).
References
de Doncker E (1979) New Euler–Maclaurin Expansions and their application to quadrature over the -dimensional simplex Math. Comput. 33 1003–1018
Grundmann A and Moller H M (1978) Invariant integration formulas for the -simplex by combinatorial methods SIAM J. Numer. Anal. 15 282–290
Parameters
Compulsory Input Parameters
- 1:
– int64int32nag_int scalar
-
, the number of dimensions of the integral.
Constraint:
.
- 2:
– double array
-
ldvert, the first dimension of the array, must satisfy the constraint
.
must be set to the
th component of the
th vertex for the simplex integration region, for
and
. If
,
vert must be unchanged since the previous call of
nag_quad_md_simplex (d01pa).
- 3:
– function handle or string containing name of m-file
-
functn must return the value of the integrand
at a given point.
[result] = functn(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 the integrand at the given point.
- 4:
– int64int32nag_int scalar
-
Must specify the highest order of the approximations currently available in the array
finvls.
indicates an initial call;
indicates that
have already been computed in a previous call of
nag_quad_md_simplex (d01pa).
Constraint:
.
- 5:
– double array
-
If , must contain approximations to the integral previously computed by nag_quad_md_simplex (d01pa).
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the second dimension of the array
vert.
The second dimension of the array
vert.
Constraint:
.
- 2:
– int64int32nag_int scalar
-
Default:
the dimension of the array
finvls.
The highest order of approximation to the integral to be computed.
Constraint:
.
Output Parameters
- 1:
– double array
-
These values are unchanged. The rest of the array
vert is used for workspace and contains information to be used if another call of
nag_quad_md_simplex (d01pa) is made with
. In particular
contains the volume of the simplex.
- 2:
– int64int32nag_int scalar
-
.
- 3:
– double array
-
Contains these values unchanged, and the newly computed values . is an approximation to the integral of polynomial degree .
- 4:
– double scalar
-
An absolute error estimate for .
- 5:
– 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:
-
-
Constraint: .
Constraint: .
Constraint: .
Constraint: .
Constraint: .
-
-
The volume of the simplex integration region is too large or too small to be represented on the machine.
-
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
An absolute error estimate is output through the argument
esterr.
Further Comments
The running time for
nag_quad_md_simplex (d01pa) will usually be dominated by the time used to evaluate the integrand
functn. The maximum time that could be used by
nag_quad_md_simplex (d01pa) will be approximately given by
where
is the time needed for one call of
functn.
Example
This example demonstrates the use of the function with the integral
Open in the MATLAB editor:
d01pa_example
function d01pa_example
fprintf('d01pa example results\n\n');
ndim = int64(3);
vertex = zeros(ndim+1,2*(ndim+1));
vertex(2:ndim+1,1:ndim) = eye(3);
minord = int64(0);
finvls = zeros(5,1);
fprintf('Maxord Estimated Estimated Integrand\n');
fprintf(' value accuracy evaluations\n');
nevals = 1;
for maxord = int64(1:5)
[vertex, minord, finvls, esterr, ifail] = ...
d01pa(...
ndim, vertex, @functn, minord, finvls,'maxord',maxord);
fprintf('%5d%13.5f%16.3e%15d\n',maxord, finvls(maxord),esterr,nevals);
nevals = (nevals*(maxord+ndim+1))/maxord;
end
function result = functn(ndim, x)
u = sum(x);
result = exp(u)*cos(u);
d01pa example results
Maxord Estimated Estimated Integrand
value accuracy evaluations
1 0.25816 2.582e-01 1
2 0.25011 8.058e-03 5
3 0.25000 1.067e-04 15
4 0.25000 4.098e-07 35
5 0.25000 1.731e-09 70
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015