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_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 finvls(j)finvlsj, for j = minord + 1,,maxordj=minord+1,,maxord, to an integral
Sf(x1,x2,,xn)dx1dx2dxn
Sf(x1,x2,,xn)dx1dx2dxn
where SS is an nn-dimensional simplex defined in terms of its n + 1n+1 vertices. finvls(j)finvlsj is an approximation which will be exact (except for rounding errors) whenever the integrand is a polynomial of total degree 2j12j-1 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 ss-dimensional simplex Math. Comput. 33 1003–1018
Grundmann A and Moller H M (1978) Invariant integration formulas for the nn-simplex by combinatorial methods SIAM J. Numer. Anal. 15 282–290

Parameters

Compulsory Input Parameters

1:     ndim – int64int32nag_int scalar
nn, the number of dimensions of the integral.
Constraint: ndim2ndim2.
2:     vert(ldvert,sdvert) – double array
ldvert, the first dimension of the array, must satisfy the constraint ldvertndim + 1ldvertndim+1.
vert(i,j)vertij must be set to the jjth component of the iith vertex for the simplex integration region, for i = 1,2,,n + 1i=1,2,,n+1 and j = 1,2,,nj=1,2,,n. If minord > 0minord>0, vert must be unchanged since the previous call of nag_quad_md_simplex (d01pa).
3:     functn – function handle or string containing name of m-file
functn must return the value of the integrand ff at a given point.
[result] = functn(ndim, x)

Input Parameters

1:     ndim – int64int32nag_int scalar
nn, the number of dimensions of the integral.
2:     x(ndim) – double array
The coordinates of the point at which the integrand ff must be evaluated.

Output Parameters

1:     result – double scalar
The result of the function.
4:     minord – int64int32nag_int scalar
Must specify the highest order of the approximations currently available in the array finvls. minord = 0minord=0 indicates an initial call; minord > 0minord>0 indicates that finvls(1),finvls(2),,finvls(minord)finvls1,finvls2,,finvlsminord have already been computed in a previous call of nag_quad_md_simplex (d01pa).
Constraint: minord0minord0.
5:     finvls(maxord) – double array
maxord, the dimension of the array, must satisfy the constraint maxord > minordmaxord>minord.
If minord > 0minord>0, finvls(1),finvls(2),,finvls(minord)finvls1,finvls2,,finvlsminord must contain approximations to the integral previously computed by nag_quad_md_simplex (d01pa).

Optional Input Parameters

1:     sdvert – int64int32nag_int scalar
Default: The second dimension of the array vert.
The second dimension of the array vert as declared in the (sub)program from which nag_quad_md_simplex (d01pa) is called.
Constraint: sdvert2 × (ndim + 1)sdvert2×(ndim+1).
2:     maxord – int64int32nag_int scalar
Default: The dimension of the array finvls.
The highest order of approximation to the integral to be computed.
Constraint: maxord > minordmaxord>minord.

Input Parameters Omitted from the MATLAB Interface

ldvert

Output Parameters

1:     vert(ldvert,sdvert) – double array
ldvertndim + 1ldvertndim+1.
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 minord > 0minord>0. In particular vert(n + 1,2n + 2)vertn+12n+2 contains the volume of the simplex.
2:     minord – int64int32nag_int scalar
minord = maxordminord=maxord.
3:     finvls(maxord) – double array
Contains these values unchanged, and the newly computed values finvls(minord + 1),finvls(minord + 2),,finvls(maxord)finvlsminord+1,finvlsminord+2,,finvlsmaxord. finvls(j)finvlsj is an approximation to the integral of polynomial degree 2j12j-1.
4:     esterr – double scalar
An absolute error estimate for finvls(maxord)finvlsmaxord.
5:     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:
  ifail = 1ifail=1
On entry,ndim < 2ndim<2,
orldvert < ndim + 1ldvert<ndim+1,
orsdvert < 2 × (ndim + 1)sdvert<2×(ndim+1),
orminord < 0minord<0,
ormaxordminordmaxordminord.
  ifail = 2ifail=2
The volume of the simplex integration region (computed as a determinant by a function from Chapter F03) is too large or too small to be representable in the machine.

Accuracy

An absolute error estimate is output through the parameter 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
T × ((maxord + ndim) ! )/((maxord1) ! (ndim + 1) ! )
T×(maxord+ndim)! (maxord-1)!(ndim+1)!
where TT is the time needed for one call of functn.

Example

function nag_quad_md_simplex_example
ndim = int64(3);
vertex = [0, 0, 0, 0, 0, 0, 0, 0;
     1, 0, 0, 0, 0, 0, 0, 0;
     0, 1, 0, 0, 0, 0, 0, 0;
     0, 0, 1, 0, 0, 0, 0, 0];
minord = int64(0);
finvls = [0];
[vertexOut, minordOut, finvlsOut, esterr, ifail] = ...
    nag_quad_md_simplex(ndim, vertex, @functn, minord, finvls)

function result = functn(ndim, x)
  result = exp(x(1)+x(2)+x(3))*cos(x(1)+x(2)+x(3));
 

vertexOut =

         0         0         0         0         0   -0.5000         0    0.2500
    1.0000         0         0    0.5000         0   -0.5000         0    0.2500
         0    1.0000         0         0    0.5000   -0.5000         0    0.2500
         0         0    1.0000         0         0         0    3.0000    1.0000


minordOut =

                    1


finvlsOut =

    0.2582


esterr =

    0.2582


ifail =

                    0


function d01pa_example
ndim = int64(3);
vertex = [0, 0, 0, 0, 0, 0, 0, 0;
     1, 0, 0, 0, 0, 0, 0, 0;
     0, 1, 0, 0, 0, 0, 0, 0;
     0, 0, 1, 0, 0, 0, 0, 0];
minord = int64(0);
finvls = [0];
[vertexOut, minordOut, finvlsOut, esterr, ifail] = ...
    d01pa(ndim, vertex, @functn, minord, finvls)

function result = functn(ndim, x)
  result = exp(x(1)+x(2)+x(3))*cos(x(1)+x(2)+x(3));
 

vertexOut =

         0         0         0         0         0   -0.5000         0    0.2500
    1.0000         0         0    0.5000         0   -0.5000         0    0.2500
         0    1.0000         0         0    0.5000   -0.5000         0    0.2500
         0         0    1.0000         0         0         0    3.0000    1.0000


minordOut =

                    1


finvlsOut =

    0.2582


esterr =

    0.2582


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