E01 Chapter Contents
E01 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentE01ZNF

## 1  Purpose

E01ZNF evaluates the multi-dimensional interpolating function generated by E01ZMF and its first partial derivatives.

## 2  Specification

 SUBROUTINE E01ZNF ( D, M, X, F, IQ, RQ, N, XE, Q, QX, IFAIL)
 INTEGER D, M, IQ(2*M+1), N, IFAIL REAL (KIND=nag_wp) X(D,M), F(M), RQ(*), XE(D,N), Q(N), QX(D,N)

## 3  Description

E01ZNF takes as input the interpolant $Q\left(\mathbf{x}\right)$, $\mathbf{x}\in {ℝ}^{d}$ of a set of scattered data points $\left({\mathbf{x}}_{\mathit{r}},{f}_{\mathit{r}}\right)$, for $\mathit{r}=1,2,\dots ,m$, as computed by E01ZMF, and evaluates the interpolant and its first partial derivatives at the set of points ${\mathbf{x}}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,n$.
E01ZNF must only be called after a call to E01ZMF.
E01ZNF is derived from the new implementation of QS3GRD described by Renka (1988). It uses the modification for high-dimensional interpolation described by Berry and Minser (1999).

## 4  References

Berry M W, Minser K S (1999) Algorithm 798: high-dimensional interpolation using the modified Shepard method ACM Trans. Math. Software 25 353–366
Renka R J (1988) Algorithm 661: QSHEP3D: Quadratic Shepard method for trivariate interpolation of scattered data ACM Trans. Math. Software 14 151–152

## 5  Parameters

1:     D – INTEGERInput
On entry: must be the same value supplied for parameter D in the preceding call to E01ZMF.
Constraint: ${\mathbf{D}}\ge 2$.
2:     M – INTEGERInput
On entry: must be the same value supplied for parameter M in the preceding call to E01ZMF.
Constraint: ${\mathbf{M}}\ge \left({\mathbf{D}}+1\right)×\left({\mathbf{D}}+2\right)/2+2$.
3:     X(D,M) – REAL (KIND=nag_wp) arrayInput
On entry: must be the same array supplied as parameter X in the preceding call to E01ZMF. It must remain unchanged between calls.
4:     F(M) – REAL (KIND=nag_wp) arrayInput
On entry: must be the same array supplied as parameter F in the preceding call to E01ZMF. It must remain unchanged between calls.
5:     IQ($2×{\mathbf{M}}+1$) – INTEGER arrayInput
On entry: must be the same array returned as parameter IQ in the preceding call to E01ZMF. It must remain unchanged between calls.
6:     RQ($*$) – REAL (KIND=nag_wp) arrayInput
Note: the dimension of the array RQ must be at least $\left(\left({\mathbf{D}}+1\right)×\left({\mathbf{D}}+2\right)/2\right)×{\mathbf{M}}+2×{\mathbf{D}}+1$.
On entry: must be the same array returned as parameter RQ in the preceding call to E01ZMF. It must remain unchanged between calls.
7:     N – INTEGERInput
On entry: $n$, the number of evaluation points.
Constraint: ${\mathbf{N}}\ge 1$.
8:     XE(D,N) – REAL (KIND=nag_wp) arrayInput
On entry: ${\mathbf{XE}}\left(1:{\mathbf{D}},\mathit{i}\right)$ must be set to the evaluation point ${\mathbf{x}}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,n$.
9:     Q(N) – REAL (KIND=nag_wp) arrayOutput
On exit: ${\mathbf{Q}}\left(\mathit{i}\right)$ contains the value of the interpolant, at ${\mathbf{x}}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,n$. If any of these evaluation points lie outside the region of definition of the interpolant the corresponding entries in Q are set to the largest machine representable number (see X02ALF), and E01ZNF returns with ${\mathbf{IFAIL}}={\mathbf{3}}$.
10:   QX(D,N) – REAL (KIND=nag_wp) arrayOutput
On exit: ${\mathbf{QX}}\left(j,i\right)$ contains the value of the partial derivatives with respect to ${\mathbf{x}}_{j}$ of the interpolant $Q\left(\mathbf{x}\right)$ at ${\mathbf{x}}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,n$, and for each of the partial derivatives $j=1,2,\dots ,d$. If any of these evaluation points lie outside the region of definition of the interpolant, the corresponding entries in QX are set to the largest machine representable number (see X02ALF), and E01ZNF returns with ${\mathbf{IFAIL}}={\mathbf{3}}$.
11:   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

${\mathbf{IFAIL}}=1$
On entry, $\left({\mathbf{D}}+1\right)×\left({\mathbf{D}}+2\right)/2×{\mathbf{M}}+2×{\mathbf{D}}+1$ exceeds the largest machine integer.
${\mathbf{D}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{M}}=⟨\mathit{\text{value}}⟩$.
On entry, ${\mathbf{D}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{D}}\ge 2$.
On entry, ${\mathbf{M}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{D}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{M}}\ge \left({\mathbf{D}}+1\right)\left({\mathbf{D}}+2\right)/2+2$.
On entry, ${\mathbf{N}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{N}}\ge 1$.
${\mathbf{IFAIL}}=2$
On entry, values in IQ appear to be invalid. Check that IQ has not been corrupted between calls to E01ZMF and E01ZNF.
On entry, values in RQ appear to be invalid. Check that RQ has not been corrupted between calls to E01ZMF and E01ZNF.
${\mathbf{IFAIL}}=3$
On entry, at least one evaluation point lies outside the region of definition of the interpolant. At all such points the corresponding values in Q and QX have been set to ${\mathbf{X02ALF}}\left(\right)$: ${\mathbf{X02ALF}}\left(\right)=⟨\mathit{\text{value}}⟩$.
${\mathbf{IFAIL}}=-999$
Dynamic memory allocation failed.

## 7  Accuracy

Computational errors should be negligible in most practical situations.

## 8  Further Comments

The time taken for a call to E01ZNF will depend in general on the distribution of the data points. If the data points are approximately uniformly distributed, then the time taken should be only $\mathit{O}\left(n\right)$. At worst $\mathit{O}\left(mn\right)$ time will be required.

## 9  Example

This program evaluates the function (in six variables)
 $fx = x1 x2 x3 1 + 2 x4 x5 x6$
at a set of randomly generated data points and calls E01ZMF to construct an interpolating function ${Q}_{x}$. It then calls E01ZNF to evaluate the interpolant at a set of points on the line ${x}_{i}=x$, for $\mathit{i}=1,2,\dots ,6$. To reduce the time taken by this example, the number of data points is limited. Increasing this value to the suggested minimum of $4000$ improves the interpolation accuracy at the expense of more time.

### 9.1  Program Text

Program Text (e01znfe.f90)

### 9.2  Program Data

Program Data (e01znfe.d)

### 9.3  Program Results

Program Results (e01znfe.r)