# Lagrange polynomial This image shows, for four points ((−9, 5), (−4, 2), (−1, −2), (7, 9)), the (cubic) interpolation polynomial L(x) (dashed, black), which is the sum of the scaled basis polynomials y00(x), y11(x), y22(x) and y33(x). The interpolation polynomial passes through all four control points, and each scaled basis polynomial passes through its respective control point and is 0 where x corresponds to the other three control points.

In numerical analysis, Lagrange polynomials are used for polynomial interpolation. For a given set of points $(x_,y_)$ with no two $x_$ values equal, the Lagrange polynomial is the polynomial of lowest degree that assumes at each value $x_$ the corresponding value $y_$ (i.e. the functions coincide at each point). The interpolating polynomial of the least degree is unique, however, and since it can be arrived at through multiple methods, referring to "the Lagrange polynomial" is perhaps not as correct as referring to "the Lagrange form" of that unique polynomial.

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 $x_$ requires recalculating the entire interpolant, it is often easier to use Newton polynomials instead.

## Definition Here we plot the Lagrange basis functions of 1st, 2nd, and 3rd order on a bi-unit domain. Linear combinations of Lagrange basis functions are used to construct Lagrange interpolating polynomials. Lagrange basis functions are commonly used in finite element analysis as the bases for the element shape-functions. Furthermore, it is common to use a bi-unit domain as the natural space for the finite-element's definition.

Given a set of k + 1 data points

$(x_,y_),\ldots ,(x_,y_),\ldots ,(x_,y_)$ where no two $x_$ are the same, the interpolation polynomial in the Lagrange form is a linear combination

$L(x):=\sum _^y_\ell _(x)$ of Lagrange basis polynomials

$\ell _(x):=\prod _{\begin0\leq m\leq k\\m\neq j\end}{\frac }-x_}}={\frac {(x-x_)}{(x_-x_)}}\cdots {\frac {(x-x_)}{(x_-x_)}}{\frac {(x-x_)}{(x_-x_)}}\cdots {\frac {(x-x_)}{(x_-x_)}},$ where $0\leq j\leq k$ . Note how, given the initial assumption that no two $x_$ are the same, $x_-x_\neq 0$ , so this expression is always well-defined. The reason pairs $x_=x_$ with $y_\neq y_$ are not allowed is that no interpolation function $L$ such that $y_=L(x_)$ would exist; a function can only get one value for each argument $x_$ . On the other hand, if also $y_=y_$ , then those two points would actually be one single point.

For all $i\neq j$ , $\ell _(x)$ includes the term $(x-x_)$ in the numerator, so the whole product will be zero at $x=x_$ :

$\ell _(x_)=\prod _{\frac -x_}-x_}}={\frac {(x_-x_)}{(x_-x_)}}\cdots {\frac {(x_-x_)}{(x_-x_)}}\cdots {\frac {(x_-x_)}{(x_-x_)}}=0.$ On the other hand,

$\ell _(x_):=\prod _{\frac -x_}-x_}}=1$ In other words, all basis polynomials are zero at $x=x_$ , except $\ell _(x)$ , for which it holds that $\ell _(x_)=1$ , because it lacks the $(x-x_)$ term.

It follows that $y_\ell _(x_)=y_$ , so at each point $x_$ , $L(x_)=y_+0+0+\dots +0=y_$ , showing that $L$ interpolates the function exactly.

## Proof

The function L(x) being sought is a polynomial in $x$ of the least degree that interpolates the given data set; that is, assumes value $y_$ at the corresponding $x_$ for all data points $j$ :

$L(x_)=y_\qquad j=0,\ldots ,k$ Observe that:

1. In $\ell _(x)$ there are k factors in the product and each factor contains one x, so L(x) (which is a sum of these k-degree polynomials) must be a polynomial of degree at most k.
2. $\ell _(x_)=\prod _^{\frac -x_}-x_}}$ We consider what happens when this product is expanded. Because the product skips $m=j$ , if $i=j$ then all terms are ${\frac -x_}-x_}}=1$ (except where $x_=x_$ , but that case is impossible, as pointed out in the definition section—in that term, $m=j$ , and since $m\neq j$ , $i\neq j$ , contrary to $i=j$ ). Also if $i\neq j$ then since $m\neq j$ does not preclude it, one term in the product will be for $m=i$ , i.e. ${\frac -x_}-x_}}=0$ , zeroing the entire product. So

1. $\ell _(x_)=\delta _={\begin1,&{\text}j=i\\0,&{\text}j\neq i\end}$ where $\delta _$ is the Kronecker delta. So:

$L(x_)=\sum _^y_\ell _(x_)=\sum _^y_\delta _=y_.$ Thus the function L(x) is a polynomial with degree at most k and where $L(x_)=y_$ .

Additionally, the interpolating polynomial is unique, as shown by the unisolvence theorem at the polynomial interpolation article.

## 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 $L(x)=\sum _^x^m_$ , we must invert the Vandermonde matrix $(x_)^$ to solve $L(x_)=y_$ for the coefficients $m_$ of $L(x)$ . By choosing a better basis, the Lagrange basis, $L(x)=\sum _^l_(x)y_$ , we merely get the identity matrix, $\delta _$ , 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) = x2 over the range 1 ≤ x ≤ 3, given these three points:

${\beginx_&=1&&&f(x_)&=1\\x_&=2&&&f(x_)&=4\\x_&=3&&&f(x_)&=9.\end}$ The interpolating polynomial is:

${\beginL(x)&=\cdot \cdot +\cdot \cdot +\cdot \cdot \\[10pt]&=x^.\end}$ ### Example 2

We wish to interpolate ƒ(x) = x3 over the range 1 ≤ x ≤ 3, given these three points:

 $x_=1$ $f(x_)=1$ $x_=2$ $f(x_)=8$ $x_=3$ $f(x_)=27$ The interpolating polynomial is:

${\beginL(x)&=\cdot \cdot +\cdot \cdot +\cdot \cdot \\[8pt]&=6x^-11x+6.\end}$ 