Lagrange Interpolation Calculator

Lagrange interpolation finds the single lowest-degree polynomial that passes exactly through every point you give it, then evaluates that polynomial at any target x you choose. Unlike a straight-line estimate between two points, it can capture curvature when you provide three or four points, making it useful for reconstructing a smooth function from a small table of measured values. This calculator accepts up to four points, builds the Lagrange basis polynomials behind the scenes, and returns the interpolated value at your target x. Leave later x fields blank to interpolate with fewer points.

0.00
0.00
0.00

Lagrange interpolation formula

P(x) = sum over j of [ y_j * L_j(x) ]
L_j(x) = product over k not equal to j of [ (x - x_k) / (x_j - x_k) ]
degree = number of points - 1

Each basis polynomial L_j(x) equals 1 at node j and 0 at every other node, so the weighted sum reproduces all known points exactly. With n distinct points the result is a polynomial of degree n minus 1.

Notes on using Lagrange interpolation

  • Two points give a line, three give a parabola, four give a cubic curve.
  • All x values must be distinct or the formula divides by zero.
  • Leave later point fields blank to interpolate with fewer than four points.
  • High-degree fits can oscillate between points (Runge's phenomenon); use splines for many points.
  • The polynomial passes exactly through every supplied point, so each known point reproduces its own y.

Lagrange interpolation: frequently asked questions

What is Lagrange interpolation?

Lagrange interpolation builds the unique polynomial of lowest degree that passes exactly through a set of known data points. For n points it produces a polynomial of degree n minus 1. The value at a target x is a weighted sum of the known y values, where each weight is a Lagrange basis polynomial.

What is the Lagrange interpolation formula?

The interpolated value is P(x) equals the sum over j of y_j times L_j(x), where each basis polynomial L_j(x) is the product over all k not equal to j of (x - x_k) / (x_j - x_k). Each L_j equals 1 at its own x_j and 0 at every other node, so the sum reproduces every known point exactly.

How many points can I enter?

This calculator accepts up to four points, producing a polynomial of degree three or lower. Leave a point's x field blank to use fewer points. Two points reduce to ordinary linear interpolation, three points give a quadratic, and four points give a cubic.

Do the x values need to be unique?

Yes. Every x value must be distinct, because the basis polynomials divide by the differences between nodes. If two x values are equal the denominator becomes zero and the polynomial is undefined, so the calculator returns n/a until you make the x values different.

When should I avoid high-degree Lagrange interpolation?

Fitting a single high-degree polynomial through many points can produce large oscillations between the points, known as Runge's phenomenon, especially near the ends of the interval. For many evenly spaced points, piecewise or spline interpolation usually gives a smoother, more reliable fit.

Official sources

Reviewed by the CalculatorHub team, edited by James Graham, 17 June 2026. See our methodology.