Lagrange polynomial explained

In numerical analysis, the Lagrange interpolating polynomial is the unique polynomial of lowest degree that interpolates a given set of data.

(xj,yj)

with

0\leqj\leqk,

the

xj

are called nodes and the

yj

are called values. The Lagrange polynomial

L(x)

has degree \leq k and assumes each value at the corresponding node,

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.

Definition

Given a set of k + 1 nodes

\{x0,x1,\ldots,xk\}

, which must all be distinct,

xjxm

for indices

jm

, the Lagrange basis for polynomials of degree \leq k for those nodes is the set of polynomials \ each of degree k which take values \ell_j(x_m) = 0 if m \neq j and \ell_j(x_j) = 1. Using the Kronecker delta this can be written \ell_j(x_m) = \delta_. Each basis polynomial can be explicitly described by the product:

\begin\ell_j(x) &= \frac \cdots \frac \frac \cdots \frac \\[8mu]&= \prod_ \frac \vphantom\Bigg|.\end

Notice that the numerator \prod_(x - x_m) has k roots at the nodes \_ while the denominator \prod_(x_j - x_m) scales the resulting polynomial so that \ell_j(x_j) = 1.

The Lagrange interpolating polynomial for those nodes through the corresponding values

\{y0,y1,\ldots,yk\}

is the linear combination:

L(x) = \sum_^ y_j \ell_j(x).

Each basis polynomial has degree k, so the sum L(x) has degree \leq k, and it interpolates the data because L(x_m) = \sum_^ y_j \ell_j(x_m) = \sum_^ y_j \delta_ = y_m.

The interpolating polynomial is unique. Proof: assume the polynomial M(x) of degree \leq k interpolates the data. Then the difference M(x) - L(x) is zero at k + 1 distinct nodes \. But the only polynomial of degree \leq k with more than k roots is the constant zero function, so M(x) - L(x) = 0, or M(x) = L(x).

Barycentric form

Each Lagrange basis polynomial \ell_j(x) can be rewritten as the product of three parts, a function \ell(x) = \prod_m (x - x_m) common to every basis polynomial, a node-specific constant w_j = \prod_(x_j - x_m)^ (called the barycentric weight), and a part representing the displacement from x_j to x:[4]

\ell_j(x) = \ell(x) \dfrac

By factoring \ell(x) 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

have been pre-computed, this requires only

lO(k)

operations compared to

lO(k2)

for evaluating each Lagrange basis polynomial

\ellj(x)

individually.

The barycentric interpolation formula can also easily be updated to incorporate a new node

xk+1

by dividing each of the

wj

,

j=0...k

by

(xj-xk+1)

and constructing the new

wk+1

as above.

For any x, \sum_^k \ell_j(x) = 1 because the constant function g(x) = 1 is the unique polynomial of degree

\leqk

interpolating the data \. We can thus further simplify the barycentric formula by dividing

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)

; the work to compute each term in the denominator

wj/(x-xj)

has already been done in computing

l(wj/(x-xj)r)yj

and so computing the sum in the denominator costs only k addition operations; for evaluation points x which are close to one of the nodes x_j, catastrophic cancelation would ordinarily be a problem for the value (x-x_j), however this quantity appears in both numerator and denominator and the two cancel leaving good relative accuracy in the final result.

Using this formula to evaluate

L(x)

at one of the nodes

xj

will result in the indeterminate

inftyyj/infty

; computer implementations must replace such results by

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

.

A perspective from linear algebra

j
(x
i)
to solve

L(xi)=yi

for the coefficients

mj

of

L(x)

. By choosing a better basis, the Lagrange basis, L(x) = \sum_^k l_j(x) y_j, we merely get the identity matrix,

\deltaij

, which is its own inverse: the Lagrange basis automatically inverts the analog of the Vandermonde matrix.

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.

Example

We wish to interpolate

f(x)=x2

over the domain

1\leqx\leq3

at the three nodes

\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

is

\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)=

\displaystyle
2
\sum
j=0
wj
x-xj
yj
\displaystyle
2
\sum
j=0
wj
x-xj

=

\displaystyle
\tfrac12
x-1
+
-4
x-2
+
\tfrac92
x-3
\displaystyle
\tfrac12
x-1
+
-1
x-2
+
\tfrac12
x-3

.

Notes

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.

Remainder in Lagrange interpolation formula

When interpolating a given function f by a polynomial of degree at the nodes

x0,...,xk

we get the remainder

R(x)=f(x)-L(x)

which can be expressed as

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]

is the notation for divided differences. Alternatively, the remainder can be expressed as a contour integral in complex domain as

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

(x
k+1
0)
k-x
(k+1)!
max
x0\leq\xi\leqxk

|f(k+1)(\xi)|.

Derivation[6]

Clearly,

R(x)

is zero at nodes. To find

R(x)

at a point

xp

, define a new function

F(x)=R(x)-\tilde{R}(x)=f(x)-L(x)-\tilde{R}(x)

and choose \tilde(x)=C\cdot\prod_^k(x-x_i) where

C

is the constant we are required to determine for a given

xp

. We choose

C

so that

F(x)

has

k+2

zeroes (at all nodes and

xp

) between

x0

and

xk

(including endpoints). Assuming that

f(x)

is

k+1

-times differentiable, since

L(x)

and

\tilde{R}(x)

are polynomials, and therefore, are infinitely differentiable,

F(x)

will be

k+1

-times differentiable. By Rolle's theorem,

F(1)(x)

has

k+1

zeroes,

F(2)(x)

has

k

zeroes...

F(k+1)

has 1 zero, say

\xi,x0<\xi<xk

. Explicitly writing

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)!

(Because the highest power of

x

in

\tilde{R}(x)

is

k+1

)

0=f(k+1)(\xi)-C(k+1)!

The equation can be rearranged as

C=f(k+1)(\xi)
(k+1)!
Since

F(xp)=0

we have

R(xp)=\tilde{R}(xp)=

fk+1(\xi)
(k+1)!
k(x
\prod
p-x

i)

Derivatives

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

\begin\ell_j(x) &= \prod_^k \frac.\end

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
2
(x-x
i)

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.

Finite fields

The Lagrange polynomial can also be computed in finite fields. This has applications in cryptography, such as in Shamir's Secret Sharing scheme.

See also

External links

Notes and References

  1. Book: Lagrange, Joseph-Louis . Joseph-Louis Lagrange . Leçons Elémentaires sur les Mathématiques . fr . 1795 . Leçon Cinquième. Sur l'usage des courbes dans la solution des problèmes . Paris. Republished in Book: Lagrange, Joseph-Louis . Serret . Joseph-Alfred . Joseph-Alfred Serret . 0 . Oeuvres de Lagrange . 1877 . 7 . Gauthier-Villars . 271–287 . Translated as Book: Lagrange, Joseph-Louis . 0 . McCormack . Thomas J. . Lectures on Elementary Mathematics . 2nd . Open Court . 1901 . Lecture V. On the Employment of Curves in the Solution of Problems . https://archive.org/details/lecturesonelemen00lagriala/page/127 . 127–149.
  2. Problems concerning interpolations . Edward . Waring . Edward Waring . . 1779 . 69 . 59–67 . 10.1098/rstl.1779.0008 .
  3. Meijering . Erik . A chronology of interpolation: from ancient astronomy to modern signal and image processing . 10.1109/5.993400 . 2002 . Proceedings of the IEEE . 90 . 3 . 319–342 .
  4. Jean-Paul . Berrut . Lloyd N. . Trefethen . Lloyd N. Trefethen . 2004 . Barycentric Lagrange Interpolation . SIAM Review . 46 . 3 . 501 - 517 . 10.1137/S0036144502417715 . 2004SIAMR..46..501B . free .
  5. Book: Scientific Computing with MATLAB. 2. Texts in computational science and engineering . Alfio Quarteroni . Alfio. Quarteroni. Fausto. Saleri. Springer. 2003. 978-3-540-44363-6. 66. .
  6. Web site: Interpolation.