Interpolation Calculator

Estimate an unknown y value between (or just outside) two known points using linear interpolation. Enter both points and a target x — the calculator returns y along with the slope, the full formula substitution, and a diagram of the line.

First known point (x₁, y₁)
Second known point (x₂, y₂)

What is interpolation?

Interpolation is estimating a value between data points you already know. Suppose a thermometer logs 20 °C at 10:00 and 80 °C at 30:00 (some odd chemistry experiment) — what was the temperature at 18:00? You don't have a reading at 18:00, but if you assume the temperature climbed at a steady rate over those twenty minutes, you can draw a straight line between the two known times and read off the value at 18:00. That's linear interpolation.

The same idea shows up whenever you look something up in a table that doesn't list your exact value — steam tables, tax brackets, tabulated log values, currency conversions between two dated rates. If the underlying quantity changes smoothly across the gap, a straight-line estimate is usually good enough.

Linear interpolation, piece by piece

Two known points anchor a straight line; the calculator walks through the slope, applies the interpolation formula, and flags whether your target x falls inside or outside the anchor range.

The linear interpolation formula

Two known points define a slope m = (y₂ − y₁)/(x₂ − x₁). Starting from (x₁, y₁), adding m·(x − x₁) lands on the y for any new x on that same straight line.

y = y₁ + (y₂ − y₁) · (x − x₁) / (x₂ − x₁)
x₁xx₂
Example
Given
(10, 20), (30, 80), x = 18
Substitute
20 + (80 − 20)·(18 − 10)/(30 − 10)
Answer
y = 44

Interpolation vs extrapolation

The same formula works for any x, but you only trust it inside [x₁, x₂]. Outside, you're assuming the straight line keeps going — errors grow the further you push past the data.

trust when x ∈ [x₁
x₂] · caution otherwise
safe: inside [x₁, x₂]risky
Example
Given
anchors at x=10, x=30 · query x=45
Substitute
x lies outside the sampled range
Answer
extrapolation — flagged

Features of this calculator

  • Accepts any two distinct anchor points — positive, negative, decimal, in any order
  • Handles both interpolation (x inside [x₁, x₂]) and extrapolation (x outside), flagging the difference
  • Shows the slope calculation before the interpolation formula so you can see where the number comes from
  • SVG plot of the line with anchor points and target labelled — see whether your query point is a safe interpolation
  • Guards against the x₁ = x₂ case where the slope is undefined
  • Clean handling of very small and very large numbers via scientific notation when it helps

Frequently asked questions

+When is linear interpolation a good approximation?

When the underlying function is smooth and your two anchor points are close enough together that curvature is negligible across the gap. Fine-grained tables (log tables, steam tables), measurements at short intervals, and locally linear physical processes all qualify. For highly non-linear data, either shrink the interval or switch to a higher-order method like polynomial or spline interpolation.

+What if my target x equals x₁ or x₂?

Then the formula simply returns y₁ or y₂ respectively — no interpolation is needed because you already have the answer. The calculator handles both cases naturally.

+Why can't x₁ equal x₂?

Two points with the same x value describe a vertical line, which has no unique y for a given x. The slope formula divides by (x₂ − x₁), so the denominator would be zero. Change one of the x values to get a well-defined line.

+How is this different from a regression line?

Linear interpolation passes exactly through your two given points. Linear regression fits a best-fit line through many data points, minimising overall error but generally missing each individual point. Use interpolation when your two anchors are known exactly; use regression when you have noisy data spread across several observations.

Related calculators