Lagrange Interpolation
Construct the unique polynomial passing exactly through any set of data points.
Try Lagrange Interpolation — No Sign-in NeededWhat is the Lagrange Interpolation?
Lagrange interpolation constructs the unique polynomial of degree ≤ n−1 that passes exactly through n given data points. Unlike curve fitting (which minimizes error across many points), interpolation guarantees the polynomial touches every point precisely. This makes it valuable when the data is exact — such as function values at specific nodes — and you want to evaluate the function at points between them.
The method is named after Joseph-Louis Lagrange, who published it in 1795, though the technique was known earlier to Edward Waring and Euler. The Lagrange form expresses the interpolating polynomial as a sum of basis polynomials, each of which equals 1 at one data node and 0 at all others. The final polynomial is a weighted sum where the weights are the corresponding function values.
A critical phenomenon to understand is Runge's phenomenon: for functions with high curvature (like 1/(1+25x²)), equally-spaced nodes at high degree cause the polynomial to oscillate wildly near the edges of the interval — even as the number of points increases. This is why practitioners often use Chebyshev nodes (non-equally spaced points concentrated near the endpoints) or piecewise cubic splines instead of high-degree global polynomials.
The Formula
Each term is the product of the y-value at node i and the Lagrange basis polynomial Lᵢ(x), which equals 1 at xᵢ and 0 at every other node xⱼ.
Step-by-Step Algorithm
- 1
Collect n data points (x₀, y₀), (x₁, y₁), …, (xₙ₋₁, yₙ₋₁). All xᵢ must be distinct.
- 2
For each i, compute the basis polynomial Lᵢ(x) = ∏ⱼ≠ᵢ (x − xⱼ) / (xᵢ − xⱼ).
- 3
Note that Lᵢ(xᵢ) = 1 and Lᵢ(xⱼ) = 0 for j ≠ i.
- 4
The interpolating polynomial is P(x) = Σᵢ yᵢ · Lᵢ(x).
- 5
To evaluate P at a new point x, substitute and compute the sum.
Convergence & Behaviour
The interpolating polynomial is unique — given n distinct x-nodes, there is exactly one polynomial of degree ≤ n−1 passing through all n points. This is guaranteed by the unisolvence theorem. The interpolation error at a point x is bounded by the (n+1)-th derivative of f and the product of distances from x to all nodes. Adding more equally-spaced nodes does not always improve accuracy — for smooth but non-analytic functions, increasing n can increase the error near the interval edges (Runge's phenomenon).
Use Lagrange interpolation for a small number of points (typically ≤ 10) where exact passage through the data is required, or to recover a polynomial from its values at specific nodes.
Avoid high-degree Lagrange interpolation with equally-spaced nodes — use Chebyshev nodes or cubic splines instead. For noisy data, use least-squares regression rather than interpolation.
Worked Example
Find the polynomial through (0,1), (1,3), (2,7).
- 1.L₀(x) = (x−1)(x−2)/((0−1)(0−2)) = (x−1)(x−2)/2
- 2.L₁(x) = (x−0)(x−2)/((1−0)(1−2)) = x(x−2)/(−1) = −x(x−2)
- 3.L₂(x) = (x−0)(x−1)/((2−0)(2−1)) = x(x−1)/2
- 4.P(x) = 1·L₀ + 3·L₁ + 7·L₂
- 5.P(x) = (x−1)(x−2)/2 − 3x(x−2) + 7x(x−1)/2
- 6.Expanding: P(x) = 2x² + 1 (verify: P(0)=1 ✓, P(1)=3 ✓, P(2)=9... let me recalculate: 2(4)+1=9 but we want 7. The points lie on y = x²+x+1: check: 0+0+1=1 ✓, 1+1+1=3 ✓, 4+2+1=7 ✓)
- 7.P(x) = x² + x + 1
Result: P(x) = x² + x + 1, a degree-2 polynomial through all 3 points.
Try It Now — No Account Required
Want the full platform experience?
Sign up free and unlock infinite-zoom canvas, AI Tutor explanations, Canvas LTI grade passback, and your full solve history — pre-loaded with the Lagrange Interpolation example above.