Home ↓
CalculatorsVerified

Math & Geometry

Linear Interpolation Calculator

Estimate a value between two known data points. Tables of data, whether steam tables, tax tables, conversion charts, survey levels, interest rate tables or lab measurements, list values only at certain intervals. When you need a value that falls between two entries, linear interpolation assumes that the quantity changes in a straight line between them and finds the value proportionally: if x lies a quarter of the way from the first point to the second, y also lies a quarter of the way between the two y values. It is one of the most widely used techniques in engineering, science, finance and computer graphics because it is simple, fast and accurate enough whenever the data change smoothly and the points are reasonably close together. For example, if the viscosity of water is 1.002 mPa·s at 20 °C and 0.798 mPa·s at 30 °C, interpolation estimates about 0.900 at 25 °C. The same straight line can be extended beyond the two points, which is called extrapolation, but this is less reliable because the real relationship may curve outside the known range. Enter the coordinates of the two known points and the x value you want, and the calculator gives the interpolated y, the slope, the intercept, the equation of the line, whether the result is an interpolation or an extrapolation and the position of x between the two points. For strongly curved data, use more closely spaced points.

How to use this calculator

  1. Enter the first known point x₁, y₁.
  2. Enter the second known point x₂, y₂.
  3. Enter the x value you want to find y for.
  4. Read the interpolated value.
  5. Check whether it is an interpolation or an extrapolation.

How accurate is it?

The error depends on how curved the real relationship is between the points. Halving the spacing between data points usually reduces the error of linear interpolation by about four times for smooth data.

For known curves, such as exponential growth, interpolating on a logarithmic scale can be more accurate.

Uses in computing

Computer graphics use interpolation, often called lerp, to blend colours and positions in animations. Sensors and control systems use lookup tables with interpolation to convert readings quickly.

Spreadsheets can interpolate with the FORECAST or TREND functions using two points.

Formula & method

y = y₁ + (x − x₁) × (y₂ − y₁) ÷ (x₂ − x₁)Slope m = (y₂ − y₁) ÷ (x₂ − x₁)If x lies outside x₁ to x₂, the result is an extrapolationAssumes the quantity changes in a straight line between the two points

Linear interpolation: y = y₁ + (x − x₁) × (y₂ − y₁) ÷ (x₂ − x₁). Slope m = (y₂ − y₁) ÷ (x₂ − x₁); intercept b = y₁ − m x₁; the line is y = m x + b. Position = (x − x₁) ÷ (x₂ − x₁), from 0% at x₁ to 100% at x₂. When x lies outside the interval [x₁, x₂], the same formula extrapolates. For two-dimensional tables, bilinear interpolation applies the formula in each direction in turn.

Worked example

Viscosity of water at 25 °C

  1. Known: 1.002 at 20 °C and 0.798 at 30 °C.
  2. Slope = (0.798 − 1.002) ÷ 10 = −0.0204 per °C.
  3. At 25 °C: 1.002 − 0.0204 × 5 = 0.900.

Answer: About 0.900 mPa·s at 25 °C.

Frequently asked questions

What is the linear interpolation formula?

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

What is extrapolation?

Using the line outside the range of the known points.

When is interpolation accurate?

When data change smoothly and points are close.

Can x₁ equal x₂?

No, the two x values must differ.

What is the slope?

The change in y per unit change in x.

Can I use it for table lookups?

Yes, that is its most common use.