Next:
Lagrangian Polynomials
Up:
Interpolating Polynomials
Previous:
Interpolation versus Curve Fitting
Contents
Fitting a Polynomial to Data
Interpolation involves
constructing and then evaluating
an
interpolating
function
.
interpolant
,
, determined by requiring that
it pass through the known data
.
In its most general form, interpolation involves
determining the coefficient
s
in the linear combination of
n basis functions
,
, that constitute the interpolant
such that
for
. The
basis function
may be
polynomial
or
trigonometric
or some other
suitable set of functions
.
Polynomials
are often used
for interpolation
because they are easy to evaluate and easy to manipulate analytically.
Table 7.1:
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
Suppose that we have a data set.
First, we need to
select the points
that determine our polynomial.
The
maximum degree of the polynomial
is always
one less
than the number of points.
Suppose we choose the first
four
points. If the
cubic
is
,
We can write four equations involving the unknown coefficients
, and
;
Solving these equations gives
and our polynomial is
At
, the
estimated value
is 20.212.
if we want a new polynomial that is also made to fit at the point
?
or if we want to see what difference it would make to use a
quadratic
instead of a
cubic
?
Example py-file:
Polynomial Interpolation. Gaussian elimination & back substitution. No pivoting.
myGEshow_interpolation.py
Figure 7.1:
Polynomial Interpolation.
Table 7.2:
Interpolation of gasoline prices.
year
price
1986
133.5
1988
132.2
1990
138.7
1992
141.5
1994
137.6
1996
144.2
Another example;
Use the polynomial order 5, why?
Make a guess about the prices of gasoline at year of 1991 (2011).
Example py-file:
Interpolation of gasoline prices. Gaussian elimination & back substitution. No pivoting.
myGEshow_gasoline.py
Now, try with the shifted dates (Xdata=Xdata-np.mean(Xdata)).
Make the necessary corrections for the array A.
What differs in the plot and why?
Figure 7.2:
Polynomial Interpolation - Gasoline Case.
Next:
Lagrangian Polynomials
Up:
Interpolating Polynomials
Previous:
Interpolation versus Curve Fitting
Contents