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)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

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

Parameters

Compulsory Input Parameters

1:     ndim int64int32nag_int scalar
n, the number of dimensions of the integral.
Constraint: ndim2.
2:     vertldvertsdvert – double array
ldvert, the first dimension of the array, must satisfy the constraint ldvertndim+1.
vertij must be set to the jth component of the ith vertex for the simplex integration region, for i=1,2,,n+1 and j=1,2,,n. If minord>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 f at a given point.
[result] = functn(ndim, x)

Input Parameters

1:     ndim int64int32nag_int scalar
n, the number of dimensions of the integral.
2:     xndim – double array
The coordinates of the point at which the integrand f must be evaluated.

Output Parameters

1:     result – double scalar
The value of the integrand f at the given point.
4:     minord int64int32nag_int scalar
Must specify the highest order of the approximations currently available in the array finvls. minord=0 indicates an initial call; minord>0 indicates that finvls1,finvls2,,finvlsminord have already been computed in a previous call of nag_quad_md_simplex (d01pa).
Constraint: minord0.
5:     finvlsmaxord – double array
If minord>0, 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.
Constraint: 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>minord.

Output Parameters

1:     vertldvertsdvert – 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 minord>0. In particular vertn+12n+2 contains the volume of the simplex.
2:     minord int64int32nag_int scalar
minord=maxord.
3:     finvlsmaxord – double array
Contains these values unchanged, and the newly computed values finvlsminord+1,finvlsminord+2,,finvlsmaxord. finvlsj is an approximation to the integral of polynomial degree 2j-1.
4:     esterr – double scalar
An absolute error estimate for finvlsmaxord.
5:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
   ifail=1
Constraint: ldvertndim+1.
Constraint: maxord>minord.
Constraint: minord0.
Constraint: ndim2.
Constraint: sdvert2×ndim+1.
   ifail=2
The volume of the simplex integration region is too large or too small to be represented on the machine.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
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
T×maxord+ndim! maxord-1!ndim+1!  
where T is the time needed for one call of functn.

Example

This example demonstrates the use of the function with the integral
01 01-x 01-x-y expx+y+z cosx+y+z dz dy dx = 14 .  
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)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015