What Is Linear Interpolation and How Does It Work?

Linear interpolation is a method for estimating an unknown value between two known data points by assuming a straight-line relationship between them. If you know the temperature at 2 PM and 4 PM, linear interpolation lets you estimate what it was at 3 PM. It’s one of the simplest and most widely used techniques in math, engineering, computer graphics, and data analysis.

How It Works

The idea is straightforward: you have two points, and you draw a straight line between them. Any value you need between those two points falls somewhere on that line. The closer your target is to one point, the closer the result will be to that point’s value.

Say you’re reading a table that tells you a material is 100 units long at 20°C and 110 units long at 40°C. You need to know its length at 30°C. Since 30 is exactly halfway between 20 and 40, linear interpolation gives you 105, exactly halfway between 100 and 110. If you needed the value at 25°C instead (one quarter of the way), you’d get 102.5.

The core principle is that the slope stays constant. The rate of change between your first known point and your estimated point is the same as the rate of change between the two known points. That constant-slope assumption is what makes the math simple and the method so fast to compute.

The Formula

The standard formula looks like this:

Y = Yₐ + (X − Xₐ) × (Y_b − Yₐ) / (X_b − Xₐ)

Here, (Xₐ, Yₐ) and (X_b, Y_b) are your two known data points. X is the input value where you want an estimate, and Y is the result. The fraction (X − Xₐ) / (X_b − Xₐ) represents how far along you are between the two known X values, expressed as a proportion from 0 to 1. Multiply that proportion by the total change in Y, add it to your starting Y value, and you have your answer.

To make this concrete: suppose you know that at X = 10 the value is 50, and at X = 20 the value is 80. You want the value at X = 14. Plugging in: Y = 50 + (14 − 10) × (80 − 50) / (20 − 10) = 50 + 4 × 3 = 62.

Interpolation vs. Extrapolation

Interpolation estimates values between known data points. Extrapolation estimates values outside your data range, either before your first point or after your last. The distinction matters because interpolation is generally more reliable. When you interpolate, your estimate is anchored on both sides by real measurements.

Extrapolation requires you to assume that the same trend continues beyond what you’ve actually observed. That assumption gets riskier the further you go. A stock price that rose steadily for five months might crash in month six. A chemical reaction that behaved linearly at moderate temperatures might change behavior at extremes. Whenever possible, interpolation is the preferred approach because it doesn’t require betting on an unchanged future.

When It Works Well (and When It Doesn’t)

Linear interpolation is most accurate when the relationship between your two variables is close to a straight line, or when your known data points are spaced closely together. If the true relationship curves gently and your points are tight, the straight-line assumption introduces very little error.

It struggles when the data follows a strongly curved or irregular pattern. Imagine estimating a point on a roller coaster’s path using only two distant points: the straight line between them would miss every hill and valley in between. For these situations, more advanced methods like cubic spline interpolation exist, which fit smooth curves through data points instead of straight lines. Interestingly, though, curves aren’t always better. A study comparing linear and cubic spline interpolation on lake water temperature profiles found that when conditions varied a lot with depth, linear interpolation actually performed better. The cubic spline method produced less average bias but generated more extreme errors, overshooting or undershooting dramatically in places where the data changed abruptly.

The takeaway: linear interpolation is a safe default for most everyday estimation tasks. Its errors are predictable and bounded. More complex methods can improve accuracy in smooth datasets, but they can also behave unpredictably when the data is messy.

Bilinear Interpolation for Images

In computer graphics and image processing, the concept extends naturally into two dimensions. When you resize a photo, the software needs to figure out color values for pixels that didn’t exist in the original image. Bilinear interpolation handles this by applying linear interpolation twice: once horizontally between two pairs of neighboring pixels, then once vertically between those intermediate results.

If you need the color at a point that falls between four surrounding pixels, you first interpolate along the top edge and the bottom edge to get two intermediate values, then interpolate between those two to get your final answer. This produces smoother results than simply snapping to the nearest pixel, which is why bilinear interpolation is a standard technique in image scaling, texture mapping in video games, and geographic information systems.

Using It in Excel

For a quick two-point interpolation in Excel, you can apply the formula directly. If your known points are in cells (say X values in A1 and A2, Y values in B1 and B2), you can type the formula into any cell:

=B1 + (target_x – A1) * (B2 – B1) / (A2 – A1)

Replace “target_x” with the X value you’re estimating for, or reference a cell containing it. This gives you exact linear interpolation between two points.

Excel also has a built-in function called FORECAST.LINEAR (or just FORECAST in older versions). Its syntax is FORECAST.LINEAR(x, known_y’s, known_x’s), where x is the value you want to predict for. However, this function fits a regression line through all the data you provide, not just the two nearest points. It’s useful when you have a larger dataset and want a best-fit line, but it’s not the same as point-to-point interpolation. For true interpolation between specific pairs of values, the manual formula approach is more precise.

Using It in Python

Python’s NumPy library provides a dedicated function: numpy.interp(x, xp, fp). Here, x is the value (or array of values) where you want estimates, xp is a list of your known X coordinates, and fp is the corresponding list of known Y coordinates. The X coordinates need to be in increasing order.

A simple example: if you call numpy.interp(14, [10, 20], [50, 80]), you get 62.0, matching the manual calculation from earlier. The function also handles arrays, so you can pass in dozens or thousands of target values at once and get results for all of them in a single call. When a target value falls outside your data range, NumPy returns the value of the nearest endpoint by default, though you can customize this behavior.

Common Uses

  • Engineering tables: Looking up material properties, pressure ratings, or conversion factors that fall between tabulated values.
  • Finance: Estimating interest rates or bond yields between quoted maturities on a yield curve.
  • Animation and gaming: Smoothly transitioning an object’s position, color, or size between keyframes.
  • Sensor data: Filling in gaps when instruments record measurements at irregular intervals.
  • Weather and climate: Estimating temperature, pressure, or rainfall at locations between weather stations.

In each of these cases, the core logic is identical: two known values, a straight line between them, and a proportional estimate for anything in between.