Skip to content

Lagrange Interpolation

The Vandermonde approach requires inverting a matrix — expensive and numerically fragile for large systems. Lagrange interpolation sidesteps this entirely. Instead of solving for coefficients, it constructs a set of clever basis polynomials Lk(x)L_k(x) that each equal 1 at exactly one node and 0 at all others. The interpolating polynomial is then a straightforward weighted sum of these basis polynomials.


The Lagrange Formula

Given n+1n+1 nodes (x0,f(x0)),  …,  (xn,f(xn))(x_0, f(x_0)),\;\ldots,\;(x_n, f(x_n)), the Lagrange interpolating polynomial is:

Pn(x)=∑k=0nf(xk) Lk(x)P_n(x) = \sum_{k=0}^{n} f(x_k)\, L_k(x)

where each Lagrange basis polynomial Lk(x)L_k(x) is defined as:

Lk(x)=∏j=0j≠knx−xjxk−xjL_k(x) = \prod_{\substack{j=0 \\ j \neq k}}^{n} \frac{x - x_j}{x_k - x_j}

The Kronecker Delta Property

The basis polynomials are engineered to satisfy:

Lk(xj)=δkj={1if k=j0if k≠jL_k(x_j) = \delta_{kj} = \begin{cases} 1 & \text{if } k = j \\ 0 & \text{if } k \neq j \end{cases}

This is what guarantees Pn(xi)=f(xi)P_n(x_i) = f(x_i) for every node — each LkL_k activates (equals 1) at its own node xkx_k and is silent (equals 0) at every other node.

Example: Verifying L2(x)L_2(x) for 3 nodes

To see this in action, let’s look at a system with three nodes: x0,x1,x_0, x_1, and x2x_2. By definition, the basis polynomial L2(x)L_2(x) is constructed by including x0x_0 and x1x_1 in the product, but omitting x2x_2:

L2(x)=(x−x0)(x−x1)(x2−x0)(x2−x1)L_2(x) = \frac{(x - x_0)(x - x_1)}{(x_2 - x_0)(x_2 - x_1)}

Let’s calculate the multiplication when we evaluate this polynomial at each specific node:

  • At x=x0x = x_0 (where k≠jk \neq j): L2(x0)=(x0−x0)(x0−x1)(x2−x0)(x2−x1)=0⋅(x0−x1)(x2−x0)(x2−x1)=0L_2(x_0) = \frac{(x_0 - x_0)(x_0 - x_1)}{(x_2 - x_0)(x_2 - x_1)} = \frac{0 \cdot (x_0 - x_1)}{(x_2 - x_0)(x_2 - x_1)} = 0

    Why it is 0: Substituting x0x_0 creates an (x0−x0)(x_0 - x_0) term. This turns the numerator into zero, making the whole expression 0.

  • At x=x1x = x_1 (where k≠jk \neq j): L2(x1)=(x1−x0)(x1−x1)(x2−x0)(x2−x1)=(x1−x0)⋅0(x2−x0)(x2−x1)=0L_2(x_1) = \frac{(x_1 - x_0)(x_1 - x_1)}{(x_2 - x_0)(x_2 - x_1)} = \frac{(x_1 - x_0) \cdot 0}{(x_2 - x_0)(x_2 - x_1)} = 0

    Why it is 0: Substituting x1x_1 creates an (x1−x1)(x_1 - x_1) term, turning the numerator and the final result to zero.

  • At x=x2x = x_2 (where k=jk = j): L2(x2)=(x2−x0)(x2−x1)(x2−x0)(x2−x1)=1L_2(x_2) = \frac{(x_2 - x_0)(x_2 - x_1)}{(x_2 - x_0)(x_2 - x_1)} = 1

    Why it is 1: Substituting x2x_2 makes the numerator exactly identical to the denominator. Any non-zero value divided by itself equals 1.

The Basis Sums to 1

A companion property is that the basis polynomials add up to 1 at every xx:

∑k=0nLk(x)=1\sum_{k=0}^{n} L_k(x) = 1

Deriving lk(x)l_k(x) from First Principles

We can use the Kronecker delta property to mathematically build a specific basis polynomial from scratch. Let’s find l2(x)l_2(x) for a system with 4 nodes where n=3n=3.

Here n=3n=3, meaning our nodes are x0,x1,x2,x3x_0, x_1, x_2, x_3. We are looking for lk(x)l_k(x) where k=2k=2.

Based on the rule lk(xj)=1l_k(x_j) = 1 when k=jk=j and 00 when k≠jk \neq j, we know the following must be true:

  • l2(x0)=0l_2(x_0) = 0
  • l2(x1)=0l_2(x_1) = 0
  • l2(x3)=0l_2(x_3) = 0
  • l2(x2)=1l_2(x_2) = 1

Because l2(x)l_2(x) evaluates to zero at x0,x1x_0, x_1, and x3x_3, these three points are the roots of the polynomial.

Knowing the roots, we can write the polynomial with an unknown constant CC: l2(x)=C(x−x0)(x−x1)(x−x3)l_2(x) = C(x-x_0)(x-x_1)(x-x_3)

To find CC, substitute x=x2x = x_2 into the equation: l2(x2)=C(x2−x0)(x2−x1)(x2−x3)l_2(x_2) = C(x_2-x_0)(x_2-x_1)(x_2-x_3)

Since we know l2(x2)=1l_2(x_2) = 1, we can substitute 11 on the left side: 1=C(x2−x0)(x2−x1)(x2−x3)1 = C(x_2-x_0)(x_2-x_1)(x_2-x_3)

Isolating CC gives us: C=1(x2−x0)(x2−x1)(x2−x3)C = \frac{1}{(x_2-x_0)(x_2-x_1)(x_2-x_3)}

Substitute CC back into the general equation to get the completed basis polynomial: l2(x)=(x−x0)(x−x1)(x−x3)(x2−x0)(x2−x1)(x2−x3)l_2(x) = \frac{(x-x_0)(x-x_1)(x-x_3)}{(x_2-x_0)(x_2-x_1)(x_2-x_3)}


Worked Example: 3 Nodes

Problem: Find the interpolating polynomial through the following three data points.

xkx_kf(xk)f(x_k)
12
23
41

Step 1: Compute the Basis Polynomials

L0(x)L_0(x): The product omits j=0j = 0, so it includes terms for j=1j = 1 and j=2j = 2:

L0(x)=(x−x1)(x−x2)(x0−x1)(x0−x2)=(x−2)(x−4)(1−2)(1−4)=(x−2)(x−4)(−1)(−3)=(x−2)(x−4)3L_0(x) = \frac{(x - x_1)(x - x_2)}{(x_0 - x_1)(x_0 - x_2)} = \frac{(x-2)(x-4)}{(1-2)(1-4)} = \frac{(x-2)(x-4)}{(-1)(-3)} = \frac{(x-2)(x-4)}{3}

L1(x)L_1(x): Omits j=1j = 1, includes j=0j = 0 and j=2j = 2:

L1(x)=(x−x0)(x−x2)(x1−x0)(x1−x2)=(x−1)(x−4)(2−1)(2−4)=(x−1)(x−4)(1)(−2)=(x−1)(x−4)−2L_1(x) = \frac{(x - x_0)(x - x_2)}{(x_1 - x_0)(x_1 - x_2)} = \frac{(x-1)(x-4)}{(2-1)(2-4)} = \frac{(x-1)(x-4)}{(1)(-2)} = \frac{(x-1)(x-4)}{-2}

L2(x)L_2(x): Omits j=2j = 2, includes j=0j = 0 and j=1j = 1:

L2(x)=(x−x0)(x−x1)(x2−x0)(x2−x1)=(x−1)(x−2)(4−1)(4−2)=(x−1)(x−2)(3)(2)=(x−1)(x−2)6L_2(x) = \frac{(x - x_0)(x - x_1)}{(x_2 - x_0)(x_2 - x_1)} = \frac{(x-1)(x-2)}{(4-1)(4-2)} = \frac{(x-1)(x-2)}{(3)(2)} = \frac{(x-1)(x-2)}{6}

Step 2: Construct the Polynomial

P(x)=y0 L0(x)+y1 L1(x)+y2 L2(x)=2 L0(x)+3 L1(x)+1⋅L2(x)P(x) = y_0\,L_0(x) + y_1\,L_1(x) + y_2\,L_2(x) = 2\,L_0(x) + 3\,L_1(x) + 1\cdot L_2(x)

P(x)=2⋅(x−2)(x−4)3  +  3⋅(x−1)(x−4)−2  +  (x−1)(x−2)6P(x) = 2\cdot\frac{(x-2)(x-4)}{3} \;+\; 3\cdot\frac{(x-1)(x-4)}{-2} \;+\; \frac{(x-1)(x-2)}{6}

After expanding and collecting terms:

P(x)=−23x2+3x−13\boxed{P(x) = -\frac{2}{3}x^2 + 3x - \frac{1}{3}}

Step 3: Verification

NodeComputed P(x)P(x)Expected
x=1x = 1−23+3−13=2-\tfrac{2}{3} + 3 - \tfrac{1}{3} = 2✓\checkmark
x=2x = 2−83+6−13=3-\tfrac{8}{3} + 6 - \tfrac{1}{3} = 3✓\checkmark
x=4x = 4−323+12−13=1-\tfrac{32}{3} + 12 - \tfrac{1}{3} = 1✓\checkmark

The Recomputation Problem

Lagrange interpolation has one significant drawback: adding a new node forces a complete rebuild of every basis polynomial.

To see why, consider L0(x)L_0(x) with the original three nodes:

L0(x)=(x−x1)(x−x2)(x0−x1)(x0−x2)L_0(x) = \frac{(x-x_1)(x-x_2)}{(x_0-x_1)(x_0-x_2)}

Now suppose we add a fourth node x3x_3. The Kronecker delta property requires L0(x3)=0L_0(x_3) = 0, which means (x−x3)(x - x_3) must appear in the numerator. Similarly, (x0−x3)(x_0 - x_3) must appear in the denominator. The basis polynomial becomes:

L0 new(x)=(x−x1)(x−x2)(x−x3)(x0−x1)(x0−x2)(x0−x3)L_0^{\,\text{new}}(x) = \frac{(x-x_1)(x-x_2)(x-x_3)}{(x_0-x_1)(x_0-x_2)(x_0-x_3)}

This is a different function from the original L0(x)L_0(x) — every basis polynomial picks up a new factor in both numerator and denominator. L1L_1, L2L_2, and any others must all be rebuilt as well. None of the work done for the 3-node case carries forward.