Next:
Neville's Method
Up:
Interpolating Polynomials
Previous:
Fitting a Polynomial to
Contents
Lagrangian Polynomials
Straightforward approach
-the Lagrangian polynomial.
The simplest way to exhibit the
existence of a polynomial
for interpolation with
unevenly
spaced data.
Linear interpolation
Quadratic interpolation
Cubic interpolation
Lagrange polynomials have
two important advantages
over interpolating polynomials.
the construction of the interpolating polynomials does not require the solution of a system of equations (such as Gaussian elimination).
the evaluation of the Lagrange polynomials is much less susceptible to roundoff.
Linear interpolation
put the values
then
substituting back and rearranging
redefining as
where Ls are the first-degree
Lagrange interpolating polynomials
.
Quadratic interpolation
where
are not the same with the previous
!
Cubic interpolation
Suppose we have a table of data with four pairs of
- and
-values, with
indexed by variable
:
Through these four data pairs we can pass a
cubic
.
The Lagrangian form is
This equation is made up of four terms, each of which is a
cubic
in
; hence the sum is a cubic.
The pattern of each term is to form the numerator as a product of linear factors of the form
, omitting one
in each term.
The omitted value being used to form the denominator by replacing
in each of the numerator factors.
In each term, we multiply by the
.
It will have
terms when the degree is
.
Fit a cubic through the first four points of the preceding Table
7.1
(first four points) and use it to find the interpolated value for
.
Table 7.3:
Fitting a polynomial to data.
x
f(x)
3.2
22.0
2.7
17.8
1.0
14.2
4.8
38.3
5.6
51.7
Carrying out the arithmetic,
.
In general
Example py-file:
Interpolation of gasoline prices. Lagrange Interpolation.
myLagInt_gasoline.py
Figure 7.3:
Lagrange Polynomial Interpolation - Gasoline Case.
Error of Interpolation
; When we fit a polynomial
to some data points, it will
pass exactly through those points
,
but between those points
will not be precisely the same as the function
that generated the points (unless the function is that polynomial).
How much is
different from
?
How large is the error of
?
It is most important that you
never fit a polynomial
of a degree
higher
than 4 or 5
to a set of points.
If you need to fit to a set of more than six points, be sure to
break up the
set into subsets
and
fit separate polynomials
to these.
You cannot fit a function that is discontinuous or one whose derivative is discontinuous with a polynomial.
Next:
Neville's Method
Up:
Interpolating Polynomials
Previous:
Fitting a Polynomial to
Contents