Lagrange Interpolating Polynomial

Summary

Lagrange form writes the unique interpolant as a weighted sum of cardinal basis polynomials Li that satisfy Li(xk)=δik .

Prerequisites

Problem Type

Given distinct nodes x0,…,xn and values yi , construct P with P(xi)=yi .

Method Definition

P(x)=∑i=0nyiLi(x),Li(x)=∏j=0j≠inx−xjxi−xj.

Each Li has degree n , Li(xi)=1 , and Li(xj)=0 for j≠i . The product is over j≠i only.[1]

Assumptions / Requirements

Algorithm

  1. For each i , form Li(x) as the product over j≠i .
  2. Sum yiLi(x) .
  3. Optionally expand into monomial form for inspection.

Error / Accuracy

If yi=f(xi) with f∈Cn+1 , then for some ξ between the nodes and x ,

f(x)−P(x)=f(n+1)(ξ)(n+1)!∏i=0n(x−xi).

If |f(n+1)|≤M on the interval of interest,

|f(x)−P(x)|≤M(n+1)!|∏i=0n(x−xi)|.

Worked Example

Nodes (0,2) , (1,3) , (2,5) .

L0(x)=(x−1)(x−2)(0−1)(0−2)=(x−1)(x−2)2=12(x2−3x+2),L1(x)=(x−0)(x−2)(1−0)(1−2)=x(x−2)−1=−x2+2x,L2(x)=(x−0)(x−1)(2−0)(2−1)=x(x−1)2=12(x2−x). P(x)=2L0(x)+3L1(x)+5L2(x)=2⋅12(x2−3x+2)+3(−x2+2x)+5⋅12(x2−x)=(x2−3x+2)+(−3x2+6x)+(52x2−52x)=(1−3+52)x2+(−3+6−52)x+2=12x2+12x+2.

Checks: P(0)=2 , P(1)=1/2+1/2+2=3 , P(2)=2+1+2=5 .

Common Failure Modes

Connections

References


  1. Burden & Faires, Numerical Analysis, Lagrange interpolation; NIST DLMF Ch. 3, https://dlmf.nist.gov/3 ↩︎