LAGRANGIAN POLYNOMIAL
Definition
Given a set of k + 1 data points
where no two x_{j} are the same, the interpolation polynomial in the Lagrange form is a linear combination
of Lagrange basis polynomials
Proof
The function we are looking for has to be a polynomial function L(x) of degree less than or equal to k with
The Lagrange polynomial is a solution to the interpolation problem.
As can be seen
 is a polynomial and has degree k.
Thus the function L(x) is a polynomial with degree at most k and
There can be only one solution to the interpolation problem since the difference of two such solutions would be a polynomial with degree at most k and k+1 zeros. This is only possible if the difference is identically zero, so L(x) is the unique polynomial interpolating the given data.
Main idea
Solving an interpolation problem leads to a problem in linear algebra where we have to solve a matrix. Using a standard monomial basis for our interpolation polynomial we get the very complicated Vandermonde matrix. By choosing another basis, the Lagrange basis, we get the much simpler identity matrix = δ_{i,j} which we can solve instantly: the Lagrange basis inverts the Vandermonde matrix.
Implementation in C++
Note : "pos" and "val" arrays are of size "degree".
float lagrangeInterpolatingPolynomial (float pos[], float val[], int degree, float desiredPos) { float retVal = 0; for (int i = 0; i < degree; ++i) { float weight = 1; for (int j = 0; j < degree; ++j) { // The ith term has to be skipped if (j != i) { weight *= (desiredPos  pos[j]) / (pos[i]  pos[j]); } } retVal += weight * val[i]; } return retVal; }
Usage
Example 1
Find an interpolation formula for f(x) = tan(x) given this set of known values:
The basis polynomials are:
Thus the interpolating polynomial then is
Example 2
We wish to interpolate ƒ(x) = x^{2} over the range 1 ≤ x ≤ 3, given these 3 points:
The interpolating polynomial is:
Example 3
We wish to interpolate ƒ(x) = x^{3} over the range 1 ≤ x ≤ 3, given these 3 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 nonvanishing 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 interpolation
Using the quantity
we can rewrite the Lagrange basis polynomials as
or, by defining the barycentric weights^{[1]}
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 w_{j} have been precomputed, requires only operations (evaluating and the weights w_{j} / (x − x_{j})) as opposed to for evaluating the Lagrange basis polynomials individually.
The barycentric interpolation formula can also easily be updated to incorporate a new node x_{k + 1} by dividing each of the w_{j}, by (x_{j} − x_{k + 1}) and constructing the new w_{k + 1} as above.
We can further simplify the first form by first considering the barycentric interpolation of the constant function :
Dividing L(x) by g(x) 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 need not be evaluated for each evaluation of L(x).
COURTESY:en.wikipedia.org/wiki/Lagrange_polynomial
LAGRANGE INTERPOLATING POLYNOMIAL:
The Lagrange interpolating polynomial is the polynomial of degree that passes through the points , , ..., , and is given by
(1)

where
(2)

Written explicitly,
(3)

The formula was first published by Waring (1779), rediscovered by Euler in 1783, and published by Lagrange in 1795 (Jeffreys and Jeffreys 1988).
Lagrange interpolating polynomials are implemented in Mathematica as InterpolatingPolynomial[data, var]. They are used, for example, in the construction of NewtonCotes formulas.
When constructing interpolating polynomials, there is a tradeoff between having a better fit and having a smooth wellbehaved fitting function. The more data points that are used in the interpolation, the higher the degree of the resulting polynomial, and therefore the greater oscillation it will exhibit between the data points. Therefore, a highdegree interpolation may be a poor predictor of the function between points, although the accuracy at the data points will be "perfect."
For points,
(4)


(5)

Note that the function passes through the points , as can be seen for the case ,
(6)


(7)


(8)

Generalizing to arbitrary ,
(9)

The Lagrange interpolating polynomials can also be written using what Szegö (1975) called Lagrange's fundamental interpolating polynomials. Let
(10)


(11)


(12)


(13)

so that is an th degree polynomial with zeros at , ..., . Then define the fundamental polynomials by
(14)

which satisfy
(15)

where is the Kronecker delta. Now let , ..., , then the expansion
(16)

gives the unique Lagrange interpolating polynomial assuming the values at . More generally, let be an arbitrary distribution on the interval , the associated orthogonal polynomials, and , ..., the fundamental polynomials corresponding to the set of zeros of a polynomial . Then
(17)

for , 2, ..., , where are Christoffel numbers.
Lagrange interpolating polynomials give no error estimate. A more conceptually straightforward method for calculating them is Neville's algorithm. COURTESY:mathworld.wolfram.com/LagrangeInterpolatingPolynomial.html
Spend a minute to Register in a few simple steps, for complete access to the Social Learning Platform with Community Learning Features and Learning Resources.
If you are part of the Learning Community already, Login now!