How to calculate linear interpolation
Enter two distinct x coordinates and the value at each one. Compute the fraction of the way from the first x to the second. Use that fraction as the weight of the second value. The first value gets the remaining weight.
t = (x − x₀) ÷ (x₁ − x₀). Estimated value = (1 − t) × z₀ + t × z₁.
If the values at x = 0 and x = 10 are 10 and 20, then x = 2 is one fifth of the way from the first endpoint. The estimate is 12.
How to calculate bilinear interpolation from four corners
Use two x coordinates and two y coordinates that form a rectangle. Keep each value with its labeled corner. Set t = (x − x₀) ÷ (x₁ − x₀) and u = (y − y₀) ÷ (y₁ − y₀). The four weights are (1 − t)(1 − u), t(1 − u), (1 − t)u and tu, respectively.
This follows from applying the same one-axis interpolation on both x edges, then interpolating those results along y. The NIST Dataplot documentation describes bilinear interpolation as a weighted average of four surrounding points on a complete rectangular grid.
For x endpoints 0 and 10, y endpoints 0 and 20, and corner values 10, 20, 30 and 50 at (0,0), (10,0), (0,20) and (10,20), the target (2,5) has weights 3/5, 3/20, 1/5 and 1/20. The estimate is 17.5.
Interpolation versus extrapolation
The target can fall inside, on the boundary or outside. Outside values require enabling extrapolation. That calculation continues the same formula, which can give negative weights and values outside the range of the inputs.
Each axis can run in either direction if its values stay attached to the correct coordinates. Repeated endpoints leave the interval width at zero and are rejected. The worksheet uses the entered rectangular grid or interval. It does not fit curves or interpolate scattered points.