E01 Chapter Contents
E01 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentE01SBF

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

E01SBF evaluates at a given point the two-dimensional interpolant function computed by E01SAF.

## 2  Specification

 SUBROUTINE E01SBF ( M, X, Y, F, TRIANG, GRADS, PX, PY, PF, IFAIL)
 INTEGER M, TRIANG(7*M), IFAIL REAL (KIND=nag_wp) X(M), Y(M), F(M), GRADS(2,M), PX, PY, PF

## 3  Description

E01SBF takes as input the parameters defining the interpolant $F\left(x,y\right)$ of a set of scattered data points $\left({x}_{r},{y}_{r},{f}_{r}\right)$, for $\mathit{r}=1,2,\dots ,m$, as computed by E01SAF, and evaluates the interpolant at the point $\left(px,py\right)$.
If $\left(px,py\right)$ is equal to $\left({x}_{r},{y}_{r}\right)$ for some value of $r$, the returned value will be equal to ${f}_{r}$.
If $\left(px,py\right)$ is not equal to $\left({x}_{r},{y}_{r}\right)$ for any $r$, the derivatives in GRADS will be used to compute the interpolant. A triangle is sought which contains the point $\left(px,py\right)$, and the vertices of the triangle along with the partial derivatives and ${f}_{r}$ values at the vertices are used to compute the value $F\left(px,py\right)$. If the point $\left(px,py\right)$ lies outside the triangulation defined by the input parameters, the returned value is obtained by extrapolation. In this case, the interpolating function ${\mathbf{F}}$ is extended linearly beyond the triangulation boundary. The method is described in more detail in Renka and Cline (1984) and the code is derived from Renka (1984).
E01SBF must only be called after a call to E01SAF.

## 4  References

Renka R L (1984) Algorithm 624: triangulation and interpolation of arbitrarily distributed points in the plane ACM Trans. Math. Software 10 440–442
Renka R L and Cline A K (1984) A triangle-based ${C}^{1}$ interpolation method Rocky Mountain J. Math. 14 223–237

## 5  Parameters

1:     M – INTEGERInput
2:     X(M) – REAL (KIND=nag_wp) arrayInput
3:     Y(M) – REAL (KIND=nag_wp) arrayInput
4:     F(M) – REAL (KIND=nag_wp) arrayInput
5:     TRIANG($7×{\mathbf{M}}$) – INTEGER arrayInput
6:     GRADS($2$,M) – REAL (KIND=nag_wp) arrayInput
On entry: M, X, Y, F, TRIANG and GRADS must be unchanged from the previous call of E01SAF.
7:     PX – REAL (KIND=nag_wp)Input
8:     PY – REAL (KIND=nag_wp)Input
On entry: the point $\left(px,py\right)$ at which the interpolant is to be evaluated.
9:     PF – REAL (KIND=nag_wp)Output
On exit: the value of the interpolant evaluated at the point $\left(px,py\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{M}}<3$.
${\mathbf{IFAIL}}=2$
On entry, the triangulation information held in the array TRIANG does not specify a valid triangulation of the data points. TRIANG may have been corrupted since the call to E01SAF.
${\mathbf{IFAIL}}=3$
The evaluation point (PX,PY) lies outside the nodal triangulation, and the value returned in PF is computed by extrapolation.

## 7  Accuracy

Computational errors should be negligible in most practical situations.

The time taken for a call of E01SBF is approximately proportional to the number of data points, $m$.