Lagrange polynomial

Lagrange polynomial

(All the below are from Wiki.)

Wiki: Lagrange polynomials are used for polynomial interpolation of a given set of points \((x_j,y_j)\).

Given a set of k+1 data points:

\[(x_0,y_0),\cdots,(x_i,y_i),\cdots,(x_k,y_k) \]

The interpolation polynomial of the above data points:

\[L(x) = \sum_{i=0}^k \ell_i(x)y_i \]

is expressed as a linear combination of Lagrange basis polynomials \(\ell_i(x)\) and \(y_i\),and \(\ell_i(x)\) is:

\[\ell_i(x)=\prod_{j\neq i}^{k}\frac{x-x_j}{x_i-x_j}=\frac{x-x_0}{x_i-x_0}\cdots\frac{x-x_{i-1}}{x_i-x_{i-1}}\frac{x-x_{i+1}}{x_i-x_{i+1}}\cdots\frac{x-x_k}{x_i-x_k} \]

And we have the following relation:

\[\ell_i(x_j)=\delta_{ij} = \begin{cases}1, \quad j=i\\0, \quad j\neq i \end{cases} \]

For example, when \(j=i\), we have:

\[\ell_i(x_i)=\frac{x_i-x_0}{x_i-x_0}\cdots\frac{x_i-x_j}{x_i-x_j}\cdots\frac{x_i-x_k}{x_i-x_k}=1 \]

when \(j\neq i\), we have:

\[\ell_i(x_j)=\frac{x_j-x_0}{x_i-x_0}\cdots(\frac{x_j-x_j}{x_i-x_j})\cdots\frac{x_j-x_k}{x_i-x_k}=0 \]

Therefore, we have the following:

\[L(x_j)=\sum_{i=0}^k\ell_i(x_j)y_i=\sum_{i=0}^k\delta_{ij}y_j=y_j \]

  • Example:

​ Say we want to interpolate \(f(x)=x^2\) with given points \((1,1),(2,4),(3,9)\)

​ The interpolating polynomial is therefore:

\[L(x)=\sum_{i=0}^3\ell_i(x)y_i\\ =\ell_0(x)y_0+\ell_1(x)y_1+\ell_2(x)y_2\\ =\frac{x-2}{1-2}\cdot\frac{x-3}{1-3}\cdot1+\frac{x-1}{2-1}\frac{x-3}{2-3}\cdot4+\frac{x-1}{3-1}\frac{x-2}{3-2}\cdot9 = x^2 \]

  • Drawback:

    When an additional point is incorporated, we should recalculate all the Lagrange basis polynomial. An improved form is the Newton polynomials.

Wiki: Lagrange and other interpolation at equally spaced points yield a polynomial oscillating above and below the true function. This behaviour tends to grow with the number of points, leading to a divergence known as Runge's phenomenon; the problem may be eliminated by choosing interpolation points at Chebyshev nodes.

posted @ 2022-03-26 17:20  miccoui  阅读(79)  评论(0编辑  收藏  举报