Graphics Programs Reference
In-Depth Information
which can beevaluatedbackward with the following recurrence relations:
P 0 ( x )
=
a 4
P 1 ( x )
=
a 3 +
( x
x 3 ) P 0 ( x )
P 2 ( x )
=
a 2 +
( x
x 2 ) P 1 ( x )
=
a 1 +
P 3 ( x )
( x
x 1 ) P 2 ( x )
For arbitrary n wehave
P 0 ( x )
=
a n
P k ( x )
=
a n k +
( x
x n k ) P k 1 ( x ), k
=
1
,
2
,...,
n
1
(3.4)
newtonPoly
Denoting the x -coordinate array of the datapoints by xData , and the number of data
points by n , wehave the following algorithm for computing P n 1 ( x ):
functionp=newtonPoly(a,xData,x)
% Returns value of Newton's polynomial at x.
%USAGE:p=newtonPoly(a,xData,x)
% a = coefficient array of the polynomial;
% must be computed first by newtonCoeff.
% xData = x-coordinates of data points.
n = length(xData);
p = a(n);
fork=1:n-1;
p = a(n-k) + (x - xData(n-k))*p;
end
Computation of coefficients
The coefficients of P n 1 ( x ) are determinedbyforcing the polynomialtopass through
each datapoint: y i
=
P n 1 ( x i ), i
=
1
,
2
,...,
n . This yields the simultaneousequations
y 1 =
a 1
y 2 =
a 1 +
( x 2
x 1 ) a 2
y 3 =
a 1 +
( x 3
x 1 ) a 2 +
( x 3
x 1 )( x 3
x 2 ) a 3
(a)
.
y n
=
a 1
+
( x n
x 1 ) a 1
+···+
( x n
x 1 )( x n
x 2 )
···
( x n
x n 1 ) a n
Search WWH ::




Custom Search