What is Lagrange interpolation?
Lagrange polynomial interpolation finds a polynomial that passes exactly through the data points you supply. If there are n + 1 points with distinct X coordinates, there is exactly one interpolating polynomial of degree at most n.
Unlike polynomial regression, interpolation matches the input values at every supplied X coordinate. That makes it useful when you want to reconstruct a curve from known measurements or understand interpolation in numerical methods.
The Lagrange interpolation formula
For points (x₀, y₀), (x₁, y₁), …, (xₙ, yₙ), write the polynomial as a weighted sum of basis polynomials:
Each basis polynomial Lᵢ(x) equals 1 at its own X coordinate and 0 at the other supplied X coordinates:
Multiplying each basis polynomial by its Y value and adding the terms creates the final interpolation polynomial.
Example: interpolate three points
Suppose you want a polynomial through these coordinates:
| Point | X | Y |
|---|---|---|
| 1 | 1 | 2 |
| 2 | 2 | 5 |
| 3 | 3 | 10 |
Step 1. Build the basis polynomials
For each point, use the other two X coordinates:
Step 2. Weight by Y and add
Use the three Y values, 2, 5, and 10:
Step 3. Simplify and check
Expanding and collecting like terms gives:
Check the inputs: P(1) = 2, P(2) = 5, and P(3) = 10. The polynomial passes through all three points.
How to use the calculator
- Open the Lagrange interpolation calculator.
- Enter X and Y values in the two columns. Start with at least two points, and use Add point for more.
- Ensure every X value is different. Y values may be the same. Use the ± button next to a field to enter negative numbers on mobile.
- Select Calculate polynomial to display the formula and plot the curve. Then choose Print / Save as PDF to create a report with points, formula, and graph.
You can test the worked example above by entering (1, 2), (2, 5), and (3, 10). The displayed coefficients may include trailing zeros because the calculator rounds them for readability.
Open the calculatorFrequently asked questions
How many points do I need?
Two distinct X coordinates define a line. Three points define a polynomial of degree at most two, four points of degree at most three, and so on.
Can two points have the same X value?
Not for standard Lagrange interpolation. Two identical X coordinates make the basis formula divide by zero, even if the Y values are equal.
Is interpolation the same as regression?
No. Interpolation passes through all supplied points; regression usually seeks an approximate fit and can be better for noisy measurements.
Can I use negative or decimal values?
Yes. The X and Y coordinates can be negative or decimal numbers. For very many points or extreme values, floating-point rounding may affect numerical accuracy.