Understanding the bilinear interpolation calculator — concept and principle
This calculator estimates a value inside a rectangle from the values at its four corners, the way you read between the rows and columns of a two-way table. It shows the fractions s and t, the two edge values and the weight of each corner. Engineers use it with steam tables and design charts; it is also how images are resized smoothly.
How it is calculated
s = (x − x₁) ÷ (x₂ − x₁); t = (y − y₁) ÷ (y₂ − y₁)
Along x at the bottom: R₁ = (1 − s) f₁₁ + s f₂₁
Along x at the top: R₂ = (1 − s) f₁₂ + s f₂₂
Result: f = (1 − t) R₁ + t R₂
Equivalent single formula: f = (1 − s)(1 − t) f₁₁ + s(1 − t) f₂₁ + (1 − s)t f₁₂ + st f₂₂
- If s or t lies outside 0–1, the point is outside the cell and the result is an extrapolation.
The principle
Bilinear interpolation is linear interpolation done twice: first along x on the bottom and top edges, then along y between those two results. Doing y first and x second gives the same answer. Each corner's weight equals the area of the sub-rectangle diagonally opposite it, so corners close to the point get more weight and the four weights add up to 1. The surface it produces is straight along every horizontal and vertical line but can be gently curved diagonally.
Worked example
Default inputs: x₁ = 0, x₂ = 10, y₁ = 0, y₂ = 20; corner values 12, 16 (bottom) and 20, 30 (top); point (4, 15).
- s = (4 − 0) ÷ 10 = 0.4; t = (15 − 0) ÷ 20 = 0.75.
- R₁ = 0.6 × 12 + 0.4 × 16 = 7.2 + 6.4 = 13.6.
- R₂ = 0.6 × 20 + 0.4 × 30 = 12 + 12 = 24.
- f = 0.25 × 13.6 + 0.75 × 24 = 3.4 + 18 = 21.4.
- Corner weights: 0.15, 0.1, 0.45, 0.3; the point is inside the grid cell — interpolation.
| y₂ (top) | Interpolated value f(x, y) |
|---|---|
| 5 | 44.8 |
| 10 | 29.2 |
| 15 | 24 |
| 20 | 21.4 |
| 25 | 19.84 |
| 30 | 18.8 |
| 40 | 17.5 |
How to read the result
The estimate is good when the true quantity changes smoothly and the grid is fine. If the table values curve strongly between grid lines, the error grows, and a finer table or a higher-order method is better. Extrapolated values outside the cell should be treated with great caution.
Common mistakes
- Mixing up which corner value belongs to which (x, y) pair.
- Swapping x and y between the table and the calculator.
- Using it far outside the table range.
- Interpolating in a table whose values jump, such as across a phase change in steam tables.
Frequently asked questions
What is bilinear interpolation used for?
Reading two-way tables, resizing images and estimating values on maps and grids.
Does the order of interpolation matter?
No; interpolating along x then y gives the same result as y then x.
Is bilinear interpolation linear?
It is linear along each axis separately, but the surface has an xy term, so it is not a flat plane.
Sources: E. W. Weisstein, "Bilinear Interpolation", Wolfram MathWorld · W. H. Press et al., Numerical Recipes, 3rd ed. (2007), §3.6