Bilinear Interpolation: Formula and Step-by-Step Worked Example

Bilinear interpolation estimates a value at a point inside a rectangle when you know the values at the rectangle’s four corners. You run ordinary linear interpolation twice along x (once on the bottom edge, once on the top edge), then once more along y between those two results. The answer is a weighted average of the four corners, where each corner’s weight is the area of the sub-rectangle opposite it.

To skip the arithmetic, use the bilinear interpolation calculator. Enter the four corner values and your point, and it shows each step.

If you only have two points on a line, you need plain linear interpolation, and our linear interpolation calculator does that in one step. Bilinear interpolation is what you use when the data sits on a grid with two inputs, such as a map of temperatures, a table with rows and columns, or the pixels of an image.

The setup

You know the function f at four corners:

Corner Coordinates Value
Q11 (x1, y1) f(Q11)
Q21 (x2, y1) f(Q21)
Q12 (x1, y2) f(Q12)
Q22 (x2, y2) f(Q22)

You want f at a point P = (x, y) with x1 ≤ x ≤ x2 and y1 ≤ y ≤ y2.

The bilinear interpolation formula

Step 1: interpolate along x on the bottom edge (y = y1):

R1 = f(Q11) + (x − x1) / (x2 − x1) × (f(Q21) − f(Q11))

Step 2: interpolate along x on the top edge (y = y2):

R2 = f(Q12) + (x − x1) / (x2 − x1) × (f(Q22) − f(Q12))

Step 3: interpolate along y between R1 and R2:

f(P) = R1 + (y − y1) / (y2 − y1) × (R2 − R1)

Each step is the same two-point formula explained in our guide to linear interpolation.

The weighted-average form

If you write the position inside the cell as fractions, tx = (x − x1) / (x2 − x1) and ty = (y − y1) / (y2 − y1), the three steps collapse into one line:

f(P) = (1 − tx)(1 − ty) f(Q11) + tx(1 − ty) f(Q21) + (1 − tx) ty f(Q12) + tx ty f(Q22)

The four weights always add up to 1. A corner gets more weight the closer the point is to it. This form is handy in code and in spreadsheets because it is a single expression.

Worked example 1: temperature inside a grid cell

A weather model gives air temperature on a 10 km grid. You want the temperature at a farm that sits 4 km east and 7 km north of the cell’s south-west corner.

Corner Position (km east, km north) Temperature (°C)
Q11 (south-west) (0, 0) 14.0
Q21 (south-east) (10, 0) 16.0
Q12 (north-west) (0, 10) 12.0
Q22 (north-east) (10, 10) 15.0

Point P = (4, 7).

Step 1, south edge (y = 0): R1 = 14.0 + (4 − 0)/(10 − 0) × (16.0 − 14.0) = 14.0 + 0.4 × 2.0 = 14.8 °C

Step 2, north edge (y = 10): R2 = 12.0 + 0.4 × (15.0 − 12.0) = 12.0 + 1.2 = 13.2 °C

Step 3, between the edges (y = 7): f(P) = 14.8 + (7 − 0)/(10 − 0) × (13.2 − 14.8) = 14.8 + 0.7 × (−1.6) = 14.8 − 1.12 = 13.68 °C

Check with the weights

tx = 0.4 and ty = 0.7, so the weights are:

Corner Weight Weight × value
Q11 (0.6)(0.3) = 0.18 0.18 × 14.0 = 2.52
Q21 (0.4)(0.3) = 0.12 0.12 × 16.0 = 1.92
Q12 (0.6)(0.7) = 0.42 0.42 × 12.0 = 5.04
Q22 (0.4)(0.7) = 0.28 0.28 × 15.0 = 4.20
Total 1.00 13.68 °C

The north-west corner gets the biggest weight (0.42) because the farm is closest to it.

Does the order matter?

No. If you interpolate along y first (west edge: 14.0 to 12.0 at y = 7 gives 12.6; east edge: 16.0 to 15.0 gives 15.3) and then along x (12.6 to 15.3 at x = 4), you get 13.68 °C again. Bilinear interpolation gives the same answer either way.

Check it with the calculator Each of the three steps is one run of the interpolation calculator. For step 1, enter X1 = 0, Y1 = 14, X2 = 10, Y2 = 16, X3 = 4 and leave Y3 empty. You should get 14.80. Repeat with the north edge (Y1 = 12, Y2 = 15) to get 13.20, then run X1 = 0, Y1 = 14.8, X2 = 10, Y2 = 13.2, X3 = 7 to get 13.68.

Worked example 2: resizing an image

When software enlarges or rotates an image, most output pixels land between the original pixels. Bilinear interpolation blends the four nearest source pixels.

Say an output pixel maps back to source position (20.25, 14.6). The four surrounding pixels have these brightness values (0 to 255):

Pixel (column, row) Brightness
Q11 (20, 14) 91
Q21 (21, 14) 210
Q12 (20, 15) 162
Q22 (21, 15) 95

Here the cell is 1 pixel wide, so tx = 0.25 and ty = 0.6.

  • Row 14: R1 = 91 + 0.25 × (210 − 91) = 91 + 29.75 = 120.75
  • Row 15: R2 = 162 + 0.25 × (95 − 162) = 162 − 16.75 = 145.25
  • Between rows: f = 120.75 + 0.6 × (145.25 − 120.75) = 120.75 + 14.70 = 135.45

The output pixel gets brightness 135 after rounding. Nearest-neighbour resizing would simply copy pixel (20, 15) and output 162. That is why nearest-neighbour enlargements look blocky and bilinear ones look smooth but slightly soft.

The polynomial behind it

On a unit cell, bilinear interpolation fits the function

f(tx, ty) = a0 + a1 tx + a2 ty + a3 tx ty

For example 1 the coefficients are a0 = 14 (the Q11 value), a1 = 16 − 14 = 2, a2 = 12 − 14 = −2 and a3 = 15 − 16 − 12 + 14 = 1. Plugging in tx = 0.4, ty = 0.7 gives 14 + 0.8 − 1.4 + 0.28 = 13.68, the same answer.

The tx ty term is why it is called bilinear and not linear. Along any line where x or y is fixed, the surface is a straight line. Along a diagonal it bends slightly, so the surface is not a flat plane.

Where bilinear interpolation is used

  • Engineering tables with two inputs. Superheated steam tables list properties by pressure and temperature. Reading a value between two rows and two columns is the same calculation, usually called double interpolation. See also how to interpolate steam tables.
  • Maps and gridded data. Climate grids, elevation models and weather forecasts are stored on regular grids and sampled at arbitrary locations.
  • Images and textures. Image scaling, rotation and GPU texture sampling use it as the default smooth filter.
  • Lookup tables in software. Controllers and simulations store 2D tables, for example engine fuel maps, and interpolate between entries. Our guide to lookup table interpolation shows the code.

Common mistakes

  1. Mixing up the corners. Label them by position (bottom-left, bottom-right, top-left, top-right) before you start, and keep x paired with x.
  2. Using the wrong fractions. tx and ty must be between 0 and 1 for a point inside the cell. A value outside that range means you picked the wrong cell, or you are extrapolating.
  3. Expecting it to be exact on curved data. Bilinear interpolation assumes the surface is close to linear across the cell. If the data curves strongly, use a finer grid or a higher-order method such as bicubic interpolation or a cubic spline.
  4. Unequal spacing. The formula works with any x1, x2, y1, y2. You do not need a square cell, only a rectangle aligned with the axes.

Bilinear vs other 2D methods

Method Uses Smoothness Typical use
Nearest neighbour 1 point Jumps between cells Pixel art, category maps
Bilinear 4 points Continuous, with creases at cell edges Tables, maps, image resizing
Bicubic 16 points Smooth slopes across cells Photo editing, high-quality resampling

For a wider overview of one-dimensional methods, see types of interpolation.

FAQ

Is bilinear interpolation the same as doing linear interpolation twice? It is linear interpolation three times: twice along one axis and once along the other. The result does not depend on which axis you start with.

Can I use bilinear interpolation if the grid is not evenly spaced? Yes. Each cell only needs to be a rectangle aligned with the axes. Use that cell’s own x1, x2, y1 and y2.

What happens if the point is on an edge of the cell? The method reduces to normal linear interpolation along that edge. At a corner it returns the corner value exactly.

Is bilinear interpolation linear? Not quite. It is linear along lines parallel to the axes, but it contains an x × y term, so the surface can curve along diagonals.

How do I do bilinear interpolation in Python? SciPy’s RegularGridInterpolator with method=”linear” performs bilinear interpolation on a 2D grid. For the maths, Wolfram MathWorld’s bilinear interpolation page gives the formula in the same weighted form used above.

Soren Vance
Soren Vance

Soren Vance is the Director of Quantitative Analysis & Algorithms at Interpolation Calculator, where he leads the design and optimization of the company’s core interpolation engines and data processing frameworks.

With a master’s in Computational Mathematics and over 8 years of experience in analytical modeling and numerical computing, Soren oversees the development of high‑performance methods — from spline interpolation and polynomial regressions to multidimensional estimators for real‑world datasets.

Known for his clarity of thought, Soren builds systems that balance mathematical rigor with computational efficiency. He collaborates closely with product, engineering, and UX teams to ensure users get reliable, transparent, and fast results. Outside of work, he contributes to open‑source math libraries and teaches data science workshops at local universities.

Articles: 21

Interpolation Calculator is a mathematical method used to estimate an unknown value between known data points.

Privacy

Disclaimer

Terms

GDPR

Affiliate

Refund

Company

About Us

Contact Us