Linear Interpolation Calculator

Estimate a value between two known points, or extrapolate beyond them, with the interpolation fraction and a warning when you leave the known range.

How to use this calculator

  1. 1Enter two points you know, as x and y pairs.
  2. 2Choose whether to find y from an x, or x from a y.
  3. 3Read the result and check whether it flagged extrapolation.

How the calculation works

y = y₁ + ((x − x₁) ÷ (x₂ − x₁)) × (y₂ − y₁) t = (x − x₁) ÷ (x₂ − x₁)
(x₁, y₁)
The first known point
(x₂, y₂)
The second known point
t
The interpolation fraction: 0 at the first point, 1 at the second, outside that range means extrapolating
slope
(y₂ − y₁) ÷ (x₂ − x₁), the constant rate of change assumed between the points

The formula is "start at y₁, then move the same fraction along y as x has moved along x". That fraction, often written t, is the whole idea — in graphics the same operation is called lerp.

When t is between 0 and 1 the target lies between the known points and this is interpolation. Outside that range it is extrapolation, which is the same arithmetic with far weaker justification.

Solving for x instead of y just inverts the relationship, and needs the two y values to differ — a horizontal line gives the same y everywhere, so no unique x exists.

Worked example

Halfway between two points

  1. 1.Known points: (10, 20) and (20, 40).
  2. 2.The fraction along: (15 − 10) ÷ (20 − 10) = 5 ÷ 10 = 0.5, exactly halfway.
  3. 3.The change in y across the interval is 40 − 20 = 20.
  4. 4.y = 20 + 0.5 × 20 = 30.
  5. 5.The slope is 20 ÷ 10 = 2, so the line is y = 2x.

Result: y = 30

Reading between rows of a steam table

  1. 1.A table gives enthalpy 419.1 kJ/kg at 100°C and 461.3 kJ/kg at 110°C.
  2. 2.For 104°C, the fraction along is (104 − 100) ÷ 10 = 0.4.
  3. 3.The change across the interval is 461.3 − 419.1 = 42.2.
  4. 4.y = 419.1 + 0.4 × 42.2 = 419.1 + 16.88 = 435.98 kJ/kg.
  5. 5.This is the standard use of interpolation: reading between the rows of a printed table.

Result: 435.98 kJ/kg

Interpolation is a straight-line assumption, and it is usually wrong

Linear interpolation assumes the quantity changes at a constant rate between two known points. Almost nothing in nature does. Temperature, growth, decay and pressure all curve, so the straight line is an approximation whose error depends entirely on how curved the truth is and how far apart your points are.

The error is largest in the middle of the interval, where you are furthest from both known values, and it shrinks as the points get closer together. This is why tables are printed with fine intervals: close spacing makes the straight-line assumption harmless, and interpolating between rows a degree apart is far safer than between rows ten degrees apart.

For a convex curve the straight line always sits above the truth; for a concave one, below. The error is therefore systematic rather than random, which means interpolating many values does not average it away.

Why extrapolation deserves its bad reputation

Interpolation is bounded by the data on both sides — the answer must lie between two values you actually know, which limits how wrong it can be. Extrapolation has no such constraint. Once outside the known range, the only thing holding the estimate up is the assumption that the pattern continues, and there is no evidence for that in the data.

The error grows with distance and without limit. Doubling the distance beyond the last known point does not double the uncertainty; for a curved relationship it can grow much faster, and the estimate can end up not merely imprecise but qualitatively wrong — predicting negative quantities, or values past a physical maximum.

This calculator flags when the target falls outside the known range rather than quietly producing a number, because the arithmetic is identical and nothing else would tell you.

What this assumes, and where it stops

Assumptions

  • The relationship between the two known points is a straight line.
  • The two known points are exact, with no measurement error of their own.

Limitations

  • Two points only. Interpolating across a curve is better done with more points and a polynomial or spline fit.
  • Systematically wrong for curved relationships, with the largest error in the middle of the interval.
  • Extrapolation is flagged but not corrected — the estimate is only as good as the assumption that the line continues.
  • Treats the known points as exact. Where they carry measurement error, that error propagates into the result and is not modelled.

Common questions

What is linear interpolation?

Estimating a value between two known points by assuming a straight line between them. Move the same fraction along y as your target has moved along x: y = y₁ + ((x − x₁) ÷ (x₂ − x₁)) × (y₂ − y₁). It is the standard way of reading between the rows of a table.

What is the difference between interpolation and extrapolation?

Interpolation estimates between known points, where the answer is bounded by values you actually have. Extrapolation extends beyond them, where nothing constrains the estimate but the assumption that the pattern continues. The arithmetic is identical; the reliability is not remotely comparable.

How accurate is linear interpolation?

It depends on how curved the underlying relationship is and how far apart the known points are. Error is worst in the middle of the interval and shrinks as points get closer. For a convex curve the straight line always overestimates, so the error is systematic rather than averaging out.

What is lerp?

The same operation under its computer graphics name — linear interpolation between two values by a fraction t, usually written lerp(a, b, t) = a + t(b − a). It is used for animation, colour blending and camera movement, where t typically runs from 0 to 1 over the duration of the effect.

Sources

Formula and content last reviewed on .

Results are estimates for information only, not professional advice.

Report an error

Tools people commonly use alongside the linear interpolation calculator.

See all math calculators →