# Tricubic interpolation

3D interpolation tries to assign a value at the red point $C$ given values at the blue corner points.

In the mathematical subfield numerical analysis, tricubic interpolation is a method for obtaining values at arbitrary points in 3D space of a function defined on a regular grid. The approach involves approximating the function locally by an expression of the form

$f(x,y,z)=\sum_{i=0}^3 \sum_{j=0}^3 \sum_{k=0}^3 a_{ijk} x^i y^j z^k.$

This form has 64 coefficients $a_{ijk}$; requiring the function to have a given value or given directional derivative at a point places one linear constraint on the 64 coefficients.

The term tricubic interpolation is used in more than one context; some experiments measure both the value of a function and its spatial derivatives, and it is desirable to interpolate preserving the values and the measured derivatives at the grid points. Those provide 32 constraints on the coefficients, and another 32 constraints can be provided by requiring smoothness of higher derivatives.[1]

In other contexts, we can obtain the 64 coefficients by considering a 3x3x3 grid of small cubes surrounding the cube inside which we evaluate the function, and fitting the function at the 64 points on the corners of this grid.

The cubic interpolation article indicates that the method is equivalent to a sequential application of one-dimensional cubic interpolators. Let $\mathrm{CINT}_x(a_{-1}, a_0, a_1, a_2)$ be the value of a monovariable cubic polynomial (e.g. constrained by values, $a_{-1}$, $a_{0}$, $a_{1}$, $a_{2}$ from consecutive grid points) evaluated at $x$. In many useful cases, these cubic polynomials have the form $\mathrm{CINT}_x(u_{-1}, u_0, u_1, u_2) = \mathbf{v}_x \cdot \left( u_{-1}, u_0, u_1, u_2 \right)$ for some vector $\mathbf{v}_x$ which is a function of $x$ alone. The tricubic interpolator is equivalent to:

\begin{align} s(i,j,k) & {} = \text{The value at grid point } (i,j,k)\\ t(i,j,z) & {} = \mathrm{CINT}_z\left( s(i,j,-1), s(i,j,0), s(i,j,1), s(i,j,2)\right) \\ u(i,y,z) & {} = \mathrm{CINT}_y\left( t(i,-1,z), t(i,0,z), t(i,1,z), t(i,2,z)\right) \\ f(x,y,z) & {} = \mathrm{CINT}_x\left( u(-1,y,z), u(0,y,z), u(1,y,z), u(2,y,z)\right) \end{align} where $i,j,k\in\{-1,0,1,2\}$ and $x,y,z\in[0,1]$.

At first glance, it might seem more convenient to use the 21 calls to $\mathrm{CINT}$ described above instead of the ${64 \times 64}$ matrix described in Lekien and Marsden.[2] However, a proper implementation using a sparse format for the matrix (that is fairly sparse) makes the latter more efficient. This aspect is even much more pronounced when interpolation is needed at several locations inside the same cube. In this case, the ${64 \times 64}$ matrix is used once to compute the interpolation coefficients for the entire cube. The coefficients are then stored and used for interpolation at any location inside the cube. In comparison, sequential use of one-dimensional integrators $\mathrm{CINT}_x$ performs extremely poorly for repeated interpolations because each computational step must be repeated for each new location.