D01 Chapter Contents
D01 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentD01PAF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

D01PAF returns a sequence of approximations to the integral of a function over a multidimensional simplex, together with an error estimate for the last approximation.

## 2  Specification

 SUBROUTINE D01PAF ( NDIM, VERT, LDVERT, SDVERT, FUNCTN, MINORD, MAXORD, FINVLS, ESTERR, IFAIL)
 INTEGER NDIM, LDVERT, SDVERT, MINORD, MAXORD, IFAIL REAL (KIND=nag_wp) VERT(LDVERT,SDVERT), FUNCTN, FINVLS(MAXORD), ESTERR EXTERNAL FUNCTN

## 3  Description

D01PAF computes a sequence of approximations ${\mathbf{FINVLS}}\left(\mathit{j}\right)$, for $\mathit{j}={\mathbf{MINORD}}+1,\dots ,{\mathbf{MAXORD}}$, to an integral
 $∫Sfx1,x2,…,xndx1dx2⋯dxn$
where $S$ is an $n$-dimensional simplex defined in terms of its $n+1$ vertices. ${\mathbf{FINVLS}}\left(j\right)$ 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).

## 4  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

## 5  Parameters

1:     NDIM – INTEGERInput
On entry: $n$, the number of dimensions of the integral.
Constraint: ${\mathbf{NDIM}}\ge 2$.
2:     VERT(LDVERT,SDVERT) – REAL (KIND=nag_wp) arrayInput/Output
On entry: ${\mathbf{VERT}}\left(\mathit{i},\mathit{j}\right)$ must be set to the $\mathit{j}$th component of the $\mathit{i}$th vertex for the simplex integration region, for $\mathit{i}=1,2,\dots ,n+1$ and $\mathit{j}=1,2,\dots ,n$. If ${\mathbf{MINORD}}>0$, VERT must be unchanged since the previous call of D01PAF.
On exit: these values are unchanged. The rest of the array VERT is used for workspace and contains information to be used if another call of D01PAF is made with ${\mathbf{MINORD}}>0$. In particular ${\mathbf{VERT}}\left(n+1,2n+2\right)$ contains the volume of the simplex.
3:     LDVERT – INTEGERInput
On entry: the first dimension of the array VERT as declared in the (sub)program from which D01PAF is called.
Constraint: ${\mathbf{LDVERT}}\ge {\mathbf{NDIM}}+1$.
4:     SDVERT – INTEGERInput
On entry: the second dimension of the array VERT as declared in the (sub)program from which D01PAF is called.
Constraint: ${\mathbf{SDVERT}}\ge 2×\left({\mathbf{NDIM}}+1\right)$.
5:     FUNCTN – REAL (KIND=nag_wp) FUNCTION, supplied by the user.External Procedure
FUNCTN must return the value of the integrand $f$ at a given point.
The specification of FUNCTN is:
 FUNCTION FUNCTN ( NDIM, X)
 REAL (KIND=nag_wp) FUNCTN
 INTEGER NDIM REAL (KIND=nag_wp) X(NDIM)
1:     NDIM – INTEGERInput
On entry: $n$, the number of dimensions of the integral.
2:     X(NDIM) – REAL (KIND=nag_wp) arrayInput
On entry: the coordinates of the point at which the integrand $f$ must be evaluated.
FUNCTN must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D01PAF is called. Parameters denoted as Input must not be changed by this procedure.
6:     MINORD – INTEGERInput/Output
On entry: must specify the highest order of the approximations currently available in the array FINVLS. ${\mathbf{MINORD}}=0$ indicates an initial call; ${\mathbf{MINORD}}>0$ indicates that ${\mathbf{FINVLS}}\left(1\right),{\mathbf{FINVLS}}\left(2\right),\dots ,{\mathbf{FINVLS}}\left({\mathbf{MINORD}}\right)$ have already been computed in a previous call of D01PAF.
Constraint: ${\mathbf{MINORD}}\ge 0$.
On exit: ${\mathbf{MINORD}}={\mathbf{MAXORD}}$.
7:     MAXORD – INTEGERInput
On entry: the highest order of approximation to the integral to be computed.
Constraint: ${\mathbf{MAXORD}}>{\mathbf{MINORD}}$.
8:     FINVLS(MAXORD) – REAL (KIND=nag_wp) arrayInput/Output
On entry: if ${\mathbf{MINORD}}>0$, ${\mathbf{FINVLS}}\left(1\right),{\mathbf{FINVLS}}\left(2\right),\dots ,{\mathbf{FINVLS}}\left({\mathbf{MINORD}}\right)$ must contain approximations to the integral previously computed by D01PAF.
On exit: contains these values unchanged, and the newly computed values ${\mathbf{FINVLS}}\left({\mathbf{MINORD}}+1\right),{\mathbf{FINVLS}}\left({\mathbf{MINORD}}+2\right),\dots ,{\mathbf{FINVLS}}\left({\mathbf{MAXORD}}\right)$. ${\mathbf{FINVLS}}\left(j\right)$ is an approximation to the integral of polynomial degree $2j-1$.
9:     ESTERR – REAL (KIND=nag_wp)Output
On exit: an absolute error estimate for ${\mathbf{FINVLS}}\left({\mathbf{MAXORD}}\right)$.
10:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
 On entry, ${\mathbf{NDIM}}<2$, or ${\mathbf{LDVERT}}<{\mathbf{NDIM}}+1$, or ${\mathbf{SDVERT}}<2×\left({\mathbf{NDIM}}+1\right)$, or ${\mathbf{MINORD}}<0$, or ${\mathbf{MAXORD}}\le {\mathbf{MINORD}}$.
${\mathbf{IFAIL}}=2$
The volume of the simplex integration region (computed as a determinant by a routine from Chapter F03) is too large or too small to be representable in the machine.

## 7  Accuracy

An absolute error estimate is output through the parameter ESTERR.

The running time for D01PAF will usually be dominated by the time used to evaluate the integrand FUNCTN. The maximum time that could be used by D01PAF will be approximately given by
 $T×MAXORD+NDIM! MAXORD-1!NDIM+1!$
where $T$ is the time needed for one call of FUNCTN.

## 9  Example

This example demonstrates the use of the subroutine with the integral
 $∫01 ∫01-x ∫01-x-y expx+y+z cosx+y+z dz dy dx = 14 .$

### 9.1  Program Text

Program Text (d01pafe.f90)

None.

### 9.3  Program Results

Program Results (d01pafe.r)