Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_interp_5d_scat_shep (e01tm)

## Purpose

nag_interp_5d_scat_shep (e01tm) generates a five-dimensional interpolant to a set of scattered data points, using a modified Shepard method.

## Syntax

[iq, rq, ifail] = e01tm(x, f, nw, nq, 'm', m)
[iq, rq, ifail] = nag_interp_5d_scat_shep(x, f, nw, nq, 'm', m)

## Description

nag_interp_5d_scat_shep (e01tm) constructs a smooth function Q (x) $Q\left(\mathbf{x}\right)$, x5$\mathbf{x}\in {ℝ}^{5}$ which interpolates a set of m$m$ scattered data points (xr,fr) $\left({\mathbf{x}}_{r},{f}_{r}\right)$, for r = 1,2,,m$r=1,2,\dots ,m$, using a modification of Shepard's method. The surface is continuous and has continuous first partial derivatives.
The basic Shepard method, which is a generalization of the two-dimensional method described in Shepard (1968), interpolates the input data with the weighted mean
 Q (x) = ( ∑ r = 1m wr (x) qr)/( ∑ r = 1m wr (x) ) , $Q (x) = ∑ r=1 m wr (x) qr ∑ r=1 m wr (x) ,$
where qr = fr ${q}_{r}={f}_{r}$, wr (x) = 1/(dr2) ${w}_{r}\left(\mathbf{x}\right)=\frac{1}{{d}_{r}^{2}}$ and dr2 = xxr22 ${d}_{r}^{2}={{‖\mathbf{x}-{\mathbf{x}}_{r}‖}_{2}}^{2}$.
The basic method is global in that the interpolated value at any point depends on all the data, but nag_interp_5d_scat_shep (e01tm) uses a modification (see Franke and Nielson (1980) and Renka (1988a)), whereby the method becomes local by adjusting each wr (x) ${w}_{r}\left(\mathbf{x}\right)$ to be zero outside a hypersphere with centre xr ${\mathbf{x}}_{r}$ and some radius Rw${R}_{w}$. Also, to improve the performance of the basic method, each qr${q}_{r}$ above is replaced by a function qr (x) ${q}_{r}\left(\mathbf{x}\right)$, which is a quadratic fitted by weighted least squares to data local to xr ${\mathbf{x}}_{r}$ and forced to interpolate (xr,fr) $\left({\mathbf{x}}_{r},{f}_{r}\right)$. In this context, a point x$\mathbf{x}$ is defined to be local to another point if it lies within some distance Rq${R}_{q}$ of it.
The efficiency of nag_interp_5d_scat_shep (e01tm) is enhanced by using a cell method for nearest neighbour searching due to Bentley and Friedman (1979) with a cell density of 3$3$.
The radii Rw${R}_{w}$ and Rq${R}_{q}$ are chosen to be just large enough to include Nw${N}_{w}$ and Nq${N}_{q}$ data points, respectively, for user-supplied constants Nw${N}_{w}$ and Nq${N}_{q}$. Default values of these parameters are provided, and advice on alternatives is given in Section [Choice of and ].
nag_interp_5d_scat_shep (e01tm) is derived from the new implementation of QSHEP3 described by Renka (1988b). It uses the modification for five-dimensional interpolation described by Berry and Minser (1999).
Values of the interpolant Q (x) $Q\left(\mathbf{x}\right)$ generated by nag_interp_5d_scat_shep (e01tm), and its first partial derivatives, can subsequently be evaluated for points in the domain of the data by a call to nag_interp_5d_scat_shep_eval (e01tn).

## References

Bentley J L and Friedman J H (1979) Data structures for range searching ACM Comput. Surv. 11 397–409
Berry M W, Minser K S (1999) Algorithm 798: high-dimensional interpolation using the modified Shepard method ACM Trans. Math. Software 25 353–366
Franke R and Nielson G (1980) Smooth interpolation of large sets of scattered data Internat. J. Num. Methods Engrg. 15 1691–1704
Renka R J (1988a) Multivariate interpolation of large sets of scattered data ACM Trans. Math. Software 14 139–148
Renka R J (1988b) Algorithm 661: QSHEP3D: Quadratic Shepard method for trivariate interpolation of scattered data ACM Trans. Math. Software 14 151–152
Shepard D (1968) A two-dimensional interpolation function for irregularly spaced data Proc. 23rd Nat. Conf. ACM 517–523 Brandon/Systems Press Inc., Princeton

## Parameters

### Compulsory Input Parameters

1:     x(5$5$,m) – double array
x(1 : 5,r)${\mathbf{x}}\left(1:5,\mathit{r}\right)$ must be set to the Cartesian coordinates of the data point xr${\mathbf{x}}_{\mathit{r}}$, for r = 1,2,,m$\mathit{r}=1,2,\dots ,m$.
Constraint: these coordinates must be distinct, and must not all lie on the same four-dimensional hypersurface.
2:     f(m) – double array
m, the dimension of the array, must satisfy the constraint m23${\mathbf{m}}\ge 23$.
f(r)${\mathbf{f}}\left(\mathit{r}\right)$ must be set to the data value fr${f}_{\mathit{r}}$, for r = 1,2,,m$\mathit{r}=1,2,\dots ,m$.
3:     nw – int64int32nag_int scalar
The number Nw${N}_{w}$ of data points that determines each radius of influence Rw${R}_{w}$, appearing in the definition of each of the weights wr${w}_{\mathit{r}}$, for r = 1,2,,m$\mathit{r}=1,2,\dots ,m$ (see Section [Description]). Note that Rw${R}_{w}$ is different for each weight. If nw0${\mathbf{nw}}\le 0$ the default value nw = min (32,m1)${\mathbf{nw}}=\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(32,{\mathbf{m}}-1\right)$ is used instead.
Constraint: nwmin (50,m1)${\mathbf{nw}}\le \mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(50,{\mathbf{m}}-1\right)$.
4:     nq – int64int32nag_int scalar
The number Nq${N}_{q}$ of data points to be used in the least squares fit for coefficients defining the quadratic functions qr (x) ${q}_{r}\left(\mathbf{x}\right)$ (see Section [Description]). If nq0${\mathbf{nq}}\le 0$ the default value nq = min (50,m1)${\mathbf{nq}}=\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(50,{\mathbf{m}}-1\right)$ is used instead.
Constraint: nq0${\mathbf{nq}}\le 0$ or 20nqmin (70,m1)$20\le {\mathbf{nq}}\le \mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(70,{\mathbf{m}}-1\right)$.

### Optional Input Parameters

1:     m – int64int32nag_int scalar
Default: The dimension of the array f and the second dimension of the array x. (An error is raised if these dimensions are not equal.)
m$m$, the number of data points.
Note: on the basis of experimental results reported in Berry and Minser (1999), it is recommended to use m4000${\mathbf{m}}\ge 4000$.
Constraint: m23${\mathbf{m}}\ge 23$.

None.

### Output Parameters

1:     iq(2 × m + 1$2×{\mathbf{m}}+1$) – int64int32nag_int array
Integer data defining the interpolant Q (x)$Q\left(\mathbf{x}\right)$.
2:     rq(21 × m + 11$21×{\mathbf{m}}+11$) – double array
Real data defining the interpolant Q (x) $Q\left(\mathbf{x}\right)$.
3:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{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${\mathbf{ifail}}=1$
Constraint: m23${\mathbf{m}}\ge 23$.
Constraint: nq0${\mathbf{nq}}\le 0$ or nq20${\mathbf{nq}}\ge 20$.
Constraint: nqmin (70,m1)${\mathbf{nq}}\le \mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(70,{\mathbf{m}}-1\right)$.
Constraint: nwmin (50,m1)${\mathbf{nw}}\le \mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(50,{\mathbf{m}}-1\right)$.
ifail = 2${\mathbf{ifail}}=2$
There are duplicate nodes in the dataset.
ifail = 3${\mathbf{ifail}}=3$
On entry, all the data points lie on the same four-dimensional hypersurface. No unique solution exists.

## Accuracy

On successful exit, the function generated interpolates the input data exactly and has quadratic precision. Overall accuracy of the interpolant is affected by the choice of parameters nw and nq as well as the smoothness of the function represented by the input data. Berry and Minser (1999) report on the results obtained for a set of test functions.

### Timing

The time taken for a call to nag_interp_5d_scat_shep (e01tm) will depend in general on the distribution of the data points and on the choice of Nw${N}_{w}$ and Nq${N}_{q}$ parameters. If the data points are uniformly randomly distributed, then the time taken should be O(m)$\mathit{O}\left(m\right)$. At worst O(m2)$\mathit{O}\left({m}^{2}\right)$ time will be required.

### Choice of Nw and Nq

Default values of the parameters Nw${N}_{w}$ and Nq${N}_{q}$ may be selected by calling nag_interp_5d_scat_shep (e01tm) with nw0${\mathbf{nw}}\le 0$ and nq0${\mathbf{nq}}\le 0$. These default values may well be satisfactory for many applications.
If non-default values are required they must be supplied to nag_interp_5d_scat_shep (e01tm) through positive values of nw and nq. Increasing these parameter values makes the method less local. This may increase the accuracy of the resulting interpolant at the expense of increased computational cost. The default values nw = min (32,m1) ${\mathbf{nw}}=\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(32,{\mathbf{m}}-1\right)$ and nq = min (50,m1) ${\mathbf{nq}}=\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(50,{\mathbf{m}}-1\right)$ have been chosen on the basis of experimental results reported in Berry and Minser (1999). In these experiments the error norm was found to increase with the decrease of Nq${N}_{q}$, but to be little affected by the choice of Nw${N}_{w}$. The choice of both, directly affected the time taken by the function. For further advice on the choice of these parameters see Berry and Minser (1999).

## Example

```function nag_interp_5d_scat_shep_example
x = [0.81, 0.91, 0.13, 0.91, 0.63, 0.10, 0.28, 0.55, 0.96, 0.96, 0.16, ...
0.97, 0.96, 0.49, 0.80, 0.14, 0.42, 0.92, 0.79, 0.96, 0.66, 0.04, ...
0.85, 0.93, 0.68, 0.76, 0.74, 0.39, 0.66, 0.17;
0.15, 0.96, 0.88, 0.49, 0.41, 0.13, 0.93, 0.01, 0.19, 0.32, 0.05, ...
0.14, 0.73, 0.48, 0.34, 0.24, 0.45, 0.19, 0.32, 0.26, 0.83, 0.70, ...
0.33, 0.58, 0.29, 0.26, 0.26, 0.68, 0.52, 0.08;
0.44, 0.00, 0.22, 0.39, 0.72, 0.77, 0.24, 0.04, 0.95, 0.53, 0.16, ...
0.36, 0.28, 0.58, 0.64, 0.12, 0.03, 0.48, 0.15, 0.93, 0.41, 0.40, ...
0.15, 0.88, 0.88, 0.09, 0.33, 0.69, 0.17, 0.35;
0.83, 0.09, 0.21, 0.79, 0.68, 0.47, 0.90, 0.41, 0.66, 0.96, 0.30, ...
0.72, 0.75, 0.19, 0.57, 0.06, 0.68, 0.67, 0.13, 0.89, 0.17, 0.54, ...
0.03, 0.81, 0.60, 0.41, 0.64, 0.37, 1.00, 0.71;
0.21, 0.98, 0.73, 0.47, 0.65, 0.22, 0.96, 0.26, 0.99, 0.84, 0.58, ...
0.78, 0.28, 0.25, 0.08, 0.63, 0.66, 0.28, 0.40, 0.61, 0.09, 0.37, ...
0.36, 0.40, 0.47, 0.14, 0.36, 0.12, 0.43, 0.17];

f = [6.39;
2.50;
9.34;
7.52;
6.91;
4.68;
45.40;
5.48;
2.75;
7.43;
6.05;
5.77;
8.68;
2.38;
3.70;
1.34;
15.18;
4.35;
1.50;
3.43;
3.10;
14.33;
0.35;
4.30;
3.77;
4.16;
6.75;
5.22;
16.23;
10.62];

xe = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6;
0.1, 0.2, 0.3, 0.4, 0.5, 0.6;
0.1, 0.2, 0.3, 0.4, 0.5, 0.6;
0.1, 0.2, 0.3, 0.4, 0.5, 0.6;
0.1, 0.2, 0.3, 0.4, 0.5, 0.6];

% Generate the interpolant
nq = int64(0);
nw = int64(0);
[iq, rq, ifail] = nag_interp_5d_scat_shep(x, f, nw, nq);

% Evaluate the interpolant
[q, qx, ifail] = nag_interp_5d_scat_shep_eval(x, f, iq, rq, xe);

fprintf('\n   |  Interpolated Evaluation Points                   |  Values\n');
fprintf('---|---------------------------------------------------+--------\n');
fprintf(' i |  xe(i,1)   xe(i,2)   xe(i,3)   xe(i,4)   xe(i,5)  | q(i)\n');
fprintf('---|---------------------------------------------------+--------\n');
for i=1:6
fprintf(' %d |%8.4f  %8.4f  %8.4f  %8.4f  %8.4f %8.4f \n', i, xe(:, i), q(i));
end
```
```

|  Interpolated Evaluation Points                   |  Values
---|---------------------------------------------------+--------
i |  xe(i,1)   xe(i,2)   xe(i,3)   xe(i,4)   xe(i,5)  | q(i)
---|---------------------------------------------------+--------
1 |  0.1000    0.1000    0.1000    0.1000    0.1000   3.2313
2 |  0.2000    0.2000    0.2000    0.2000    0.2000   4.2476
3 |  0.3000    0.3000    0.3000    0.3000    0.3000   5.2695
4 |  0.4000    0.4000    0.4000    0.4000    0.4000   6.3838
5 |  0.5000    0.5000    0.5000    0.5000    0.5000   7.6837
6 |  0.6000    0.6000    0.6000    0.6000    0.6000   9.3885

```
```function e01tm_example
x = [0.81, 0.91, 0.13, 0.91, 0.63, 0.10, 0.28, 0.55, 0.96, 0.96, 0.16, ...
0.97, 0.96, 0.49, 0.80, 0.14, 0.42, 0.92, 0.79, 0.96, 0.66, 0.04, ...
0.85, 0.93, 0.68, 0.76, 0.74, 0.39, 0.66, 0.17;
0.15, 0.96, 0.88, 0.49, 0.41, 0.13, 0.93, 0.01, 0.19, 0.32, 0.05, ...
0.14, 0.73, 0.48, 0.34, 0.24, 0.45, 0.19, 0.32, 0.26, 0.83, 0.70, ...
0.33, 0.58, 0.29, 0.26, 0.26, 0.68, 0.52, 0.08;
0.44, 0.00, 0.22, 0.39, 0.72, 0.77, 0.24, 0.04, 0.95, 0.53, 0.16, ...
0.36, 0.28, 0.58, 0.64, 0.12, 0.03, 0.48, 0.15, 0.93, 0.41, 0.40, ...
0.15, 0.88, 0.88, 0.09, 0.33, 0.69, 0.17, 0.35;
0.83, 0.09, 0.21, 0.79, 0.68, 0.47, 0.90, 0.41, 0.66, 0.96, 0.30, ...
0.72, 0.75, 0.19, 0.57, 0.06, 0.68, 0.67, 0.13, 0.89, 0.17, 0.54, ...
0.03, 0.81, 0.60, 0.41, 0.64, 0.37, 1.00, 0.71;
0.21, 0.98, 0.73, 0.47, 0.65, 0.22, 0.96, 0.26, 0.99, 0.84, 0.58, ...
0.78, 0.28, 0.25, 0.08, 0.63, 0.66, 0.28, 0.40, 0.61, 0.09, 0.37, ...
0.36, 0.40, 0.47, 0.14, 0.36, 0.12, 0.43, 0.17];

f = [6.39;
2.50;
9.34;
7.52;
6.91;
4.68;
45.40;
5.48;
2.75;
7.43;
6.05;
5.77;
8.68;
2.38;
3.70;
1.34;
15.18;
4.35;
1.50;
3.43;
3.10;
14.33;
0.35;
4.30;
3.77;
4.16;
6.75;
5.22;
16.23;
10.62];

xe = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6;
0.1, 0.2, 0.3, 0.4, 0.5, 0.6;
0.1, 0.2, 0.3, 0.4, 0.5, 0.6;
0.1, 0.2, 0.3, 0.4, 0.5, 0.6;
0.1, 0.2, 0.3, 0.4, 0.5, 0.6];

% Generate the interpolant
nq = int64(0);
nw = int64(0);
[iq, rq, ifail] = e01tm(x, f, nw, nq);

% Evaluate the interpolant
[q, qx, ifail] = e01tn(x, f, iq, rq, xe);

fprintf('\n   |  Interpolated Evaluation Points                   |  Values\n');
fprintf('---|---------------------------------------------------+--------\n');
fprintf(' i |  xe(i,1)   xe(i,2)   xe(i,3)   xe(i,4)   xe(i,5)  | q(i)\n');
fprintf('---|---------------------------------------------------+--------\n');
for i=1:6
fprintf(' %d |%8.4f  %8.4f  %8.4f  %8.4f  %8.4f %8.4f \n', i, xe(:, i), q(i));
end
```
```

|  Interpolated Evaluation Points                   |  Values
---|---------------------------------------------------+--------
i |  xe(i,1)   xe(i,2)   xe(i,3)   xe(i,4)   xe(i,5)  | q(i)
---|---------------------------------------------------+--------
1 |  0.1000    0.1000    0.1000    0.1000    0.1000   3.2313
2 |  0.2000    0.2000    0.2000    0.2000    0.2000   4.2476
3 |  0.3000    0.3000    0.3000    0.3000    0.3000   5.2695
4 |  0.4000    0.4000    0.4000    0.4000    0.4000   6.3838
5 |  0.5000    0.5000    0.5000    0.5000    0.5000   7.6837
6 |  0.6000    0.6000    0.6000    0.6000    0.6000   9.3885

```
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 76, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.9207383990287781, "perplexity": 3501.2029989066664}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2015-14/segments/1427131299054.80/warc/CC-MAIN-20150323172139-00053-ip-10-168-14-71.ec2.internal.warc.gz"}