Vous êtes sur la page 1sur 3

105

3.2 Polynomial Interpolation

1.00

l2
0.50

l1
0.00

l3
-0.50
0.00

0.50

1.00

1.50

2.00

2.50

3.00

x
Figure 3.2. Example of quadratic cardinal functions.

To prove that the interpolating polynomial passes through the data points, we
substitute x = x j into Eq. (3.1a) and then utilize Eq. (3.2). The result is
Pn1 (x j ) =

n

i=1

yi i (x j ) =

n


yi i j = y j

i=1

It can be shown that the error in polynomial interpolation is


f (x) Pn1 (x) =

(x x 1 )(x x 2 ) . . . (x xn) (n)


f ( )
n!

(3.3)

where lies somewhere in the interval (x 1 , xn); its value is otherwise unknown. It is
instructive to note that the farther a data point is from x, the more it contributes to
the error at x.

Newtons Method
Evaluation of polynomial
Although Lagranges method is conceptually simple, it does not lend itself to an efcient algorithm. A better computational procedure is obtained with Newtons method,
where the interpolating polynomial is written in the form
Pn1 (x) = a 1 + (x x1 )a 2 + (x x1 )(x x2 )a 3 + + (x x1 )(x x2 ) (x xn1 )an
This polynomial lends itself to an efcient evaluation procedure. Consider, for
example, four data points (n = 4). Here the interpolating polynomial is
P3 (x) = a 1 + (x x 1 )a 2 + (x x 1 )(x x 2 )a 3 + (x x 1 )(x x 2 )(x x 3 )a 4
= a 1 + (x x 1 ) {a 2 + (x x 2 ) [a 3 + (x x 3 )a 4 ]}

106

Interpolation and Curve Fitting

which can be evaluated backward with the following recurrence relations:


P0 (x) = a 4
P1 (x) = a 3 + (x x 3 )P0 (x)
P2 (x) = a 2 + (x x 2 )P1 (x)
P3 (x) = a 1 + (x x 1 )P2 (x)
For arbitrary n we have
P0 (x) = an

Pk(x) = ank + (x xnk)Pk1 (x),

k = 1, 2, . . . , n 1

(3.4)

 newtonPoly
Denoting the x-coordinate array of the data points by xData, and the number of data
points by n, we have the following algorithm for computing Pn1 (x):
function p = newtonPoly(a,xData,x)
% Returns value of Newtons 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 coefcients
The coefcients of Pn1 (x) are determined by forcing the polynomial to pass through
each data point: yi = Pn1 (xi ), i = 1, 2, . . . , n. This yields the simultaneous equations
y1 = a1
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
..
.
yn = a 1 + (xn x 1 )a 1 + + (xn x 1 )(xn x 2 ) (xn xn1 )an

(a)

107

3.2 Polynomial Interpolation

Introducing the divided differences


yi =

yi y 1
, i = 2, 3, . . . , n
xi x 1

2 yi =

yi y2
, i = 3, 4, . . . , n
xi x 2

3 yi =

2 yi 2 y 3
, i = 4, 5, . . . n
xi x 3

(3.5)

..
.
n yn =

n1 yn n1 yn1
xn xn1

the solution of Eqs. (a) is


a1 = y1

a2 = y2

a 3 = 2 y3

an = n yn

(3.6)

If the coefcients are computed by hand, it is convenient to work with the format in
Table 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 (y 1 , y 2 , 2 y 3 , 3 y 4 and 4 y 5 ) in the table are the coefcients
of the polynomial. If the data points are listed in a different order, the entries in the table
will change, but the resultant polynomial will be the samerecall that a polynomial
of degree n 1 interpolating n distinct data points is unique.

 newtonCoeff
Machine computations are best carried out within a one-dimensional array a employing the following algorithm:
function a = newtonCoeff(xData,yData)
% Returns coefficients of Newtons polynomial.

Vous aimerez peut-être aussi