Skip to content

Linear Interpolation Calculator

Find y for any x (or x for any y) on the line through two points.

Your details

Find

Between x₁ and x₂ for interpolation; outside them for extrapolation.

Results update as you type

Interpolated y

62

Type
Interpolation (between the two points)
Slope m
3
y-intercept b
20
Line equation
y = 3x + 20

Step-by-step solution
  1. Slope: m = (y₂ − y₁) ÷ (x₂ − x₁) = (80 − 50) ÷ (20 − 10) = 30 ÷ 10 = 3
  2. x lies at t = (x − x₁) ÷ (x₂ − x₁) = 0.4 of the way from point 1 to point 2
  3. y = y₁ + m × (x − x₁) = 50 + 3 × (14 − 10) = 62

Tables rarely list the exact value you need. A steam table jumps from 10 °C to 20 °C, a tax scale from one bracket to the next, a calibration chart from one mark to another. Linear interpolation fills the gap by assuming the quantity changes in a straight line between the two known points.

This linear interpolation calculator takes two points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) and returns:

  • the interpolated y for any x — or, in reverse, the x that produces a given y;
  • whether you are interpolating (inside the interval) or extrapolating (outside it);
  • the slope, the y-intercept and the equation of the line, with every step written out.

It is the same calculation engineers, accountants and students do by hand dozens of times a day, without the risk of mixing up x1x_1 and x2x_2. When the two points come from a curve rather than a straight line, the answer is an approximation: the closer the points, the better it is.

How to use this calculator

  1. Choose whether you want y for a given x or x for a given y.
  2. Enter the two known points: x1,y1x_1, y_1 and x2,y2x_2, y_2. Their order does not matter.
  3. Enter the value to look up.
  4. Read the result, check whether it is an interpolation or an extrapolation, and open the steps to see the slope and the substitution.

The formula

The straight line through (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) has slope

m=y2−y1x2−x1m = \frac{y_2 - y_1}{x_2 - x_1}

and the interpolated value at xx is

y=y1+(x−x1) y2−y1x2−x1y = y_1 + (x - x_1)\,\frac{y_2 - y_1}{x_2 - x_1}

Reversing it gives the xx that produces a known yy (when y1≠y2y_1 \neq y_2):

x=x1+(y−y1) x2−x1y2−y1x = x_1 + (y - y_1)\,\frac{x_2 - x_1}{y_2 - y_1}

The fraction t=x−x1x2−x1t = \frac{x - x_1}{x_2 - x_1} tells you how far along you are: 0≤t≤10 \le t \le 1 means interpolation, anything else is extrapolation.

Worked example

A tank gauge reads 10 cm when the tank holds 50 L and 20 cm when it holds 80 L. How much is in the tank at 14 cm?

m=80−5020−10=3 L/cmm = \frac{80 - 50}{20 - 10} = 3 \text{ L/cm}
y=50+3×(14−10)=62 Ly = 50 + 3 \times (14 - 10) = 62 \text{ L}

Here t=0.4t = 0.4: 14 cm is 40 % of the way from the first mark to the second, so the volume is 40 % of the way from 50 to 80. The line is y=3x+20y = 3x + 20.

In reverse: at what reading does the tank hold 65 L? x=10+(65−50)÷3=15x = 10 + (65 - 50) \div 3 = 15 cm.

Extrapolation: at 25 cm the formula gives 50+3×15=9550 + 3 \times 15 = 95 L, which is only right if the tank keeps the same shape above the 20 cm mark.

When linear interpolation is accurate — and when it is not

Linear interpolation is exact for quantities that really change in a straight line, such as a constant-rate fee or a uniformly filled prism. For curved relationships (compound interest, vapour pressure, a cone-shaped tank), the error grows with the distance between the two points and with how sharply the curve bends. In practice, use the two table rows closest to your value on either side, and avoid extrapolating far beyond the data: the straight line knows nothing about what happens there.

Frequently asked questions

What is linear interpolation?

It is a way to estimate an unknown value between two known data points by assuming they are joined by a straight line. If x is 40 % of the way from x₁ to x₂, the estimated y is 40 % of the way from y₁ to y₂.

What is the difference between interpolation and extrapolation?

Interpolation estimates a value inside the range of the known points; extrapolation estimates one outside it. The formula is the same, but extrapolation is riskier because nothing guarantees the trend continues beyond the data.

Does it matter which point I enter first?

No. Swapping (x₁, y₁) and (x₂, y₂) gives the same line and the same result. Only the pairing matters: each y must stay with its own x.

Why do I get an error when x₁ equals x₂?

Two points with the same x lie on a vertical line, which does not give a single y for each x, so the slope is undefined. In the reverse mode, if y₁ equals y₂ the line is flat: either every x works or none does.

How do I interpolate in Excel or Google Sheets?

Type the formula directly: =y1+(x-x1)*(y2-y1)/(x2-x1) with cell references, or use FORECAST.LINEAR(x, {y1,y2}, {x1,x2}), which fits the same line through two points.

Last updated:

More Math calculators

People also use