Lagrange polynomial

In numerical analysis, Lagrange polynomials are used for polynomial interpolation. For a given set of points formula_1 with no two formula_2 values equal, the Lagrange polynomial is the polynomial of lowest degree that assumes at each value formula_2 the corresponding value formula_4, so that the functions coincide at each point.
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 and Shamir's secret sharing scheme in cryptography.
Lagrange interpolation is susceptible to Runge's phenomenon of large oscillation. As changing the points formula_2 requires recalculating the entire interpolant, it is often easier to use Newton polynomials instead.
Definition.
Given a set of "k" + 1 data points
where no two formula_2 are the same, the interpolation polynomial in the Lagrange form is a linear combination
of Lagrange basis polynomials
where formula_10. Note how, given the initial assumption that no two formula_2 are the same, then (when formula_12) formula_13, so this expression is always well-defined. The reason pairs formula_14 with formula_15 are not allowed is that no interpolation function formula_16 such that formula_17 would exist; a function can only get one value for each argument formula_18. On the other hand, if also formula_19, then those two points would actually be one single point.
For all formula_20, formula_21 includes the term formula_22 in the numerator, so the whole product will be zero at formula_23:
On the other hand,
In other words, all basis polynomials are zero at formula_26, except formula_21, for which it holds that formula_28, because it lacks the formula_29 term.
It follows that formula_30, so at each point formula_2, formula_32, showing that formula_16 interpolates the function exactly.
Proof.
The function being sought is a polynomial in of the least degree that interpolates the given data set; that is, it assumes the value at the corresponding for all data points :
Observe that:
Expand this product. Since the product omits the term where , if then all terms that appear are formula_37. Also, if then one term in the product "will" be (for ), formula_38, zeroing the entire product. So,
where formula_40 is the Kronecker delta. So:
Thus the function is a polynomial with degree at most and where .
Additionally, the interpolating polynomial is unique, as shown by the unisolvence theorem at the polynomial interpolation article.
It's also true that:
since it must be a polynomial of degree, at most, and passes through all these "k" + 1 data points:
resulting in a horizontal line, since a straight line is the only polynomial of degree less than "k" + 1 that passes through "k" + 1 aligned points.
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 formula_44, we must invert the Vandermonde matrix formula_45 to solve formula_46 for the coefficients formula_47 of formula_48. By choosing a better basis, the Lagrange basis, formula_49, we merely get the identity matrix, formula_40, 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.
Examples.
Example 1.
We wish to interpolate "ƒ"("x") = "x"2 over the range 1 ≤ "x" ≤ 3, given these three points:
The interpolating polynomial is:
Example 2.
We wish to interpolate "ƒ"("x") = "x"3 over the range 1 ≤ "x" ≤ 4, given these four points:
The interpolating polynomial is:
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 "x""k" 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.
Barycentric form.
Using
we can rewrite the Lagrange basis polynomials as
or, by defining the "barycentric weights"
we can simply write
which is commonly referred to as the "first form" of the barycentric interpolation formula.
The advantage of this representation is that the interpolation polynomial may now be evaluated as
which, if the weights formula_60 have been pre-computed, requires only formula_61 operations (evaluating formula_62 and the weights formula_63) as opposed to formula_64 for evaluating the Lagrange basis polynomials formula_21 individually.
The barycentric interpolation formula can also easily be updated to incorporate a new node formula_66 by dividing each of the formula_60, formula_68 by formula_69 and constructing the new formula_70 as above.
We can further simplify the first form by first considering the barycentric interpolation of the constant function formula_71:
Dividing formula_48 by formula_74 does not modify the interpolation, yet yields
which is referred to as the "second form" or "true form" of the barycentric interpolation formula. This second form has the advantage that formula_62 need not be evaluated for each evaluation of formula_48.
Remainder in Lagrange interpolation formula.
When interpolating a given function "f" by a polynomial of degree at the nodes formula_78 we get the remainder formula_79 which can be expressed as
where formula_81 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.
Clearly, formula_84 is zero at nodes. To find formula_85 at a point formula_86, define a new function formula_87 and choose formula_88 (This ensures formula_89 at nodes) where formula_90 is the constant we are required to determine for a given formula_91. Now formula_92 has formula_93 zeroes (at all nodes and formula_91) between formula_95 and formula_96 (including endpoints). Assuming that formula_97 is formula_98-times differentiable, formula_48 and formula_85 are polynomials, and therefore, are infinitely differentiable. By Rolle's theorem, formula_101 has formula_98 zeroes, formula_103 has formula_104 zeroes... formula_105 has 1 zero, say formula_106. Explicitly writing formula_107:
The equation can be rearranged as
Derivatives.
The formula_115th derivatives of the Lagrange polynomial can be written as
For the first derivative, the coefficients are given by
and for the second derivative
Through recursion, one can compute formulas for higher 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.