How to use the Lagrange Interpolation Calculator
- 1. Enter the x valuesType the known x values, separated by commas.
- 2. Enter the y valuesType the matching y values in the same order.
- 3. Choose xEnter the x where you want y and press Interpolate.
Lagrange's formula
Given n points (xᵢ, yᵢ), there is exactly one polynomial of degree n − 1 through all of them. Lagrange writes it as P(x) = Σ yᵢ Lᵢ(x), where Lᵢ(x) = Π (x − xⱼ)/(xᵢ − xⱼ) over all j ≠ i. Each Lᵢ is 1 at xᵢ and 0 at every other data point.
The x values do not need to be equally spaced, which is the big advantage over Newton's difference formulas. The tool also expands P(x) so you can see the polynomial itself.
Worked example
Given f(5) = 12, f(6) = 13, f(9) = 14 and f(11) = 16, find f(10).
L₀(10) = (10−6)(10−9)(10−11)/((5−6)(5−9)(5−11)) = −4/−24 = 0.1667. L₁(10) = (5)(1)(−1)/((1)(−3)(−5)) = −0.3333. L₂(10) = (5)(4)(−1)/((4)(3)(−2)) = 0.8333. L₃(10) = (5)(4)(1)/((6)(5)(2)) = 0.3333.
f(10) = 12(0.1667) + 13(−0.3333) + 14(0.8333) + 16(0.3333) = 14.6667. The four Lᵢ add up to 1, a quick check on your working.
Good practice
Interpolation is safe inside the range of your data. Outside it (extrapolation) the polynomial can swing wildly, and the tool warns you. With many points a single high-degree polynomial can wiggle between them, so use the nearest few points instead of all of them. For equally spaced data, the Newton forward difference table gives the same answer with a difference table.
Frequently asked questions
Do the x values need to be equally spaced?
No. Lagrange's formula works for any distinct x values.
Why do the Lᵢ values add up to 1?
Interpolating the constant function 1 must give 1 everywhere, so Σ Lᵢ(x) = 1 for any x.
How many points can I use?
Up to 15. In practice 3 to 6 nearby points give the most reliable estimates.
Is this calculator free?
Yes. You enter your name and WhatsApp number once when you see your result, and other Uncodemy tools then open without the form.