Trilinear interpolation is the extension of linear interpolation, which operates in spaces with dimension D = 1 {\displaystyle D=1} , and bilinear interpolation, which operates with dimension D = 2 {\displaystyle D=2} , to dimension D = 3 {\displaystyle D=3} . These interpolation schemes all use polynomials of order 1, giving an accuracy of order 2, and it requires 2 D = 8 {\displaystyle 2^{D}=8} adjacent pre-defined values surrounding the interpolation point. There are several ways to arrive at trilinear interpolation, which is equivalent to 3-dimensional tensor B-spline interpolation of order 1, and the trilinear interpolation operator is also a tensor product of 3 linear interpolation operators.
For an arbitrary, unstructured mesh (as used in finite element analysis), other methods of interpolation must be used; if all the mesh elements are tetrahedra (3D simplices), then barycentric coordinates provide a straightforward procedure.
On a periodic and cubic lattice, let x d {\displaystyle x_{\text{d}}} , y d {\displaystyle y_{\text{d}}} , and z d {\displaystyle z_{\text{d}}} be the differences between each of x {\displaystyle x} , y {\displaystyle y} , z {\displaystyle z} and the smaller coordinate related, that is:
where x 0 {\displaystyle x_{0}} indicates the lattice point below x {\displaystyle x} , and x 1 {\displaystyle x_{1}} indicates the lattice point above x {\displaystyle x} and similarly for y 0 , y 1 , z 0 {\displaystyle y_{0},y_{1},z_{0}} and z 1 {\displaystyle z_{1}} .
First one interpolates along x {\displaystyle x} (imagine one is "pushing" the face of the cube defined by C 0 j k {\displaystyle C_{0jk}} to the opposing face, defined by C 1 j k {\displaystyle C_{1jk}} ), giving:
Where c 000 {\displaystyle c_{000}} means the function value of ( x 0 , y 0 , z 0 ) . {\displaystyle (x_{0},y_{0},z_{0}).} Then one interpolates these values (along y {\displaystyle y} , "pushing" from C i 0 k {\displaystyle C_{i0k}} to C i 1 k {\displaystyle C_{i1k}} ), giving:
Finally one interpolates these values along z {\displaystyle z} (walking through a line):
This gives us a predicted value for the point.
The result of trilinear interpolation is independent of the order of the interpolation steps along the three axes: any other order, for instance along x {\displaystyle x} , then along y {\displaystyle y} , and finally along z {\displaystyle z} , produces the same value.
The above operations can be visualized as follows: First we find the eight corners of a cube that surround our point of interest. These corners have the values c 000 {\displaystyle c_{000}} , c 100 {\displaystyle c_{100}} , c 010 {\displaystyle c_{010}} , c 110 {\displaystyle c_{110}} , c 001 {\displaystyle c_{001}} , c 101 {\displaystyle c_{101}} , c 011 {\displaystyle c_{011}} , c 111 {\displaystyle c_{111}} .
Next, we perform linear interpolation between c 000 {\displaystyle c_{000}} and c 100 {\displaystyle c_{100}} to find c 00 {\displaystyle c_{00}} , c 001 {\displaystyle c_{001}} and c 101 {\displaystyle c_{101}} to find c 01 {\displaystyle c_{01}} , c 011 {\displaystyle c_{011}} and c 111 {\displaystyle c_{111}} to find c 11 {\displaystyle c_{11}} , c 010 {\displaystyle c_{010}} and c 110 {\displaystyle c_{110}} to find c 10 {\displaystyle c_{10}} .
Now we do interpolation between c 00 {\displaystyle c_{00}} and c 10 {\displaystyle c_{10}} to find c 0 {\displaystyle c_{0}} , c 01 {\displaystyle c_{01}} and c 11 {\displaystyle c_{11}} to find c 1 {\displaystyle c_{1}} . Finally, we calculate the value c {\displaystyle c} via linear interpolation of c 0 {\displaystyle c_{0}} and c 1 {\displaystyle c_{1}}
In practice, a trilinear interpolation is identical to two bilinear interpolation combined with a linear interpolation:
An alternative way to write the solution to the interpolation problem is
where the coefficients are found by solving the linear system
yielding the result