# Using the TPS to interpolate between points

I have implemented the Thin Plate Spline interpolation.

I successfully plotted surfaces which go through all my 3D data points.

What I want to do is calculate a few points which lie between my known data points.

The TPS returns a vector with coefficients for a function, which is called $w$ in the cited page. But what does this function look like, how to insert the coefficients?

Wikipedia says that TPS has closed-form solution, so what's its shape?

Given data sites (centers) $\{x_i\}_{i=1}^N$ and data values to interpolate $\{y_i\}_{i=1}^N$, the thin plate spline interpolant is the function $$s(x) = \sum_{i=1}^n c_i \varphi(\|x-x_i\|) + \sum_{l=0}^{m} b_i p_l(x)$$ where $\varphi(r) = r^2 \log(r)$ and $p_l$ is a set of polynomials spanning the space of at most degree one polynomials (p_0 = 1, p_1 = x, p_y = y, p_z = z for example). The coefficients $c_i$ must satisfy the "orthogonality" relationship $$\sum_{i=1}^N c_i p_l(x_i) = 0.$$ So, you set-up a matrix system $$\begin{pmatrix}A & P \\ P^T & 0 \end{pmatrix} \begin{pmatrix}c \\ b \end{pmatrix} = \begin{pmatrix} y \\ 0 \end{pmatrix}$$ with $A_{ij} = \varphi(\|x_i-x_j\|)$ and $P_{i,l} = p_l(x_i)$. When you solve this linear system, you get back the coefficients $c_i$ and $b_l$.
Now, let's say we want to evaluate the interpolant on another set of points, call this set of points $\{z_k\}_{k=1}^M$ ($M$ possibly very different from $N$. That is, we want to compute (for each $z_k$) $$s(z_k) = \sum_{i=1}^N c_i \varphi(\|z_k-x_i\|) + \sum_{l=0}^m b_l p_l(z_k).$$
To evaluate this for each $z_k$, we can set up a matrix and do a matrix-vector multiplication to get a vector $\{s(z_k)\}_{k=1}^M$. Let $\hat{A}_{k,i} = \varphi(\|z_k-x_i\|)$ and let $\hat{P}_{k,l} = p_l(z_k)$. Then, we compute $$\begin{pmatrix} \hat{A} & \hat{P} \end{pmatrix} \begin{pmatrix} c \\ b \end{pmatrix} = \begin{pmatrix} s(z_k). \end{pmatrix}$$