Lagrange interpolation

The Lagrange basis functions, the cardinal property that defines them, the polynomial as a direct combination of the data, its error and a worked example with the census data.

Cardinal basis functions

Lagrange builds the same unique polynomial in direct, symmetric form. The functions Li(x)L_i(x) equal 1 at their node and 0 at the others:

Li(xj)={1,i=j0,ijLi(x)=j=0jinxxjxixjL_{i}(x_j)=\begin{cases}1,& i=j\\[2pt] 0,& i\ne j\end{cases}\qquad\Longrightarrow\qquad L_{i}(x)=\prod_{\substack{j=0\\ j\ne i}}^{n}\frac{x-x_j}{x_i-x_j}

The numerator has all factors (xxj)(x-x_j) except (xxi)(x-x_i); the denominator has all (xixj)(x_i-x_j) except (xixi)(x_i-x_i). With these functions the polynomial is a combination of the known values:

pn(x)=i=0nLi(x)f(xi)p_n(x)=\sum_{i=0}^{n} L_{i}(x)\,f(x_i)
Why the polynomial passes through every node
  1. To check this at a specific node xkx_k, evaluate the polynomial there:

    pn(xk)=i=0nLi(xk)f(xi)p_n(x_k)=\sum_{i=0}^{n} L_i(x_k)\,f(x_i)
  2. The cardinal property cancels all basis functions except the one attached to the node xkx_k:

    Li(xk)={0,ik1,i=kL_i(x_k)=\begin{cases}0,& i\ne k\\[2pt]1,& i=k\end{cases}
  3. Only the term i=ki=k remains, and the interpolant reproduces the datum at that node:

    pn(xk)=Lk(xk)f(xk)=f(xk)p_n(x_k)=L_k(x_k)\,f(x_k)=f(x_k)

Newton versus Lagrange

  • Lagrange is direct and symmetric: ideal for few nodes and for deriving rules (quadrature, differentiation).
  • Newton is incremental: adding a node costs one term, not a full rebuild.
  • Both give the same polynomial and share the same error bound.

Worked example

ExamplePopulation census (degree 4)

With the same census data (1971–2011), build the degree-4 Lagrange polynomial and estimate the 2005 population.

  1. Each LiL_i has the four factors of the other nodes. For example, for x0=1971x_0=1971:

    L0(x)=(x1981)(x1991)(x2001)(x2011)(19711981)(19711991)(19712001)(19712011)=(x1981)(x1991)(x2001)(x2011)240000\begin{aligned}L_0(x)&=\frac{(x-1981)(x-1991)(x-2001)(x-2011)}{(1971-1981)(1971-1991)(1971-2001)(1971-2011)}\\&=\frac{(x-1981)(x-1991)(x-2001)(x-2011)}{240000}\end{aligned}
  2. The polynomial sums each LiL_i times its value f(xi)f(x_i):

    p4(x)=i=04Li(x)f(xi)p_4(x)=\sum_{i=0}^{4} L_i(x)\,f(x_i)

The result matches (up to rounding) the Newton one, as uniqueness requires:

p4(2005)42.316 millonesp_4(2005)\approx 42.316\ \text{millones}

Derivation of the Lagrange basis

DerivationDerivation: Lagrange basis functionsView as its own page →
  1. We want Li(x)L_i(x) to vanish at every node except xix_i. To vanish at xjx_j (jij\ne i) it suffices to include the factor (xxj)(x-x_j) for each one:

    numerador=j=0jin(xxj)\text{numerador}=\prod_{\substack{j=0\\ j\ne i}}^{n}(x-x_j)
  2. That product has some value (not 1) at xix_i. To normalize it to 1 we divide by its value at xix_i, i.e. the same product evaluated there:

    Li(x)=j=0jinxxjxixjL_i(x)=\prod_{\substack{j=0\\ j\ne i}}^{n}\frac{x-x_j}{x_i-x_j}
  3. Thus Li(xi)=1L_i(x_i)=1 and Li(xj)=0L_i(x_j)=0. The combination iLi(x)f(xi)\sum_i L_i(x)\,f(x_i) reproduces each datum, hence interpolates.