Lagrange Formula

Lagrange’s formula is a classical formula for constructing an interpolation polynomial. It allows us to obtain a unique polynomial of degree nn that passes through a given set of (n+1)(n+1) nodes (xk,yk),k{0,...,n}(x_k, y_k),{}_{k \in \left\{0, ..., n\right\}}:

P(x)=i=0nyili(x)P(x) = \sum_{i=0}^n{y_i l_i(x)}

where:

  • xix_i are the coordinates of the nodes,
  • yiy_i are the function values at these points,
  • li(x)=jixxjxixjl_i(x) = \prod_{j \ne i}{\frac{x-x_j}{x_i-x_j}} is the Lagrange basis polynomial for each point, which equals 1 when x=xix = x_i and 0 when x=xjx = x_j for jij \neq i.