InfyCalculator
➗

Lagrange Interpolation Calculator

Find the Lagrange interpolating polynomial through 2 to 10 points with exact fractions, evaluate it at any x, and see each basis polynomial value Lᵢ(x).

x values
y values
Evaluate at x
Loading calculator…

How it works

P(x) = Σᵢ yᵢ·Lᵢ(x), Lᵢ(x) = Πⱼ≠ᵢ (x − xⱼ)/(xᵢ − xⱼ) · degree ≤ n − 1 for n points

Through n points with different x values there is exactly one polynomial of degree at most n − 1. Lagrange’s form writes it as a weighted sum of basis polynomials Lᵢ(x), each equal to 1 at its own xᵢ and 0 at every other node, so P(xᵢ) = yᵢ automatically. Expanding the sum gives the usual coefficient form, shown here with exact fractions.

Worked example

Through (1, 2), (2, 3) and (3, 6): L₁(2.5) = (2.5 − 2)(2.5 − 3)/((1 − 2)(1 − 3)) = −1/8, L₂(2.5) = 3/4 and L₃(2.5) = 3/8. So P(2.5) = 2(−1/8) + 3(3/4) + 6(3/8) = 17/4 = 4.25, and the polynomial is P(x) = x² − 2x + 3.

Sources: Lagrange polynomial — Wikipedia · Lagrange Interpolating Polynomial — Wolfram MathWorld

Frequently asked questions

What is Lagrange interpolation used for?

To estimate values between known data points, build a smooth curve through measurements, or derive numerical integration and differentiation formulas.

Why does the polynomial wiggle with many points?

High-degree polynomials through equally spaced points oscillate near the ends (Runge’s phenomenon). Use fewer points near the x you need, or piecewise (spline) interpolation.

Is it the same as Newton’s divided-difference polynomial?

Yes — the interpolating polynomial is unique, so Lagrange and Newton forms give the same polynomial; they are just different ways of writing it.

Can I extrapolate outside the data range?

The calculator will evaluate any x, but extrapolation is unreliable: the polynomial can move far away from the true trend outside the nodes.

Related calculators

This calculator is for educational purposes. Double-check important results before acting on them.