In numerical analysis, the Lagrange interpolating polynomial is the unique polynomial of lowest degree that interpolates a given set of data.
(xj,yj)
0\leqj\leqk,
xj
yj
L(x)
L(xj)=yj.
Although named after Joseph-Louis Lagrange, who published it in 1795,[1] the method was first discovered in 1779 by Edward Waring.[2] It is also an easy consequence of a formula published in 1783 by Leonhard Euler.[3]
Uses of Lagrange polynomials include the Newton–Cotes method of numerical integration, Shamir's secret sharing scheme in cryptography, and Reed–Solomon error correction in coding theory.
For equispaced nodes, Lagrange interpolation is susceptible to Runge's phenomenon of large oscillation.
Given a set of nodes
\{x0,x1,\ldots,xk\}
xj ≠ xm
j ≠ m
Notice that the numerator has roots at the nodes while the denominator scales the resulting polynomial so that
The Lagrange interpolating polynomial for those nodes through the corresponding values
\{y0,y1,\ldots,yk\}
Each basis polynomial has degree , so the sum has degree , and it interpolates the data because
The interpolating polynomial is unique. Proof: assume the polynomial of degree interpolates the data. Then the difference is zero at distinct nodes But the only polynomial of degree with more than roots is the constant zero function, so or
Each Lagrange basis polynomial can be rewritten as the product of three parts, a function common to every basis polynomial, a node-specific constant (called the barycentric weight), and a part representing the displacement from to :[4]
By factoring out from the sum, we can write the Lagrange polynomial in the so-called first barycentric form:
L(x)=\ell(x)
k | |
\sum | |
j=0 |
wj | |
x-xj |
yj.
If the weights
wj
lO(k)
lO(k2)
\ellj(x)
The barycentric interpolation formula can also easily be updated to incorporate a new node
xk+1
wj
j=0...k
(xj-xk+1)
wk+1
For any because the constant function is the unique polynomial of degree
\leqk
L(x)=L(x)/g(x)\colon
\begin{aligned} L(x)&=\ell(x)
k | |
\sum | |
j=0 |
wj | |
x-xj |
yj/\ell(x)
k | |
\sum | |
j=0 |
wj | |
x-xj |
\\[10mu] &=
k | |
\sum | |
j=0 |
wj | |
x-xj |
yj/
k | |
\sum | |
j=0 |
wj | |
x-xj |
. \end{aligned}
This is called the second form or true form of the barycentric interpolation formula.
This second form has advantages in computation cost and accuracy: it avoids evaluation of
\ell(x)
wj/(x-xj)
l(wj/(x-xj)r)yj
Using this formula to evaluate
L(x)
xj
inftyyj/infty
L(xj)=yj.
Each Lagrange basis polynomial can also be written in barycentric form:
\ellj(x)=
wj | |
x-xj |
/
k | |
\sum | |
m=0 |
wm | |
x-xm |
.
j | |
(x | |
i) |
L(xi)=yi
mj
L(x)
\deltaij
This construction is analogous to the Chinese remainder theorem. Instead of checking for remainders of integers modulo prime numbers, we are checking for remainders of polynomials when divided by linears.
Furthermore, when the order is large, Fast Fourier transformation can be used to solve for the coefficients of the interpolated polynomial.
We wish to interpolate
f(x)=x2
1\leqx\leq3
\begin{align} x0&=1,&&&y0=f(x0)&=1,\\[3mu] x1&=2,&&&y1=f(x1)&=4,\\[3mu] x2&=3,&&&y2=f(x2)&=9. \end{align}
The node polynomial
\ell
\ell(x)=(x-1)(x-2)(x-3)=x3-6x2+11x-6.
The barycentric weights are
\begin{align} w0&=(1-2)-1(1-3)-1=\tfrac12,\\[3mu] w1&=(2-1)-1(2-3)-1=-1,\\[3mu] w2&=(3-1)-1(3-2)-1=\tfrac12. \end{align}
The Lagrange basis polynomials are
\begin{align} \ell0(x)&=
x-2 | ⋅ | |
1-2 |
x-3 | |
1-3 |
=\tfrac12x2-\tfrac52x+3,\\[5mu] \ell1(x)&=
x-1 | ⋅ | |
2-1 |
x-3 | |
2-3 |
=-x2+4x-3,\\[5mu] \ell2(x)&=
x-1 | ⋅ | |
3-1 |
x-2 | |
3-2 |
=\tfrac12x2-\tfrac32x+1. \end{align}
The Lagrange interpolating polynomial is:
\begin{align} L(x)&=1 ⋅
x-2 | ⋅ | |
1-2 |
x-3 | |
1-3 |
+4 ⋅
x-1 | ⋅ | |
2-1 |
x-3 | |
2-3 |
+9 ⋅
x-1 | ⋅ | |
3-1 |
x-2 | |
3-2 |
\\[6mu] &=x2. \end{align}
In (second) barycentric form,
L(x)=
| ||||||||||||
|
=
| ||||||||||||
|
.
The Lagrange form of the interpolation polynomial shows the linear character of polynomial interpolation and the uniqueness of the interpolation polynomial. Therefore, it is preferred in proofs and theoretical arguments. Uniqueness can also be seen from the invertibility of the Vandermonde matrix, due to the non-vanishing of the Vandermonde determinant.
But, as can be seen from the construction, each time a node xk changes, all Lagrange basis polynomials have to be recalculated. A better form of the interpolation polynomial for practical (or computational) purposes is the barycentric form of the Lagrange interpolation (see below) or Newton polynomials.
Lagrange and other interpolation at equally spaced points, as in the example above, 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.[5]
The Lagrange basis polynomials can be used in numerical integration to derive the Newton–Cotes formulas.
When interpolating a given function f by a polynomial of degree at the nodes
x0,...,xk
R(x)=f(x)-L(x)
R(x)=f[x0,\ldots,xk,x]\ell(x)=\ell(x)
f(k+1)(\xi) | |
(k+1)! |
, x0<\xi<xk,
where
f[x0,\ldots,xk,x]
R(x)=
\ell(x) | |
2\pii |
\intC
f(t) | |
(t-x)(t-x0) … (t-xk) |
dt=
\ell(x) | |
2\pii |
\intC
f(t) | |
(t-x)\ell(t) |
dt.
The remainder can be bound as
|R(x)|\leq
| |||||||||||||
(k+1)! |
max | |
x0\leq\xi\leqxk |
|f(k+1)(\xi)|.
Clearly,
R(x)
R(x)
xp
F(x)=R(x)-\tilde{R}(x)=f(x)-L(x)-\tilde{R}(x)
C
xp
C
F(x)
k+2
xp
x0
xk
f(x)
k+1
L(x)
\tilde{R}(x)
F(x)
k+1
F(1)(x)
k+1
F(2)(x)
k
F(k+1)
\xi,x0<\xi<xk
F(k+1)(\xi)
F(k+1)(\xi)=f(k+1)(\xi)-L(k+1)(\xi)-\tilde{R}(k+1)(\xi)
L(k+1)=0,\tilde{R}(k+1)=C ⋅ (k+1)!
x
\tilde{R}(x)
k+1
0=f(k+1)(\xi)-C ⋅ (k+1)!
The equation can be rearranged as
C= | f(k+1)(\xi) |
(k+1)! |
F(xp)=0
R(xp)=\tilde{R}(xp)=
fk+1(\xi) | |
(k+1)! |
k(x | |
\prod | |
p-x |
i)
The th derivative of a Lagrange interpolating polynomial can be written in terms of the derivatives of the basis polynomials,
L(d)(x):=
k | |
\sum | |
j=0 |
yj
(d) | |
\ell | |
j |
(x).
Recall (see above) that each Lagrange basis polynomial is
The first derivative can be found using the product rule:
\begin{align} \ellj'(x)&=\sum\begin{smallmatrixi=0\ i\not=j\end{smallmatrix}}kl[
1 | |
xj-xi |
\prod\begin{smallmatrixm=0\ m\not=(i,j)\end{smallmatrix}}k
x-xm | |
xj-xm |
r] \\[5mu] &=\ellj(x)\sum\begin{smallmatrixi=0\\i\not=j\end{smallmatrix}}k
1 | |
x-xi |
. \end{align}
The second derivative is
\begin{align} \ellj''(x) &=\sum\begin{smallmatrixi=0\ i\nej\end{smallmatrix}}k
1 | |
xj-xi |
l[\sum\begin{smallmatrixm=0\ m\ne(i,j)\end{smallmatrix}}kl(
1 | |
xj-xm |
\prod\begin{smallmatrixn=0\ n\ne(i,j,m)\end{smallmatrix}}k
x-xn | |
xj-xn |
r)r] \\[10mu] &=\ellj(x) \sum0
2 | |
(x-xi)(x-xm) |
\\[10mu] &=\ellj(x)l[l(\sum\begin{smallmatrixi=0\\i\not=j\end{smallmatrix}}k
1 | |
x-xi |
2-\sum | |
r) | |
\begin{smallmatrix |
i=0\\i\not=j\end{smallmatrix}}k
1 | ||||||
|
r]. \end{align}
The third derivative is
\begin{align} \ellj'''(x) &=\ellj(x) \sum0
3! | |
(x-xi)(x-xm)(x-xn) |
\end{align}
and likewise for higher derivatives.
Note that all of these formulas for derivatives are invalid at or near a node. A method of evaluating all orders of derivatives of a Lagrange polynomial efficiently at all points of the domain, including the nodes, is converting the Lagrange polynomial to power basis form and then evaluating the derivatives.
The Lagrange polynomial can also be computed in finite fields. This has applications in cryptography, such as in Shamir's Secret Sharing scheme.