Mathwords logoMathwords

Lagrange Interpolating Polynomial — Definition, Formula & Examples

The Lagrange Interpolating Polynomial is the unique polynomial of lowest degree that passes exactly through a given set of data points. It expresses the interpolating polynomial as a weighted sum of basis polynomials, each constructed so that it equals 1 at one data point and 0 at all others.

Given n+1n+1 distinct points (x0,y0),(x1,y1),,(xn,yn)(x_0, y_0), (x_1, y_1), \ldots, (x_n, y_n), the Lagrange interpolating polynomial is the polynomial P(x)P(x) of degree at most nn defined by P(x)=i=0nyiLi(x)P(x) = \sum_{i=0}^{n} y_i \, L_i(x), where each Lagrange basis polynomial is Li(x)=j=0jinxxjxixjL_i(x) = \prod_{\substack{j=0 \\ j \neq i}}^{n} \frac{x - x_j}{x_i - x_j}. By the uniqueness theorem for polynomial interpolation, P(x)P(x) is the only polynomial of degree n\leq n satisfying P(xi)=yiP(x_i) = y_i for all ii.

Key Formula

P(x)=i=0nyij=0jinxxjxixjP(x) = \sum_{i=0}^{n} y_i \prod_{\substack{j=0 \\ j \neq i}}^{n} \frac{x - x_j}{x_i - x_j}
Where:
  • n+1n+1 = Total number of data points
  • (xi,yi)(x_i, y_i) = The known data points, where all $x_i$ are distinct
  • P(x)P(x) = The interpolating polynomial of degree at most $n$
  • Li(x)L_i(x) = The $i$-th Lagrange basis polynomial, equal to the product term

How It Works

You start with a set of known data points and want a polynomial that hits every one of them. For each data point (xi,yi)(x_i, y_i), you build a basis polynomial Li(x)L_i(x) that equals 1 at xix_i and 0 at every other xjx_j. Then you multiply each Li(x)L_i(x) by the corresponding yiy_i and add them all together. The result is a smooth polynomial curve that interpolates the data exactly. Once you have P(x)P(x), you can estimate values at points between the known data — this is the core idea of polynomial interpolation.

Worked Example

Problem: Find the Lagrange interpolating polynomial through the points (1, 2), (2, 3), and (4, 5), then estimate the value at x = 3.
Step 1: Build L₀(x): For the point (1, 2), construct the basis polynomial using x₁ = 2 and x₂ = 4.
L0(x)=(x2)(x4)(12)(14)=(x2)(x4)(1)(3)=(x2)(x4)3L_0(x) = \frac{(x-2)(x-4)}{(1-2)(1-4)} = \frac{(x-2)(x-4)}{(-1)(-3)} = \frac{(x-2)(x-4)}{3}
Step 2: Build L₁(x): For the point (2, 3), use x₀ = 1 and x₂ = 4.
L1(x)=(x1)(x4)(21)(24)=(x1)(x4)(1)(2)=(x1)(x4)2L_1(x) = \frac{(x-1)(x-4)}{(2-1)(2-4)} = \frac{(x-1)(x-4)}{(1)(-2)} = \frac{(x-1)(x-4)}{-2}
Step 3: Build L₂(x): For the point (4, 5), use x₀ = 1 and x₁ = 2.
L2(x)=(x1)(x2)(41)(42)=(x1)(x2)(3)(2)=(x1)(x2)6L_2(x) = \frac{(x-1)(x-2)}{(4-1)(4-2)} = \frac{(x-1)(x-2)}{(3)(2)} = \frac{(x-1)(x-2)}{6}
Step 4: Combine: Multiply each basis polynomial by its y-value and sum.
P(x)=2(x2)(x4)3+3(x1)(x4)2+5(x1)(x2)6P(x) = 2 \cdot \frac{(x-2)(x-4)}{3} + 3 \cdot \frac{(x-1)(x-4)}{-2} + 5 \cdot \frac{(x-1)(x-2)}{6}
Step 5: Evaluate at x = 3: Substitute x = 3 into each term.
P(3)=2(1)(1)3+3(2)(1)2+5(2)(1)6=23+3+53=2+9+53=4P(3) = 2 \cdot \frac{(1)(-1)}{3} + 3 \cdot \frac{(2)(-1)}{-2} + 5 \cdot \frac{(2)(1)}{6} = -\frac{2}{3} + 3 + \frac{5}{3} = \frac{-2+9+5}{3} = 4
Answer: The interpolating polynomial evaluates to P(3)=4P(3) = 4. Expanding fully, P(x)=16(x2+10x3)P(x) = \frac{1}{6}(-x^2 + 10x - 3), which simplifies to confirm the result.

Visualization

Why It Matters

Lagrange interpolation appears in numerical analysis courses and is foundational for understanding more advanced techniques like spline interpolation and numerical integration (e.g., deriving Newton-Cotes quadrature rules). Engineers and scientists use it to estimate values from experimental measurements where only discrete data is available. It also underpins theoretical results in approximation theory and is used in cryptographic protocols such as Shamir's Secret Sharing.

Common Mistakes

Mistake: Mixing up the numerator and denominator indices in the basis polynomial, such as writing (xixj)(x_i - x_j) in the numerator instead of (xxj)(x - x_j).
Correction: The numerator always contains the variable xx: each factor is (xxj)(x - x_j). The denominator uses the fixed data point: each factor is (xixj)(x_i - x_j). Double-check that jij \neq i in both products.
Mistake: Forgetting to exclude the j=ij = i term from the product, which would place a zero in both the numerator and denominator.
Correction: The product runs over all jj from 0 to nn except j=ij = i. Including j=ij = i would give a factor of (xxi)/(xixi)(x - x_i)/(x_i - x_i), which is undefined. Always skip the index that matches the current basis polynomial.

Related Terms