Lagrange Interpolating Polynomials

A rearranged form of Newton’s divided difference polynomial.

The kk-th Lagrange basis polynomial for n+1n+1 nodes is:

Ln,k(x)=∏i=0i≠knx−xixk−xiL_{n,k}(x) = \prod_{\substack{i=0 \\ i \neq k}}^{n} \frac{x - x_i}{x_k - x_i}
Here:
x0,x1,…,xnx_0, x_1, \ldots, x_n
the n+1n+1 distinct data points (nodes)

Each Ln,kL_{n,k} satisfies Ln,k(xk)=1L_{n,k}(x_k) = 1 and Ln,k(xi)=0L_{n,k}(x_i) = 0 for i≠ki \neq k.

The nn-th Lagrange interpolating polynomial through the data (xk,f(xk))(x_k, f(x_k)) is:

Pn(x)=∑k=0nLn,k(x) f(xk)P_n(x) = \sum_{k=0}^{n} L_{n,k}(x)\, f(x_k)

Example

Interpolate through (1,1)(1, 1), (2,4)(2, 4), (3,9)(3, 9) (i.e., f(x)=x2f(x) = x^2).

Solution Reveal Hide

Basis polynomials for n=2n = 2:

L2,0(x)=(x−2)(x−3)(1−2)(1−3)=(x−2)(x−3)2L_{2,0}(x) = \frac{(x-2)(x-3)}{(1-2)(1-3)} = \frac{(x-2)(x-3)}{2}L2,1(x)=(x−1)(x−3)(2−1)(2−3)=−(x−1)(x−3)L_{2,1}(x) = \frac{(x-1)(x-3)}{(2-1)(2-3)} = -(x-1)(x-3)L2,2(x)=(x−1)(x−2)(3−1)(3−2)=(x−1)(x−2)2L_{2,2}(x) = \frac{(x-1)(x-2)}{(3-1)(3-2)} = \frac{(x-1)(x-2)}{2}P2(x)=1⋅(x−2)(x−3)2−4(x−1)(x−3)+9⋅(x−1)(x−2)2P_2(x) = 1 \cdot \frac{(x-2)(x-3)}{2} - 4(x-1)(x-3) + 9 \cdot \frac{(x-1)(x-2)}{2}

At x=4x = 4: L2,0(4)=1L_{2,0}(4) = 1, L2,1(4)=−3L_{2,1}(4) = -3, L2,2(4)=3L_{2,2}(4) = 3, so:

P2(4)=1(1)+4(−3)+9(3)=1−12+27=16=42✓P_2(4) = 1(1) + 4(-3) + 9(3) = 1 - 12 + 27 = 16 = 4^2 \checkmark

Wolfram Mathematica notebook

The summary notebook defines every function used in this module, with documentation and no examples, as a starting point for your own problems.

Written by November 3, 2026 1 min read
Was this helpful?