Bilinear Interpolation Calculator
Enter the four corners of a rectangular grid cell (x1, x2, y1, y2), their known function values at each corner (Q11, Q12, Q21, Q22), and the target point (x, y). The calculator estimates the function value at that point using bilinear interpolation and shows every step of the two-stage linear calculation so you can follow the maths exactly.
Formula
Worked example
Corners: Q11 = 12 at (0,1), Q21 = 0 at (4,1), Q12 = -4 at (0,3), Q22 = 8 at (4,3). Target: (1, 2). Step 1a: R1 = (3/4)*12 + (1/4)*0 = 9. Step 1b: R2 = (3/4)*(-4) + (1/4)*8 = -1. Step 2: P = (1/2)*9 + (1/2)*(-1) = 4.
What is bilinear interpolation?
Bilinear interpolation estimates the value of a function at an arbitrary point (x, y) inside a rectangular grid cell, given that the function is known at the four corners of that cell. The method performs two separate one-dimensional linear interpolations: first horizontally along the bottom edge of the rectangle, then along the top edge, producing two intermediate values (R1 and R2). A final linear interpolation in the vertical direction between R1 and R2 gives the answer. Despite its two-step linear construction, the result is actually bilinear, meaning it is linear in x and linear in y but contains a cross-product term x*y that makes it mildly curved overall. This makes bilinear interpolation a natural extension of simple linear interpolation to two dimensions.
How to use this calculator
Fill in the four grid boundaries (x1, x2, y1, y2) and the function values at the four corners (Q11, Q12, Q21, Q22), then enter the target coordinates (x, y) where you need the estimate. The naming convention follows the standard mathematical notation: Q11 is the value at (x1, y1) - the bottom-left corner; Q21 is at (x2, y1) - bottom-right; Q12 is at (x1, y2) - top-left; Q22 is at (x2, y2) - top-right. The target point must lie inside the rectangle (between x1 and x2 horizontally, and between y1 and y2 vertically). The result panel shows the final interpolated value P as well as the two intermediate values R1 and R2, and the step-by-step panel walks through every multiplication and addition so you can verify the working or copy the method into your own code.
The bilinear interpolation formula
Let dx = x2 - x1 and dy = y2 - y1. The x-axis weights are wX1 = (x2 - x) / dx and wX2 = (x - x1) / dx. Step 1 produces two intermediate values: R1 = wX1 * Q11 + wX2 * Q21 (along the bottom edge at y = y1) and R2 = wX1 * Q12 + wX2 * Q22 (along the top edge at y = y2). The y-axis weights are wY1 = (y2 - y) / dy and wY2 = (y - y1) / dy. Step 2 gives the final estimate: P = wY1 * R1 + wY2 * R2. This is equivalent to the compact matrix form P = (1 / (dx * dy)) * [x2-x, x-x1] * [[Q11, Q12],[Q21, Q22]] * [y2-y; y-y1], which is how many numerical libraries implement it.
Properties, accuracy, and alternatives
Bilinear interpolation is exact at the four corners and exact along any horizontal or vertical line through the cell. The cross-product term x*y makes it slightly curved along diagonals, which gives better accuracy than nearest-neighbour interpolation but introduces a mild smoothing effect. For very smooth functions the error scales as O(h^2) where h is the grid spacing, the same order as linear interpolation in 1D. When you need higher accuracy, bicubic interpolation uses a 4x4 neighbourhood instead of 2x2 and achieves O(h^4) convergence at the cost of needing derivatives at the corners. For scattered (non-grid) data, methods such as natural-neighbour or radial-basis interpolation are better choices. Bilinear interpolation is preferred in real-time applications such as texture mapping and image resizing because it is fast, reversible, and needs only the nearest four samples.
Common applications of bilinear interpolation
| Field | Typical grid | What is interpolated |
|---|---|---|
| Digital image processing | Pixel grid (integer coordinates) | Colour or intensity at sub-pixel position |
| GIS / terrain modelling | Latitude-longitude grid | Elevation, temperature, or rainfall |
| Computational fluid dynamics | Mesh nodes | Velocity, pressure, or density |
| Engineering lookup tables | Two-parameter design chart | Material property, efficiency, or load rating |
| Weather / climate data | Regular lat-long grid | Wind speed, humidity, or pressure at a sensor location |
| Finite-element post-processing | Element nodes | Stress, strain, or displacement inside an element |
Bilinear interpolation appears across science, engineering, and computing wherever 2D grid data must be sampled at non-grid locations.
Frequently asked questions
What inputs does bilinear interpolation need?
You need four things: the coordinates of the rectangle corners (x1, x2, y1, y2), the function value at each of the four corners (Q11, Q12, Q21, Q22), and the target point (x, y) where you want an estimate. The target must lie inside the rectangle. If it falls outside, you are extrapolating, which bilinear interpolation does not guarantee to be accurate.
Is bilinear interpolation the same as linear interpolation?
No, but it is built from two successive linear interpolations. Standard linear interpolation works in one dimension (along a line segment). Bilinear interpolation extends that idea to two dimensions by first interpolating horizontally at two y-levels, then interpolating vertically between those results. The overall function is linear in x alone and linear in y alone, but the combination produces a surface with a mild curvature due to the x*y cross term.
Does the order of the two interpolation passes matter?
No. You can interpolate first along x then along y, or first along y then along x. Both orderings produce the same final answer because the underlying formula is symmetric in x and y. This calculator uses the horizontal-first convention (x first, then y), but the result would be identical if the vertical pass were done first.
Why does the result sometimes fall outside the range of the corner values?
Bilinear interpolation is not guaranteed to stay within the range of the corner values. When the function has a saddle-shaped variation over the cell - the corners at opposite ends of a diagonal are large while the other two are small - the bilinear surface can produce values outside the corner range at some interior points. This is a property of the x*y cross term in the formula. If you need a monotone or bounded interpolant, consider alternative methods such as shape-preserving Hermite interpolation.
How is bilinear interpolation used in image processing?
When an image is scaled, rotated, or warped, the destination pixel coordinates rarely fall exactly on source pixel centres. Bilinear interpolation estimates the colour at the fractional source position using the four nearest pixel values as the corners. Compared with nearest-neighbour resampling, bilinear gives smoother results without the blocky artefacts, and compared with bicubic it runs faster, making it a popular default in many image-editing applications.
What happens if the target point is exactly on a corner or edge?
If the target falls exactly on one of the four corners, the result equals that corner value exactly - no approximation is involved. If the target lies on an edge (one coordinate equals a boundary), the formula reduces to a single linear interpolation between the two corner values on that edge. The formula handles both cases correctly without any special casing.