ThisCalculator

Everyday

Interpolation Formula Calculator & How to Use It

Updated · Standard formula, shown below

The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.

This calculator performs linear interpolation between two known data points: you enter the x and y coordinates of two points plus a target x-value, and it returns the interpolated y-value at that x. It also shows the slope of the line and the full equation, so you can verify the result by hand. Linear interpolation is the most common method for estimating values between two measured points when the relationship is roughly straight.

Formula

The linear interpolation formula finds a point on the straight line connecting two known points. Given (x₁, y₁) and (x₂, y₂), the y-value at any x is:

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

  • x – the target x-value where you want the estimate (same units as x₁ and x₂)
  • y – the interpolated result (same units as y₁ and y₂)
  • x₁, y₁ – coordinates of the first known point
  • x₂, y₂ – coordinates of the second known point

The expression (y₂ − y₁) / (x₂ − x₁) is the slope of the line, often written as m. The formula assumes the relationship between x and y is linear—that a constant change in x produces a constant change in y.

Worked Example

Using the default values from the calculator: (x₁, y₁) = (0, 0), (x₂, y₂) = (10, 20), and target x = 5.

  1. Calculate the slope: (20 − 0) / (10 − 0) = 20 / 10 = 2
  2. Apply the formula: y = 0 + (20 − 0) × (5 − 0) / (10 − 0)
  3. Simplify: y = 0 + 20 × 5 / 10 = 100 / 10 = 10

The interpolated y-value is 10, which matches the calculator’s output. The line equation is y = 2x + 0, so at x = 5, y = 10.

When to Use Linear Interpolation

Linear interpolation is appropriate when you have two data points and need a quick estimate between them, and the underlying relationship is approximately linear. Common uses include:

  • Reading values from calibration curves (e.g., a sensor’s output vs. known standards)
  • Estimating intermediate values from tables (e.g., density of water at a temperature between listed values)
  • Filling gaps in time-series data where changes are gradual
  • Graphics and image scaling when resizing pixels

It is not appropriate when the relationship is known to be curved, such as exponential growth, logarithmic decay, or sinusoidal patterns. In those cases, use a polynomial, spline, or a model specific to the phenomenon.

How to Read the Result

The interpolated y-value is your best estimate of the dependent variable at the target x, assuming a straight-line change between the two known points. The slope tells you the rate of change: for every one unit increase in x, y changes by the slope value. The line equation lets you compute y for any x, not just the target.

If your target x lies outside the range [x₁, x₂], the calculator still returns a value—this is called extrapolation. Extrapolation is riskier because you are extending the line beyond the observed data, and the true relationship may diverge. Use extrapolated results with caution.

Common Mistakes and Limitations

  • Unit mix-ups: If x is in seconds and y is in meters, the slope has units of m/s. Make sure x and y are in consistent units before entering them.
  • Reversed points: The formula works regardless of which point is first, as long as you keep x₁ paired with y₁ and x₂ with y₂. Swapping both pairs gives the same result; swapping only one gives a wrong line.
  • Assuming linearity: The biggest error is using linear interpolation on data that is clearly curved. Always plot your data or check the residuals if possible.
  • Rounding too early: Rounding the slope before applying the formula can introduce noticeable error. Keep full precision during calculation, then round the final answer.
  • Extrapolation overconfidence: Values outside the known range are guesses based on a straight line—they can be wildly inaccurate if the trend changes.

Comparison with Other Interpolation Methods

Linear interpolation is the simplest and fastest method, but it creates a piecewise linear curve that is not smooth at the data points. Alternatives include:

  • Polynomial interpolation: Fits a single polynomial through all points. It can oscillate wildly with many points (Runge’s phenomenon), so it is rarely used for more than a handful of points.
  • Spline interpolation: Fits low-degree polynomials between each pair of points, ensuring smooth first and second derivatives. Cubic splines are the standard for smooth curves.
  • Nearest-neighbor: Simply takes the value of the closest point. Fast but produces a step-like result.

For most engineering and scientific tables, linear interpolation is accurate enough when the data is densely spaced. For smooth curves, cubic splines are preferred.

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 known points. Interpolation is generally safer because you are staying within the observed domain, while extrapolation assumes the trend continues indefinitely, which may not hold.

Can I use linear interpolation for non-linear data?

You can, but the result will only be accurate if the data is approximately linear over the interval. If the data curves significantly, linear interpolation will underestimate or overestimate. For curved data, use a spline or a polynomial fit, or transform the data to make it linear.

Does the order of the two points matter?

No, as long as you keep the x and y coordinates paired correctly. The slope (y₂ − y₁)/(x₂ − x₁) is the same whether you go from point 1 to point 2 or vice versa, because both numerator and denominator change sign. The formula is symmetric.

What if x₂ equals x₁?

If x₂ = x₁, the denominator becomes zero, and the slope is undefined. This means the two points are vertical—there is no unique line. Check your inputs; you need two distinct x-values for interpolation.

How do I interpolate between more than two points?

For more than two points, you typically interpolate piecewise: find the interval containing your target x, then apply linear interpolation using the endpoints of that interval. For a smoother result across all points, use cubic spline interpolation, which fits a separate cubic polynomial to each interval with matching derivatives at the knots.

Is linear interpolation the same as finding the equation of a line?

Yes, linear interpolation is exactly evaluating the equation of the straight line that passes through the two known points. The formula is derived from the point-slope form: y − y₁ = m(x − x₁), where m is the slope. So the calculator is essentially computing the line’s y-value at your target x.

Related

Formula used
in x1 | First x | - | 0 | 0
in y1 | First y | - | 0 | 0
in x2 | Second x | - | 10 | 0
in y2 | Second 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
out eq | Line equation | - | y = " + round(slope,4) + "x + " + round(y1 - slope * x1,4) | 0

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.