In
numerical analysis
Numerical analysis is the study of algorithms that use numerical approximation (as opposed to symbolic manipulations) for the problems of mathematical analysis (as distinguished from discrete mathematics). It is the study of numerical methods ...
, the Lagrange interpolating polynomial is the unique
polynomial
In mathematics, a polynomial is an expression consisting of indeterminates (also called variables) and coefficients, that involves only the operations of addition, subtraction, multiplication, and positive-integer powers of variables. An example ...
of lowest
degree that
interpolates a given set of data.
Given a data set of
coordinate pairs with
the
are called ''nodes'' and the
are called ''values''. The Lagrange polynomial
has degree
and assumes each value at the corresponding node,
Although named after
Joseph-Louis Lagrange, who published it in 1795, the method was first discovered in 1779 by
Edward Waring
Edward Waring (15 August 1798) was a British mathematician. He entered Magdalene College, Cambridge as a sizar and became Senior wrangler in 1757. He was elected a Fellow of Magdalene and in 1760 Lucasian Professor of Mathematics, holding the ...
. It is also an easy consequence of a formula published in 1783 by
Leonhard Euler
Leonhard Euler ( , ; 15 April 170718 September 1783) was a Swiss mathematician, physicist, astronomer, geographer, logician and engineer who founded the studies of graph theory and topology and made pioneering and influential discoveries in ma ...
.
Uses of Lagrange polynomials include the
Newton–Cotes method of
numerical integration
In analysis, numerical integration comprises a broad family of algorithms for calculating the numerical value of a definite integral, and by extension, the term is also sometimes used to describe the numerical solution of differential equations ...
and
Shamir's secret sharing scheme in
cryptography
Cryptography, or cryptology (from grc, , translit=kryptós "hidden, secret"; and ''graphein'', "to write", or ''-logia'', "study", respectively), is the practice and study of techniques for secure communication in the presence of adver ...
.
For equispaced nodes, Lagrange interpolation is susceptible to
Runge's phenomenon
In the mathematical field of numerical analysis, Runge's phenomenon () is a problem of oscillation at the edges of an interval that occurs when using polynomial interpolation with polynomials of high degree over a set of equispaced interpolation ...
of large oscillation.
Definition
Given a set of
nodes
, which must all be distinct,
for indices
, the Lagrange basis for polynomials of degree
for those nodes is the set of polynomials
each of degree
which take values
if
and
. Using the
Kronecker delta
In mathematics, the Kronecker delta (named after Leopold Kronecker) is a function of two variables, usually just non-negative integers. The function is 1 if the variables are equal, and 0 otherwise:
\delta_ = \begin
0 &\text i \neq j, \\
1 & ...
this can be written
Each basis polynomial can be explicitly described by the product:
Notice that the numerator
has
roots at the nodes
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 the 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.
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
is the unique polynomial of degree
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.
This second form has advantages in computation cost and accuracy: it avoids evaluation of
; the work to compute each term in the denominator
has already been done in computing
and so computing the sum in the denominator costs only
addition operations; for evaluation points
which are close to one of the nodes
,
catastrophic cancelation
In numerical analysis, catastrophic cancellation is the phenomenon that subtracting good approximations to two nearby numbers may yield a very bad approximation to the difference of the original numbers.
For example, if there are two studs, one L_ ...
would ordinarily be a problem for the value
, 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
at one of the nodes
will result in the
indeterminate ; computer implementations must replace such results by
A perspective from linear algebra
Solving an
interpolation problem leads to a problem in
linear algebra
Linear algebra is the branch of mathematics concerning linear equations such as:
:a_1x_1+\cdots +a_nx_n=b,
linear maps such as:
:(x_1, \ldots, x_n) \mapsto a_1x_1+\cdots +a_nx_n,
and their representations in vector spaces and through matrices ...
amounting to inversion of a matrix. Using a standard
monomial basis for our interpolation polynomial
, we must invert the
Vandermonde matrix
In linear algebra, a Vandermonde matrix, named after Alexandre-Théophile Vandermonde, is a matrix with the terms of a geometric progression in each row: an matrix
:V=\begin
1 & x_1 & x_1^2 & \dots & x_1^\\
1 & x_2 & x_2^2 & \dots & x_2^\\
1 & x_ ...
to solve
for the coefficients
of
. By choosing a better basis, the Lagrange basis,
, we merely get the
identity matrix,
, 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
We wish to interpolate
over the domain
at the three nodes
:
The node polynomial
is
:
The barycentric weights are
:
The Lagrange basis polynomials are
:
The Lagrange interpolating polynomial is:
:
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 In algebra, the Vandermonde polynomial of an ordered set of ''n'' variables X_1,\dots, X_n, named after Alexandre-Théophile Vandermonde, is the polynomial:
:V_n = \prod_ (X_j-X_i).
(Some sources use the opposite order (X_i-X_j), which changes the ...
.
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 polynomial In the mathematical field of numerical analysis, a Newton polynomial, named after its inventor Isaac Newton, is an interpolation polynomial for a given set of data points. The Newton polynomial is sometimes called Newton's divided differences interp ...
s.
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
In the mathematical field of numerical analysis, Runge's phenomenon () is a problem of oscillation at the edges of an interval that occurs when using polynomial interpolation with polynomials of high degree over a set of equispaced interpolation ...
; the problem may be eliminated by choosing interpolation points at
Chebyshev nodes
In numerical analysis, Chebyshev nodes are specific real algebraic numbers, namely the roots of the Chebyshev polynomials of the first kind. They are often used as nodes in polynomial interpolation because the resulting interpolation polynomial ...
.
The Lagrange basis polynomials can be used in
numerical integration
In analysis, numerical integration comprises a broad family of algorithms for calculating the numerical value of a definite integral, and by extension, the term is also sometimes used to describe the numerical solution of differential equations ...
to derive the
Newton–Cotes formulas
In numerical analysis, the Newton–Cotes formulas, also called the Newton–Cotes quadrature rules or simply Newton–Cotes rules, are a group of formulas for numerical integration (also called ''quadrature'') based on evaluating the integrand at ...
.
Remainder in Lagrange interpolation formula
When interpolating a given function ''f'' by a polynomial of degree at the nodes
we get the remainder
which can be expressed as
:
where