Skip to content
K Knidox Search…
Math · Numerical methods

Interpolation Calculator

Read a value between data points — by straight line, or by the polynomial through every point, with the divided-difference table.

Method
One per line, as “x, y”. They are sorted for you.
Anywhere; outside the data it becomes extrapolation, and the page says so.

3 points, so the interpolating polynomial has degree 2. The polynomial passes through every one of them exactly.

Value at x = 2.1
0.7418701

degree 2 polynomial through all 3 points

Polynomial degree
2

one less than the number of points, unless the data already lies on something simpler

A straight line would give
0.7408023

difference 1.068e-3

The interpolating curve
Data points with the interpolating polynomial through them

x from 1.95y from 0.67 to 0.86to 2.35

P(x) = −0.10678x^2 + 0.925027x − 0.729787

Divided differences
xf(x)order 1order 2
20.69314720.476551-0.10678
2.20.78845740.444517
2.30.8329091

The highlighted top row is the Newton form’s coefficients: P(x) = f[x₀] + f[x₀,x₁](x − x₀) + f[x₀,x₁,x₂](x − x₀)(x − x₁) + …

Examples — tap to load

Linear interpolation reads between two table rows: y = y₀ + (x − x₀)(y₁ − y₀) ÷ (x₁ − x₀). Polynomial interpolation uses every point instead, and exactly one polynomial of degree ≤ n passes through n + 1 points with distinct x values.

Between two rows of a table

The everyday case is a printed table that stops short of the value you need — a steam table at 110 °C and 120 °C when the problem says 115 °C, a tax band, a calibration curve. Linear interpolation draws a straight line between the two neighbouring rows and reads off the height at your x. It is the first thing to reach for, it needs no more than four numbers, and for a smooth quantity sampled closely it is usually accurate enough that the table’s own rounding dominates the error.

The accuracy has a known shape. The error of linear interpolation over a step of width h is bounded by h²·max|f″| ÷ 8, so halving the spacing quarters the error. That is also why a table with tight rows can be interpolated linearly with confidence while one with wide rows cannot.

Using every point at once

Polynomial interpolation fits a single polynomial through all the data. There is exactly one of degree at most n through n + 1 points with distinct x values, so Lagrange’s formula and Newton’s divided-difference formula are not competing answers — they are two ways of writing the same polynomial, and this page computes both and checks them against each other.

Newton’s form is the one worth seeing, because the divided differences build up in a triangle that a textbook will ask you to reproduce. Each entry divides a difference of the column to its left by the span of x it covers, and the top row of the triangle is exactly the list of coefficients. Adding a new data point appends one row and one new coefficient without disturbing anything already computed, which is why Newton’s form is preferred in practice over Lagrange’s.

P(x) = f[x₀] + f[x₀,x₁](x − x₀) + f[x₀,x₁,x₂](x − x₀)(x − x₁) + …

Newton’s divided-difference form; the coefficients are the top row of the triangle

  1. 1
    Sort the points by x. Interpolation does not care about the order they were collected in, but the table is only readable sorted.
  2. 2
    For a straight line, find the two points either side. Then y = y₀ + (x − x₀) × (y₁ − y₀) ÷ (x₁ − x₀). The fraction is the slope of the segment.
  3. 3
    For a polynomial, build the divided-difference table. First column is the y values. Each later entry is the difference of the two above it, divided by the span of x those entries cover.
  4. 4
    Read the coefficients off the top row. They multiply 1, (x − x₀), (x − x₀)(x − x₁) and so on, in that order.
  5. 5
    Evaluate by nesting, not by expanding. Expanding to standard form loses precision when the x values are large or close together; nested evaluation does not.

Which method for which job

Degree here means the degree of the polynomial actually fitted, not the number of points available.

SituationUseWhy
Reading between two table rowsLinearError falls with the square of the row spacing; a close table needs nothing more.
Three to five well-spaced pointsPolynomialCaptures curvature the straight line misses, without room to oscillate.
Many points, evenly spacedSplines, not a single polynomialA high-degree fit on even spacing swings wildly between the data — Runge’s phenomenon.
Many points, noisyLeast-squares regressionInterpolation passes through every point, including the errors in them.
Outside the data rangeNothing, if you can avoid itEvery method above is unreliable there, and the polynomial is the worst of them.

Why more points can make the answer worse

It is natural to assume that fitting more points gives a better curve. For evenly spaced data it is false, and spectacularly so. The standard demonstration is Runge’s function, 1 ÷ (1 + 25x²), on the interval from −1 to 1. Interpolating it at 5 evenly spaced points gives a worst error of about 0.44. At 9 points the worst error is about 1.05; at 11 points, 1.92; at 15 points, 7.19. The polynomial passes through every data point exactly and is wrong by more than the function’s entire range in between, with the damage concentrated near the ends.

The fix is not a better algorithm but a different model: either put the points where the oscillation cannot grow — Chebyshev spacing, clustered towards the ends — or give up on one global polynomial and join low-degree pieces instead, which is what a spline does. Both are standard, and both exist because the single high-degree interpolant does not work.

One more limit worth stating plainly. Interpolation reconstructs a function between points you trust. If the data carry measurement error, forcing a curve through every point forces it through every error too, and a regression line that misses all the points can easily be the more accurate model. Extrapolating past the ends of the data is worse again: the tool marks it, because a polynomial’s behaviour outside its data is governed by its highest-degree term and has nothing to do with the phenomenon you measured.

What is the linear interpolation formula?
y = y₀ + (x − x₀) × (y₁ − y₀) ÷ (x₁ − x₀), where (x₀, y₀) and (x₁, y₁) are the points either side of your x. It is the equation of the line through those two points.
Lagrange or Newton — which is correct?
Both. There is only one polynomial of degree ≤ n through n + 1 points with distinct x values, so the two formulas produce the same curve. Newton’s form is preferred because adding a point extends it instead of restarting it.
What are divided differences?
A triangle built from the data: each entry is the difference of the two entries above it divided by the span of x they cover. The top row gives Newton’s coefficients, and the last entry bounds the interpolation error.
How many points should I use?
Two for a straight line, three to five for a curve. Beyond about six evenly spaced points a single polynomial starts oscillating between the data rather than following it.
What is Runge’s phenomenon?
The wild oscillation a high-degree interpolant develops near the ends of evenly spaced data. On 1 ÷ (1 + 25x²) over [−1, 1] the worst error grows from about 0.44 at 5 points to about 7.19 at 15 — more points, far worse fit.
Can I interpolate outside the data?
The arithmetic will produce a number, but that is extrapolation, and it is unreliable. Outside the data a polynomial is driven by its highest-degree term, so the curve is describing the fit rather than the thing measured.
Interpolation or regression?
Interpolation when the points are exact and you want the value between them. Regression when the points carry error — forcing a curve through noisy data reproduces the noise.