# NAG Library Routine Document

## 1Purpose

e01sbf evaluates at a given point the two-dimensional interpolant function computed by e01saf.

## 2Specification

Fortran Interface
 Subroutine e01sbf ( m, x, y, f, px, py, pf,
 Integer, Intent (In) :: m, triang(7*m) Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: x(m), y(m), f(m), grads(2,m), px, py Real (Kind=nag_wp), Intent (Out) :: pf
#include nagmk26.h
 void e01sbf_ (const Integer *m, const double x[], const double y[], const double f[], const Integer triang[], const double grads[], const double *px, const double *py, double *pf, Integer *ifail)

## 3Description

e01sbf takes as input the arguments 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 arguments, 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.
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

## 5Arguments

1:     $\mathbf{m}$ – IntegerInput
2:     $\mathbf{x}\left({\mathbf{m}}\right)$ – Real (Kind=nag_wp) arrayInput
3:     $\mathbf{y}\left({\mathbf{m}}\right)$ – Real (Kind=nag_wp) arrayInput
4:     $\mathbf{f}\left({\mathbf{m}}\right)$ – Real (Kind=nag_wp) arrayInput
5:     $\mathbf{triang}\left(7×{\mathbf{m}}\right)$ – Integer arrayInput
6:     $\mathbf{grads}\left(2,{\mathbf{m}}\right)$ – Real (Kind=nag_wp) arrayInput
On entry: m, x, y, f, triang and grads must be unchanged from the previous call of e01saf.
7:     $\mathbf{px}$ – Real (Kind=nag_wp)Input
8:     $\mathbf{py}$ – Real (Kind=nag_wp)Input
On entry: the point $\left(px,py\right)$ at which the interpolant is to be evaluated.
9:     $\mathbf{pf}$ – Real (Kind=nag_wp)Output
On exit: the value of the interpolant evaluated at the point $\left(px,py\right)$.
10:   $\mathbf{ifail}$ – IntegerInput/Output
On entry: ifail must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation 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 argument, 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).

## 6Error Indicators and Warnings

If on entry ${\mathbf{ifail}}=0$ or $-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.
${\mathbf{ifail}}=-99$
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

## 7Accuracy

Computational errors should be negligible in most practical situations.

## 8Parallelism and Performance

e01sbf is not thread safe and should not be called from a multithreaded user program. Please see Section 3.12.1 in How to Use the NAG Library and its Documentation for more information on thread safety.
e01sbf is not threaded in any implementation.

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