Upload
muhammad-ahtisham-asif
View
12
Download
0
Embed Size (px)
DESCRIPTION
Newton Polynomials
Citation preview
105 3.2 Polynomial Interpolation
x0.00 0.50 1.00 1.50 2.00 2.50 3.00
-0.50
0.00
0.50
1.00
l1
l2
l3
Figure 3.2. Example of quadratic cardinal functions.
To prove that the interpolating polynomial passes through the data points, wesubstitute x = xj into Eq. (3.1a) and then utilize Eq. (3.2). The result is
Pn−1(xj ) =n∑
i=1
yi�i(xj ) =n∑
i=1
yiδi j = y j
It can be shown that the error in polynomial interpolation is
f (x) − Pn−1(x) = (x − x1)(x − x2) . . . (x − xn)n!
f (n)(ξ ) (3.3)
where ξ lies somewhere in the interval (x1, xn); its value is otherwise unknown. It isinstructive to note that the farther a data point is from x, the more it contributes tothe error at x.
Newton’s Method
Evaluation of polynomialAlthough Lagrange’s method is conceptually simple, it does not lend itself to an effi-cient algorithm. A better computational procedure is obtained with Newton’s method,where the interpolating polynomial is written in the form
Pn−1(x) = a1 + (x − x1)a2 + (x − x1)(x − x2)a3 + · · · + (x − x1)(x − x2) · · · (x − xn−1)an
This polynomial lends itself to an efficient evaluation procedure. Consider, forexample, four data points (n = 4). Here the interpolating polynomial is
P3(x) = a1 + (x − x1)a2 + (x − x1)(x − x2)a3 + (x − x1)(x − x2)(x − x3)a4
= a1 + (x − x1) {a2 + (x − x2) [a3 + (x − x3)a4]}
106 Interpolation and Curve Fitting
which can be evaluated backward with the following recurrence relations:
P0(x) = a4
P1(x) = a3 + (x − x3)P0(x)
P2(x) = a2 + (x − x2)P1(x)
P3(x) = a1 + (x − x1)P2(x)
For arbitrary n we have
P0(x) = an Pk(x) = an−k + (x − xn−k)Pk−1(x), k = 1, 2, . . . , n − 1 (3.4)
� newtonPoly
Denoting the x-coordinate array of the data points by xData, and the number of datapoints by n, we have the following algorithm for computing Pn−1(x):
function p = 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);
for k = 1:n-1;
p = a(n-k) + (x - xData(n-k))*p;
end
Computation of coefficientsThe coefficients of Pn−1(x) are determined by forcing the polynomial to pass througheach data point: yi = Pn−1(xi), i = 1, 2, . . . , n. This yields the simultaneous equations
y1 = a1
y2 = a1 + (x2 − x1)a2
y3 = a1 + (x3 − x1)a2 + (x3 − x1)(x3 − x2)a3 (a)
...
yn = a1 + (xn − x1)a1 + · · · + (xn − x1)(xn − x2) · · · (xn − xn−1)an
107 3.2 Polynomial Interpolation
Introducing the divided differences
∇yi = yi − y1
xi − x1, i = 2, 3, . . . , n
∇2 yi = ∇yi − ∇y2
xi − x2, i = 3, 4, . . . , n
∇3 yi = ∇2 yi − ∇2 y3
xi − x3, i = 4, 5, . . . n (3.5)
...
∇nyn = ∇n−1 yn − ∇n−1 yn−1
xn − xn−1
the solution of Eqs. (a) is
a1 = y1 a2 = ∇y2 a3 = ∇2 y3 · · · an = ∇nyn (3.6)
If the coefficients are computed by hand, it is convenient to work with the format inTable 3.1 (shown for n = 5).
x1 y1
x2 y2 ∇y2
x3 y3 ∇y3 ∇2 y3
x4 y4 ∇y4 ∇2 y4 ∇3 y4
x5 y5 ∇y5 ∇2 y5 ∇3 y5 ∇4 y5
Table 3.1
The diagonal terms (y1, ∇y2, ∇2 y3, ∇3 y4 and ∇4 y5) in the table are the coefficientsof the polynomial. If the data points are listed in a different order, the entries in the tablewill change, but the resultant polynomial will be the same—recall that a polynomialof degree n − 1 interpolating n distinct data points is unique.
� newtonCoeff
Machine computations are best carried out within a one-dimensional array a employ-ing the following algorithm:
function a = newtonCoeff(xData,yData)
% Returns coefficients of Newton’s polynomial.