Numerical Methods II - Curve-Fitting II
Numerical Methods II - Curve-Fitting II
və Sənaye Universiteti
Numerical
Methods I
Curve-Fitting:
Lagrange Interpolation
The Lagrange interpolating polynomial is
simply a reformulation of the Newton
polynomial that avoids the computation of
divided differences.
yields
.
We can use the algorithm from to study a trend
analysis problem associated with our now-
familiar falling parachutist.
.
Assume that we have instrumentation to
measure the velocity of the parachutist.
Thus for this case the are the knowns and the
are the unknowns.
Because there are the same number of equations
as unknowns Eq. could be solved by an
elimination method (e.g. Gaussian elimination
method).
where is the or .
On this basis the finite divided differences can
be expressed in concise form.
where
the unknown
because the process
extends the curve
beyond the known
region.
As such the true curve could easily diverge from
the prediction.
200
population
150
100
1920 1930 1940 1950 1960 1970 1980 1990 2000
time
. As illustrated in the last , the result indicates
that the polynomial seems to fit the data nicely
from to .
0.8
As seen in , the
0.6
0.4
polynomial does a
y
0.2
poor job of 0
function. -0.4
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
x
.
Continuing with the analysis, the tenth-order
polynomial can be generated and plotted with:
>> x = linspace(-1,1,11);
>> y = 1./(1 + 25*x.^2);
>> xx = linspace(-1,1);
>> p = polyfit(x,y,10);
>> y10 = polyval(p,xx);
>> yr = 1./(1 + 25*xx.^2);
.
>> plot(x,y,'o', xx,y10,
xx,yr,'--');
Comparison of grid 2
on; xlabel('x');
Runge’s function
ylabel('y'); 1.5
a tenth-order
y
0.5
polynomial fit to
0
points sampled
from the function.
-0.5
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
x
As can be seen in the Figure, the fit has gotten
even worse, particularly at the endpoints!
text
text
. text
text
text
text