Multidimensional interpolation
Multidimensional interpolation is the process of finding a multivariable function $f(x_1,\cdots,x_m)$ that for a definite set of datapoints $\{(x_{1,i},\cdots,x_{m,i},y_i)\mid i\in [0,n], i \in \mathbb{N}\}$ satisfies $f(x_{1,i},\cdots,x_{m,i})=y_i$.
Methods
Grid interpolation
If a "grid" of $n^m$ datapoints is known:
$$ \{(x_{1,i_1},\cdots,x_{m,i_m},y_{i_1,\cdots,i_m})\mid i_1,\cdots,i_m \in [0,n-1],\, i_1,\cdots,i_m \in \mathbb{N}\} $$
Then an $m$-dimensional interpolation can be obtained via $n^{m-1}$ one-dimensional interpolations on each variable, fixing all other variables at all possible combinations of known constant values.
Each of those interpolations runs along one axis-parallel line of the grid. Along $x_j$ there are $n^{m-1}$ such lines, one for each combination of the other $m-1$ indices, so the construction uses $m\,n^{m-1}$ one-dimensional interpolations in all, one per line, each independent of the others.
The line interpolants on their own do not single out $f$; they are combined multiplicatively, by requiring $f$ to be a polynomial of degree at most $n-1$ in each variable separately:
$$ f(x_1,\cdots,x_m)=\sum_{i_1=0}^{n-1}\cdots\sum_{i_m=0}^{n-1}y_{i_1,\cdots,i_m}\prod_{j=1}^{m}L^{(j)}_{i_j}(x_j),\qquad L^{(j)}_{i}(x)=\prod_{\substack{k=0\\k\neq i}}^{n-1}\frac{x-x_{j,k}}{x_{j,i}-x_{j,k}} $$
where $L^{(j)}_i$ is the Lagrange basis polynomial of the variable $x_j$. The result is the tensor product interpolant, and it is the unique polynomial of degree at most $n-1$ in each variable that reproduces the $n^m$ datapoints[1].
Pointwise interpolation
Pointwise interpolation (or point evaluation) asks only for the value of $f$ at one new point $(x_1^*,\cdots,x_m^*)$ inside the data range, without constructing $f$ anywhere else. It uses the same grid of $n^m$ datapoints and the same one-dimensional interpolations, but chains them instead of laying them out side by side.
In two dimensions, the first pass interpolates along $x_1$ inside each row $x_2=x_{2,i_2}$, at the target $x_1^*$:
$$ y^*_{i_2}=\sum_{i_1=0}^{n-1}L^{(1)}_{i_1}(x_1^*)\,y_{i_1,i_2},\qquad \forall i_2\in [0,n-1], i_2 \in \mathbb{N} $$
The $n$ intermediate values $y^*_{i_2}$ sit at the coordinates $(x_1^*,x_{2,i_2})$, i.e., on a one-dimensional grid in $x_2$, so a second pass interpolates them at $x_2^*$:
$$ f(x_1^*,x_2^*)=\sum_{i_2=0}^{n-1}L^{(2)}_{i_2}(x_2^*)\,y^*_{i_2} $$
The first pass costs $n$ one-dimensional interpolations and the second costs $1$. In $m$ dimensions the passes shrink by one variable each time, costing $n^{m-1}, n^{m-2}, \cdots, n^0$:
$$ \sum_{k=0}^{m-1}n^{k}=\frac{n^{m}-1}{n-1} $$
which is the nested form
$$ f(x_1^*,\cdots,x_m^*)=\sum_{i_m=0}^{n-1}L^{(m)}_{i_m}(x_m^*)\sum_{i_{m-1}=0}^{n-1}L^{(m-1)}_{i_{m-1}}(x_{m-1}^*)\cdots\sum_{i_1=0}^{n-1}L^{(1)}_{i_1}(x_1^*)\,y_{i_1,\cdots,i_m} $$
This count is smaller than the $m\,n^{m-1}$ of grid interpolation, because the passes are not symmetric. In the first pass "all other variables" do range over $n^{m-1}$ combinations of known values, as in the grid case; afterwards one variable is pinned at the target $x_j^*$, which contributes one position instead of $n$. Nothing is thrown away: the two counts answer different questions, the value at one point and the whole surface.
The order of the passes does not matter. Collapsing $x_1$ first and then $x_2$ gives the same number as collapsing $x_2$ first and then $x_1$, because the tensor product sum can be regrouped; every ordering evaluates the same polynomial of grid interpolation[2].
| $m$ | grid interpolation, $m\,n^{m-1}$ | pointwise, $\sum_{k=0}^{m-1}n^{k}$ |
|---|---|---|
| 2 | 8 | 5 |
| 3 | 48 | 21 |
| 4 | 256 | 85 |
For a general number of variables the passes are most conveniently written as contractions, one per variable:
def grid_interpolate_point(axes, values, point):
"""Interpolated value at `point` from an n_1 x ... x n_m grid.
axes -- one 1-D array of node coordinates per variable, in the same order
as the axes of `values`
values -- m-dimensional array, values[i_1, ..., i_m]
point -- the m query coordinates
"""
data = np.asarray(values, dtype=float)
for axis in range(len(axes) - 1, -1, -1): # collapse one variable per pass
data = np.tensordot(data, lagrange_weights(axes[axis], point[axis]),
axes=([axis], [0]))
return float(data)
For the station grid, `grid_interpolate_point([latitude, longitude], temperature, [51.6, 1.4])` returns `22.1162048...`, which is the two-pass calculation of the example above: four longitude interpolations give $24.094$, $23.038$, $21.433$, and $19.666\ ^\circ$C on the rows at $50$, $51$, $52$, and $53^\circ$N, and one latitude interpolation of those four values gives the reading at the query point.
Because these readings happen to be close to planar, bilinear interpolation of the four stations surrounding the query point gives $22.100\ ^\circ$C, only $0.02\ ^\circ$C away from the grid interpolant. The two are not interchangeable, however: the bilinear interpolant is merely continuous where cells meet, whereas the grid interpolant is a single polynomial and therefore smooth everywhere.
References
- ↑ Gasca, M., & Sauer, T. (2000). Polynomial interpolation in several variables. Advances in Computational Mathematics, 12, 377-410. https://doi.org/10.1023/A:1018981505752
- ↑ Neidinger, R. D. (2019). Multivariate Polynomial Interpolation in Newton Forms. SIAM Review, 61(2), 361-381. https://doi.org/10.1137/17M1124188
