Jump to content

Lagrange polynomial

From Wikipedia, the free encyclopedia
(Redirected from Lagrange form)

Template:Short description Template:Distinguish

File:Lagrange polynomial.svg
This image shows, for four data points (Template:Ifsubst style="color:#5e81B5">Template:Math, Template:Ifsubst style="color:#e19c24">Template:Math, Template:Ifsubst style="color:#8FB131">Template:Math, Template:Ifsubst style="color:#EC6235">Template:Math), the (cubic) interpolation polynomial Template:Ifsubst style="color:black">Template:Math (dashed, black), which is the sum of the scaled basis polynomials Template:Ifsubst style="color:#5e81B5">Template:Math, Template:Ifsubst style="color:#e19c24">Template:Math, Template:Ifsubst style="color:#8FB131">Template:Math and Template:Ifsubst style="color:#EC6235">Template:Math. The interpolation polynomial passes through all four control points, and each scaled basis polynomial passes through its respective control point and is Template:Math where Template:Mvar corresponds to the other three control points.

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

Given a data set of coordinate pairs Template:Tmath, the Template:Tmath are called nodes and the Template:Tmath are called values. The Lagrange polynomial Template:Tmath which interpolates the data assumes each value at the corresponding node, Template:Tmath. If there are Template:Tmath data pairs, the Lagrange polynomial has degree Template:Tmath.

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.

Lagrange polynomials are also related to matrix eigenspace projection via Frobenius covariants.

Definition

Given a set of Template:Tmath nodes Template:Nowrap which must all be distinct, Template:Tmath for indices Template:Tmath, the Lagrange basis for polynomials of degree Template:Tmath for those nodes is the set of polynomials <math>\textstyle \{\ell_0(x), \ell_1(x), \ldots, \ell_k(x)\}</math> each of degree Template:Tmath which take values Template:Tmath if Template:Tmath and Template:Tmath. Using the Kronecker delta this can be written Template:Tmath. Each basis polynomial can be explicitly described by the product:

<math display=block>\begin{aligned} \ell_j(x) &= \frac{(x-x_0)}{(x_j-x_0)} \cdots \frac{(x-x_{j-1})}{(x_j-x_{j - 1})} \frac{(x-x_{j+1})}{(x_j-x_{j+1})} \cdots \frac{(x-x_k)}{(x_j-x_k)} \\[8mu] &= \prod_{\begin{smallmatrix}0\le m\le k\\ m\neq j\end{smallmatrix}} \frac{x-x_m}{x_j-x_m} \vphantom\Bigg|. \end{aligned}</math>

Notice that the numerator Template:Tmath has Template:Tmath roots at the nodes <math>\textstyle \{x_m\}_{m \neq j}</math> while the denominator Template:Tmath scales the resulting polynomial so that Template:Tmath.

The Lagrange interpolating polynomial for those nodes through the corresponding values <math>\{y_0, y_1, \ldots, y_k\}</math> is the linear combination:

<math display=block>L(x) = \sum_{j=0}^{k} y_j \ell_j(x).</math>

Each basis polynomial has degree Template:Tmath, so the sum Template:Tmath has degree Template:Tmath, and it interpolates the data because Template:Tmath.

The interpolating polynomial is unique. Proof: assume some polynomial Template:Tmath of degree Template:Tmath interpolates the data. Then the difference Template:Tmath is zero at Template:Tmath distinct nodes Template:Nowrap But the only polynomial of degree Template:Tmath with more than Template:Tmath roots is the constant zero function, so Template:Tmath, or Template:Tmath.

The unique interpolating polynomial can alternatively be constructed using Newton polynomials as an alternative basis, or generalized to Hermite interpolating polynomials when there are confluent nodes.

Barycentric form

Each Lagrange basis polynomial Template:Tmath can be rewritten as the product of three parts, a function Template:Tmath common to every basis polynomial, a node-specific constant Template:Tmath (called the barycentric weight), and a part representing the displacement from Template:Tmath to Template:Tmath:[4]

<math display=block>\ell_j(x) = \ell(x) \dfrac{w_j}{x - x_j}</math>

By factoring Template:Tmath out from the sum, we can write the Lagrange polynomial in the so-called first barycentric form:

<math display="block">L(x) = \ell(x) \sum_{j=0}^k \frac{w_j}{x-x_j}y_j.</math>

If the weights Template:Tmath have been pre-computed, this requires only Template:Tmath operations compared to Template:Tmath for evaluating each Lagrange basis polynomial Template:Tmath individually. (See Big O notation.)

The barycentric interpolation formula can also easily be updated to incorporate a new node Template:Tmath by dividing each of the Template:Tmath, Template:Tmath by Template:Tmath and constructing the new Template:Tmath as above.

For any Template:Tmath, <math display=inline>\sum_{j=0}^k \ell_j(x) = 1</math> because the constant function <math display="inline">g(x) = 1</math> is the unique polynomial of degree <math>\leq k</math> interpolating the data Template:Nowrap We can thus further simplify the barycentric formula by dividing Template:Nowrap

<math display="block">\begin{aligned} L(x) &= \ell(x) \sum_{j=0}^k \frac{w_j}{x-x_j}y_j \Bigg/ \ell(x) \sum_{j=0}^k \frac{w_j}{x-x_j} \\[10mu] &= \sum_{j=0}^k \frac{w_j}{x-x_j}y_j \Bigg/ \sum_{j=0}^k \frac{w_j}{x-x_j}. \end{aligned}</math>

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 <math>\ell(x)</math>; the work to compute each term in the denominator <math>w_j/(x-x_j)</math> has already been done in computing <math>\bigl(w_j/(x-x_j)\bigr)y_j</math> and so computing the sum in the denominator costs only <math display=inline>k</math> addition operations; for evaluation points <math display=inline>x</math> which are close to one of the nodes <math display=inline>x_j</math>, catastrophic cancelation would ordinarily be a problem for the value <math display=inline>(x-x_j)</math>, 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 <math>L(x)</math> at one of the nodes <math>x_j</math> will result in the indeterminate <math>\infty y_j/\infty</math>; computer implementations must replace such results by <math>L(x_j) = y_j.</math>

Each Lagrange basis polynomial can also be written in barycentric form:

<math display="block"> \ell_j(x) = \frac{w_j}{x-x_j} \Bigg/ \sum_{m=0}^k \frac{w_m}{x-x_m}. </math>

A perspective from linear algebra

Solving an interpolation problem leads to a problem in linear algebra amounting to inversion of a matrix. Using a standard monomial basis for our interpolation polynomial <math display="inline">L(x) = \sum_{j=0}^k x^j m_j</math>, we must invert the Vandermonde matrix <math>(x_i)^j</math> to solve <math>L(x_i) = y_i</math> for the coefficients <math>m_j</math> of <math>L(x)</math>. By choosing a better basis, the Lagrange basis, <math display="inline">L(x) = \sum_{j=0}^k \ell_j(x) y_j</math>, we merely get the identity matrix, <math>\delta_{ij}</math>, which is its own inverse: the Lagrange basis automatically inverts the analog of the Vandermonde matrix.

More explicitly, let Template:Tmath be the inverse Vandermonde matrix such that: <math display="block">L = \begin{pmatrix} L_{00} & \cdots & L_{0n} \\ \vdots & \ddots & \vdots \\ L_{n0} & \cdots & L_{nn} \end{pmatrix}.</math> The Lagrange basis polynomial Template:Tmath can be expressed directly using the columns of Template:Tmath: <math display="block">\ell_j(x) = L_{0j} + L_{1j} x + \cdots + L_{nj} x^n.</math>

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.

In numerical practice, directly computing Template:Tmath by inverting the Vandermonde matrix is generally avoided because Vandermonde matrices are notoriously ill-conditioned. As the number of nodes or their degree increases, their condition number grows exponentially, making direct matrix inversion numerically unstable and highly sensitive to floating-point errors.

Example

We wish to interpolate <math>f(x) = x^2</math> over the domain <math>1 \leq x \leq 3</math> at the three nodes Template:Nobr

<math display="block">\begin{align} x_0 & = 1, & & & y_0 = f(x_0) & = 1, \\[3mu] x_1 & = 2, & & & y_1 = f(x_1) & = 4, \\[3mu] x_2 & = 3, & & & y_2 = f(x_2) & =9. \end{align}</math>

The node polynomial <math>\ell</math> is <math display="block">\ell(x) = (x-1)(x-2)(x-3) = x^3 - 6x^2 + 11x - 6.</math>

The barycentric weights are <math display="block">\begin{align} w_0 &= (1-2)^{-1}(1-3)^{-1} = \tfrac12, \\[3mu] w_1 &= (2-1)^{-1}(2-3)^{-1} = -1, \\[3mu] w_2 &= (3-1)^{-1}(3-2)^{-1} = \tfrac12. \end{align}</math>

The Lagrange basis polynomials are

<math display="block">\begin{align} \ell_0(x) &= \frac{x - 2}{1 - 2}\cdot\frac{x - 3}{1 - 3} = \tfrac12x^2 - \tfrac52x + 3, \\[5mu] \ell_1(x) &= \frac{x - 1}{2 - 1}\cdot\frac{x - 3}{2 - 3} = -x^2 + 4x - 3, \\[5mu] \ell_2(x) &= \frac{x - 1}{3 - 1}\cdot\frac{x - 2}{3 - 2} = \tfrac12x^2 - \tfrac32x + 1. \end{align}</math>

The Lagrange interpolating polynomial is: <math display="block"> \begin{align} L(x) &= y_0 \cdot \ell_0(x) + y_1 \cdot \ell_1(x) + y_2 \cdot \ell_2(x) = x^2. \end{align} </math>

In (second) barycentric form,

<math display="block"> L(x) = \frac

 {\displaystyle \sum_{j=0}^2 \frac{w_j}{x-x_j}y_j}
 {\displaystyle \sum_{j=0}^2 \frac{w_j}{x-x_j}}
= \frac
 {\displaystyle \frac{\tfrac12}{x - 1} + \frac{-4}{x - 2} + \frac{\tfrac92}{x - 3}}
 {\displaystyle \frac{\tfrac12}{x - 1} + \frac{-1}{x - 2} + \frac{\tfrac12}{x - 3}}.

</math>

Notes

File:Polynomial interpolation with equidistant and Chebyshev nodes.svg
Polynomial interpolation suffers from significant oscillations near the endpoints (Runge's phenomenon) when using equidistant nodes. The oscillation is much smaller when using Chebyshev nodes.

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 Template:Tmath 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 Template:Tmath by a polynomial of degree Template:Tmath at the nodes <math>x_0,\dots, x_k</math> we get the remainder <math>R(x) = f(x) - L(x)</math> which can be expressed as[6]

<math display="block"> \begin{align} R(x) &= f[x_0,\ldots,x_k,x] \ell(x) \\[1ex] &= \ell(x) \frac{f^{(k+1)}(\xi)}{(k+1)!}, & x_0 < \xi < x_k, \end{align}</math>

where <math>f[x_0,\ldots,x_k,x]</math> is the notation for divided differences. Alternatively, the remainder can be expressed as a contour integral in complex domain as

<math display="block">\begin{align} R(x) &= \frac{\ell(x)}{2\pi i} \int_C \frac{f(t)}{(t-x)(t-x_0) \cdots (t-x_k)} dt \\[1ex] &= \frac{\ell(x)}{2\pi i} \int_C \frac{f(t)}{(t-x)\ell(t)} dt. \end{align}</math>

The remainder can be bound as

<math display="block">|R(x)| \leq \frac{(x_k-x_0)^{k+1}}{(k+1)!}\max_{x_0 \leq \xi \leq x_k} |f^{(k+1)}(\xi)|. </math>

Derivation

Clearly, <math>R(x) </math> is zero at nodes. To find <math>R(x)</math> at a point Template:Nowrap define a new function <math>F(x) = R(x)-\tilde{R}(x) = f(x)-L(x)-\tilde{R}(x)</math> and choose <math display="inline">\tilde{R}(x) = C\cdot\prod_{i=0}^k(x-x_i)</math> where <math>C</math> is the constant we are required to determine for a given <math>x_p</math>. We choose <math>C</math> so that <math>F(x)</math> has <math>k+2</math> zeroes (at all nodes and <math>x_p</math>) between <math>x_0</math> and <math>x_k</math> (including endpoints). Assuming that <math>f(x)</math> is <math>k+1</math>-times differentiable, since <math>L(x)</math> and <math>\tilde{R}(x)</math> are polynomials, and therefore, are infinitely differentiable, <math>F(x)</math> will be <math>k+1</math>-times differentiable. By Rolle's theorem, <math>F^{(1)}(x)</math> has <math>k+1</math> zeroes, <math>F^{(2)}(x)</math> has <math>k</math> zeroes... <math>F^{(k+1)}</math> has 1 zero, say Template:Nowrap where Template:Nowrap Explicitly writing <math>F^{(k+1)}(\xi)</math>:

<math display="block">F^{(k+1)}(\xi)=f^{(k+1)}(\xi)-L^{(k+1)}(\xi)-\tilde{R}^{(k+1)}(\xi)</math> <math display="block">L^{(k+1)}=0,\tilde{R}^{(k+1)}=C\cdot(k+1)!</math> (Because the highest power of <math>x</math> in <math>\tilde{R}(x)</math> is <math>k+1</math>)

<math display="block">0=f^{(k+1)}(\xi)-C\cdot(k+1)!</math>

The equation can be rearranged as[7]

<math display="block">C=\frac{f^{(k+1)}(\xi)}{(k+1)!}</math> Since <math>F(x_p) = 0</math> we have <math>R(x_p)=\tilde{R}(x_p) = \frac{f^{k+1}(\xi)}{(k+1)!} \prod_{i=0}^k(x_p-x_i)</math>

Derivatives

The Template:Tmathth derivative of a Lagrange interpolating polynomial can be written in terms of the derivatives of the basis polynomials,

<math display="block">L^{(d)}(x) := \sum_{j=0}^{k} y_j \ell_j^{(d)}(x).</math>

Recall (see Template:Slink above) that each Lagrange basis polynomial is

<math display=block>\begin{aligned} \ell_j(x) &= \prod_{\begin{smallmatrix}m = 0\\ m\neq j\end{smallmatrix}}^k \frac{x-x_m}{x_j-x_m}. \end{aligned}</math>

The first derivative can be found using the product rule:

<math display="block">\begin{align} \ell_j'(x) &= \sum_{\begin{smallmatrix}i=0 \\ i\not=j\end{smallmatrix}}^k \Biggl[ \frac{1}{x_j-x_i}\prod_{\begin{smallmatrix}m=0 \\ m\not = (i , j)\end{smallmatrix}}^k \frac{x-x_m}{x_j-x_m} \Biggr] \\[5mu] &= \ell_j(x)\sum_{\begin{smallmatrix}i=0 \\i\not=j\end{smallmatrix}}^k \frac{1}{x-x_i}. \end{align}</math>

The second derivative is

<math display="block">\begin{align} \ell_j(x) &= \sum_{\begin{smallmatrix}i=0 \\ i\ne j\end{smallmatrix}}^{k} \frac{1}{x_j-x_i} \Biggl[ \sum_{\begin{smallmatrix}m=0 \\ m\ne(i,j)\end{smallmatrix}}^{k} \Biggl( \frac{1}{x_j-x_m} \prod_{\begin{smallmatrix}n=0 \\ n\ne(i,j,m)\end{smallmatrix}}^{k} \frac{x-x_n}{x_j-x_n} \Biggr) \Biggr] \\[10mu] &= \ell_j(x) \sum_{0 \leq i < m \leq k} \frac{2}{(x-x_i)(x - x_m)} \\[10mu] &= \ell_j(x)\Biggl[\Biggl(\sum_{\begin{smallmatrix}i=0 \\i\not=j\end{smallmatrix}}^k \frac{1}{x-x_i}\Biggr)^2 - \sum_{\begin{smallmatrix}i=0 \\i\not=j\end{smallmatrix}}^k \frac{1}{(x-x_i)^2}\Biggr]. \end{align}</math>

The third derivative is

<math display="block">\begin{align} \ell_j(x) &= \ell_j(x) \sum_{0 \leq i < m < n \leq k} \frac{3!}{(x-x_i)(x - x_m)(x - x_n)} \end{align}</math>

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.

Multivariate case

A Lagrange basis can also be constructed in the multivariate case[8]. Let

<math>f(\mathbf{x}) = \sum_{i=0}^{U-1} \alpha_i {\mathbf x}^{\mathbf{k}_i} </math>

be a degree-<math>d</math> polynomial on <math>n</math> variables, where <math>U = \binom{n+d}{n}</math> is the number of terms and

<math>{\mathbf x}^{\mathbf{k}_i} = \prod_{j=0}^{n-1} x_j^{k_{ij}}.</math>

Let then <math>M</math> be the <math>U \times U </math> matrix with elements

<math>M_{ab} = \mathbf{t}_a^{\mathbf{k}_b}</math>

for some set of points <math>\{\mathbf{t}_i\}_{i=0}^{U-1}</math>. This set of points uniquely determines the polynomial <math>f</math> iff <math>\Delta:=\det(M) \neq 0</math>. In this case we can construct the Lagrange basis as follows:

<math>\ell_i(\mathbf{x}) = \frac{\Delta_i(\mathbf{x})}{\Delta},</math>

where <math>\Delta_i(\mathbf{x})</math> is the determinant of the matrix <math>M^{(i)}(\mathbf{x})</math> with elements

<math>M^{(i)}(\mathbf{x})_{ab} = \delta_{ai}\mathbf{x}_a^{\mathbf{k}_b} + (1-\delta_{ai})\mathbf{t}_a^{\mathbf{k}_b}.</math>

Then it holds that

<math>f(\mathbf{x}) = \sum_{i=0}^{U-1} f(\mathbf{t}_i) \ell_i( {\mathbf x}) </math>

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

Template:Div col

Template:Div col end

References

Template:Reflist

Template:Sister project

|_exclude=urlname, _debug, id |url = https://mathworld.wolfram.com/{{#if:LagrangeInterpolatingPolynomial%7CLagrangeInterpolatingPolynomial.html}} |title = Lagrange Interpolating Polynomial |author = Weisstein, Eric W. |website = MathWorld |access-date = |ref = Template:SfnRef }}

Template:Joseph-Louis Lagrange Template:Authority control