ThisCalculator

Everyday

Linear Interpolation Formula Calculator

Updated · Standard formula, shown below

Interpolated y 10.0000
Slope (m)
2.0000
Result
x₁
0
You entered
y₁
0
You entered

This calculator performs linear interpolation between two known data points, giving you the estimated y-value for any x between them. You enter the coordinates of the two points (x1, y1) and (x2, y2) and the target x, and the calculator returns the interpolated y-value. It uses the standard two-point form of the linear equation, so you get an exact result for any straight-line relationship.

Formula

The linear interpolation formula is:

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

Where:

  • x₁, y₁ – coordinates of the first known point (any unit)
  • x₂, y₂ – coordinates of the second known point (same units as x₁, y₁)
  • x – the target x-value where you want to estimate y (must be between x₁ and x₂ for interpolation; outside that range it becomes extrapolation)
  • y – the estimated y-value at x (same units as y₁ and y₂)

The formula assumes a straight line between the two points. It is the same as the point-slope form of a line: y = y₁ + m(x − x₁), where m = (y₂ − y₁)/(x₂ − x₁).

Worked Example

Using the default values from the calculator above:

  • Point 1: (0, 0)
  • Point 2: (10, 20)
  • Target x: 5

Step 1: Calculate the slope: m = (20 − 0) / (10 − 0) = 2

Step 2: Apply the formula: y = 0 + (20 − 0) × (5 − 0) / (10 − 0) = 0 + 20 × 5 / 10 = 10

So the interpolated y-value at x = 5 is 10, which matches the calculator’s first output. The slope output is 2, as expected.

When to Use Linear Interpolation

Linear interpolation is appropriate when you have two data points and you believe the relationship between x and y is approximately linear over that interval. Common uses include:

  • Estimating values from a table (e.g., steam tables, statistical tables, calibration curves) when the exact value is not listed.
  • Filling in missing data points in a time series, assuming a constant rate of change.
  • Creating smooth transitions in computer graphics and animation (lerp).
  • Approximating a function between two known values when the function is nearly straight over the interval.

If the relationship is known to be curved (e.g., exponential, logarithmic, or polynomial), linear interpolation will introduce error. In such cases, use a higher-order interpolation method (quadratic, cubic spline) or fit a curve to the data.

How to Read the Result

The interpolated y-value is the estimated output for the given x. For example, if you have a table of temperature vs. pressure for a gas, and you need pressure at a temperature that falls between two table entries, linear interpolation gives you the pressure assuming a straight-line change between those two points.

Remember that the result is only as good as the linear assumption. If the data points are far apart or the curve bends sharply, the estimate may be off. The slope output helps you see how steep the line is; a large slope means small changes in x produce large changes in y, so small errors in x can lead to large errors in y.

Common Mistakes and Pitfalls

  • Using the wrong order of points: The formula works regardless of which point is called “first” or “second,” but you must be consistent. If you swap x₁ and x₂, you must also swap y₁ and y₂.
  • Not checking that x is between x₁ and x₂: If x is outside that range, you are extrapolating, not interpolating. Extrapolation is riskier because the linear assumption may not hold beyond the known data.
  • Unit mix-ups: If x is in meters and y is in seconds, the slope will be in seconds per meter, and the interpolated y will be in seconds. Make sure you interpret the result with the correct units.
  • Rounding too early: Rounding intermediate steps can cause a noticeable error in the final answer. Keep full precision until the end.
  • Assuming linearity: The formula is exact only for a straight line. For real-world data, it is an approximation. Always check whether the curve is smooth enough over the interval.

Limits and Alternatives

Linear interpolation has a clear limitation: it ignores curvature. If you have more than two data points, you can use piecewise linear interpolation (connecting each pair of points with a straight line), which is what many table-lookup functions do. For smoother results, use:

  • Quadratic interpolation – fits a parabola through three points.
  • Cubic spline interpolation – fits piecewise cubic polynomials, giving a smooth curve.
  • Polynomial interpolation – fits a single polynomial through all points, but can oscillate wildly for many points.
  • Regression – if the data has noise, a least-squares fit (linear or nonlinear) is more appropriate than interpolation.

For most practical purposes, linear interpolation is fast, simple, and accurate enough when the interval is small and the function is smooth.

Frequently Asked Questions

What is the difference between interpolation and extrapolation?

Interpolation estimates a value between two known data points. Extrapolation estimates a value outside the range of the known points. The same formula works for both, but extrapolation is riskier because you assume the linear trend continues indefinitely, which is often not true.

Can I use linear interpolation for non-linear data?

Yes, but the result will be an approximation. The error depends on how much the curve deviates from a straight line over the interval. For highly curved data, use a higher-order method or collect more data points.

How do I interpolate between two points in a table?

Take the two table entries that surround your target x. Treat the lower one as (x₁, y₁) and the upper one as (x₂, y₂). Plug your target x into the formula and solve for y. Many tables are designed so that linear interpolation is acceptable over small intervals.

What if my x values are not evenly spaced?

That is fine. The formula uses the actual x coordinates, so uneven spacing is handled correctly. The slope will be the average rate of change over that interval.

Does linear interpolation work for negative numbers?

Yes. The formula works with any real numbers, including negative coordinates. Just be careful with the order of operations and signs.

Why is my interpolated value slightly different from a spreadsheet’s result?

Spreadsheet functions like FORECAST or TREND may use the same linear formula, but they might round differently or use a different method (e.g., least-squares regression) if you give them more than two points. For exactly two points, the result should be identical.

Related

Formula used
in x1 | x₁ | - | 0 | 0
in y1 | y₁ | - | 0 | 0
in x2 | x₂ | - | 10 | 0
in y2 | y₂ | - | 20 | 0
in x | Target x | - | 5 | 0
out y | Interpolated y | - | y1 + (y2 - y1) * (x - x1) / (x2 - x1) | 4
out slope | Slope (m) | - | (y2 - y1) / (x2 - x1) | 4

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.