Wikipedia / Lagrange polynomial
Wikipedia / Lagrange polynomial
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 , the are called nodes and the are called values. The Lagrange polynomial which interpolates the data assumes each value at the corresponding node, . If there are data pairs, the Lagrange polynomial has degree .
Although named after Joseph-Louis Lagrange, who published it in 1795, the method was first discovered in 1779 by Edward Waring. It is also an easy consequence of a formula published in 1783 by Leonhard Euler.
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 nodes which must all be distinct, for indices , the Lagrange basis for polynomials of degree each of degree which take values if and . Using the Kronecker delta this can be written . Each basis polynomial can be explicitly described by the product:
Notice that the numerator has while the denominator scales the resulting polynomial so that .
The Lagrange interpolating polynomial for those nodes through the corresponding values is the linear combination:
Each basis polynomial has degree , so the sum has degree , and it interpolates the data because .
The interpolating polynomial is unique. Proof: assume some 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 .
Barycentric form
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 :
By factoring out from the sum, we can write the Lagrange polynomial in the so-called first barycentric form:
If the weights have been pre-computed, this requires only operations compared to for evaluating each Lagrange basis polynomial individually. (See Big O notation.)
The barycentric interpolation formula can also easily be updated to incorporate a new node by dividing each of the , by and constructing the new as above.
For any because the constant function interpolating the data We can thus further simplify the barycentric formula by dividing {
This is called the second form or true form of the barycentric interpolation formula.
, catastrophic cancelation, however this quantity appears in both numerator and denominator and the two cancel leaving good relative accuracy in the final result.
will result in the indeterminate
Each Lagrange basis polynomial can also be written in barycentric form:
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, we must invert the Vandermonde matrix, we merely get the identity matrix, \delta_{ij}, 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
at the three nodes
The Lagrange basis polynomials are
In (second) barycentric form,
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 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.
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 which can be expressed as
is the notation for divided differences. Alternatively, the remainder can be expressed as a contour integral in complex domain as
The remainder can be bound as
Derivation
at a point -times differentiable. By Rolle's theorem has 1 zero, say where :
)
The equation can be rearranged as
Derivatives
The th derivative of a Lagrange interpolating polynomial can be written in terms of the derivatives of the basis polynomials,
Recall (see above) that each Lagrange basis polynomial is
The first derivative can be found using the product rule:
The second derivative is
The third derivative is
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
Newton form of the interpolation polynomial
References
External links
ALGLIB has an implementations in C++ / C# / VBA / Pascal.
GSL has a polynomial interpolation code in C
SO has a MATLAB example that demonstrates the algorithm and recreates the first image in this article
Lagrange interpolation polynomial on www.math-linux.com