Lagrange Interpolation Calculator

Fit the polynomial through your points and evaluate it at any x.

Formula

P(x) = Σ yᵢ · Lᵢ(x),   Lᵢ(x) = Πj≠i (x − xⱼ) / (xᵢ − xⱼ)

n points define a unique polynomial of degree n − 1 that passes through all of them.

Example

The points (1, 1), (2, 8), (3, 27), (4, 64) lie on y = x³. The calculator recovers P(x) = x³, so P(2.5) = 15.625. A straight line between (2, 8) and (3, 27) would give 17.5.

How the basis polynomials work

Each Lᵢ(x) equals 1 at its own point xᵢ and 0 at every other data point. Weighting each one by yᵢ and adding them up gives a curve that hits every point exactly.

When not to use it

Avoid it with many points or noisy measurements, where a single high-degree polynomial swings between points. Use piecewise linear interpolation or a least-squares fit instead.

FAQ

How many points can I use?

Up to 15, but more than 6–8 often causes wild swings between points (Runge’s phenomenon). For many points, use table interpolation.

Is it the same as Newton interpolation?

It produces the same polynomial, written differently. Newton’s form is easier to extend with a new point.

What does it give with two points?

A straight line, the same as linear interpolation.