Linear Interpolation Calculator

Find y at a given x (or x at a given y) on the straight line through two known points. Shows the formula steps and warns when you are extrapolating.

Must differ from x₁.

Results

y at x = 3
20
Interpolation or extrapolation?
Interpolated: the known value lies between the two points.
Slope (Δy ÷ Δx)
5
Fraction of the way from x₁ to x₂
0.50
Working
y = y₁ + (x − x₁) × (y₂ − y₁) ÷ (x₂ − x₁) y = 10 + (3 − 1) × (30 − 10) ÷ (5 − 1) = 20

How it’s calculated

Linear interpolation estimates a value between two known points by assuming the data follows a straight line between them. The same line also gives an estimate beyond the points (extrapolation), which is less reliable the further you go.

y = y₁ + (x − x₁) × (y₂ − y₁) ÷ (x₂ − x₁) x = x₁ + (y − y₁) × (x₂ − x₁) ÷ (y₂ − y₁)

Example: the points (1, 10) and (5, 30) and x = 3. The slope is (30 − 10) ÷ (5 − 1) = 5, so y = 10 + (3 − 1) × 5 = 20. Going the other way, y = 25 gives x = 1 + (25 − 10) × 4 ÷ 20 = 4.

This is the n = 1 case of Lagrange interpolation. If your table has more than two points, use the polynomial interpolation calculator, which also has a table-lookup mode.

Frequently asked questions

What is the linear interpolation formula?

y = y₁ + (x − x₁)(y₂ − y₁)/(x₂ − x₁). It finds the point on the straight line through (x₁, y₁) and (x₂, y₂) at the given x.

What is the difference between interpolation and extrapolation?

Interpolation finds a value between the known points. Extrapolation extends the line beyond them, which assumes the straight-line trend continues and is usually less accurate.

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

The slope would need a division by zero. Two points with the same x lie on a vertical line, so y is not a function of x there.

Can I interpolate a table of more than two rows?

Pick the two rows on either side of your x and enter them here, or use the polynomial interpolation calculator in table-lookup mode, which does that for you.

Embed this calculator

Add this free calculator to your own website. Copy the code below into your page’s HTML:

Need this calculator branded, changed or built around your own prices?See custom business solutions →

Sources

Formulas are taken from the free public references above. Results are provided “as is” for informational and educational purposes only. See our disclaimer.

Added · Last updated · How we check our calculators

Spotted a mistake or missing option? Report a problem· Suggest a calculator