Home › Everyday Numbers › Linear Interpolation Calculator

Linear Interpolation Calculator

Estimate a value between two known data points. Enter (x₁, y₁), (x₂, y₂), and the x you care about; the calculator runs the straight line between your points, returns y at your x, and flags when you have left the interval (extrapolation).

Example: with x₁ (first known point) 10 · y₁ (first known point) 20 · x₂ (second known point) 30 · y₂ (second known point) 60 · x to estimate at 17.5 → Interpolated y: 35 (at x = 17.5).

  • Slope between the points2 per unit of x
  • Position along the interval37.5% of the way from x₁ = 10 to x₂ = 30
  • Interpolation or extrapolation?interpolation — x is inside [10, 30], the reliable zone

Computed by the calculator below using its default values. Change any input to see your own numbers.

Interpolated y—
Slope between the points—
Position along the interval—
Interpolation or extrapolation?—

y = y₁ + (x − x₁) × (y₂ − y₁)/(x₂ − x₁) — ride the straight line between the known points. Here: 20 + 7.5 × 2 = 35.

How linear interpolation works — and when to trust it

When a table gives you values at x = 10 and x = 30 but you need x = 17.5, linear interpolation assumes the quantity moves in a straight line between the two known points and reads the value off that line. Compute how far along the interval you are — t = (x − x₁)/(x₂ − x₁) = 0.375 here — and take that same fraction of the y-gap: y = 20 + 0.375 × 40 = 35. Graphics programmers know the identical formula as lerp.

The method is exact when the underlying relationship is truly linear and a good approximation when the curve is gentle over a narrow gap — which is why steam tables, yield curves, and survey data lean on it. It earns skepticism in two situations: wide gaps across curved data, and any x outside the known interval. That second case is extrapolation, and the calculator flags it, because a straight line follows the data's last known direction forever while reality usually bends.

How it’s calculated

y = y₁ + (x − x₁) × (y₂ − y₁)/(x₂ − x₁), equivalently y = y₁ + t(y₂ − y₁) with t = (x − x₁)/(x₂ − x₁). The position row reports t as a percentage; 0-100% means interpolation, anything else extrapolation. Results are rounded to 4 decimal places.

Assumes the quantity changes linearly between the two known points — over curved data, accuracy falls as the gap widens.

Along the line through (10, 20) and (30, 60)

xInterpolated yStatus
1020known endpoint
1530interpolated
17.535interpolated
2550interpolated
3060known endpoint
4080extrapolated — treat with caution

Computed with y = 20 + (x − 10) × 2; the slope between the endpoints is (60 − 20)/(30 − 10) = 2.

Common mistakes

  • Extrapolating far past the interval and trusting it — beyond the endpoints, nothing anchors the straight-line assumption.
  • Swapping a coordinate pair, pairing y₂ with x₁ — keep each point's values together.
  • Using one wide interval across obviously curved data instead of the two nearest table entries.
  • Confusing the fraction t (percent of the way across) with the slope — t is dimensionless; the slope carries units of y per x.

Frequently asked questions

What is the linear interpolation formula?

y = y₁ + (x − x₁) × (y₂ − y₁)/(x₂ − x₁). Find the fraction of the x-gap you have covered and add that fraction of the y-gap to y₁. Between (10, 20) and (30, 60), at x = 17.5: y = 20 + 0.375 × 40 = 35.

What is the difference between interpolation and extrapolation?

Interpolation estimates inside the known interval, where the two endpoints hem in the answer. Extrapolation extends the same line outside it — sometimes necessary, but error grows with distance because nothing constrains the curve out there.

Is this the same as lerp in programming and graphics?

Yes — lerp(a, b, t) = a + t(b − a) is the identical formula with the position t made explicit. t = 0 returns the first value, t = 1 the second, t = 0.5 the midpoint.

When is linear interpolation accurate enough?

When the true relationship is close to straight over the gap: adjacent rows of steam tables, elevations between nearby survey stations, rates between neighboring dates. For strongly curved data, shrink the gap or use a polynomial or spline fit instead.

How do I interpolate between rows of a table?

Take the table entries just below and above your target as (x₁, y₁) and (x₂, y₂), then apply the formula. For a value that depends on two table variables, interpolate along one variable first, then the other (bilinear interpolation).