Sie sind auf Seite 1von 25

Module

for
The Newton Polynomial

Background.
We have seen how to expand a function in a Maclaurin polynomial about
involving the powers and a Taylor polynomial about involving the
powers . These polynomials have a single "center" . Polynomial interpolation
can be used to construct the polynomial of degree that passes through the n+1
points , for . If multiple "centers"
are used, then the result is the so called Newton polynomial. We attribute much of the
founding theory to Sir Isaac Newton (1643-1727).

Theorem (Newton Polynomial).
Suppose there is a known polynomial ) (
1
x p
n
that interpolates the data set:
) , , 2 , 1 , , ( n i y x
i i
= . When one more data point ) , (
1 1 + + n n
y x , which is distinct from all the
old data points, is added to the data set, we can construct a new polynomial that interpolates
the new data set. Keep also in mind that the new data point need not be at either end of the
old data set. Consider the following polynomial of degree n

[
=

+ =
n
i
i n n n
x x c x p x p
1
1
) ( ) ( ) ( (3.2.1)

where
n
c is an unknown constant. In the case of 1 = n , we specify ) (
0
x p as
1 0
) ( y x p = ,
where data point 1 need not be at the beginning of the data set.
At the points of the old data set, the values of ) (x p
n
are the same as those of ) (
1
x p
n
.
This is because the second term in Equation 3.2.1 is zero there. Since we assume ) (
1
x p
n

interpolates the old data set, ) (x p
n
does so too.
At the new data point, we want
1 1
) (
+ +
=
n n n
y x p . This can be accomplished by setting
the coefficient
n
c to be

[ [
=
+
+ +
=
+
+ +

=
n
i
i n
n n n
n
i
i n
n n n n
n
x x
x p y
x x
x p x p
c
1
1
1 1 1
1
1
1 1 1
) (
) (
) (
) ( ) (
(3.2.2)

which definitely exists since
1 + n
x is distinct from n) , , 2 1, i ( x
i
= . Now ) (x p
n
is a
polynomial that interpolates the new data set.
For any given data set: ) , , 2 , 1 , , ( n i y x
i i
= , we can obtain the interpolating
polynomial by a recursive process that starts from ) (
0
x p and uses the above construction to
get ) (
1
x p , ) (
2
x p , ., ) (
1
x p
n
. We will demonstrate this process through the following
example.


Assume that and for are distinct values. Then

,

where is a polynomial that can be used to approximate ,



and we write

.

The Newton polynomial goes through the points , i.e.

for .

The remainder term has the form

,

for some value that lies in the interval . The coefficients are
constructed using divided differences.






Definition. Divided Differences.
The divided differences for a function are defined as follows:


The divided difference formulae are used to construct the divided difference table:





































The coefficient of the Newton polynomial is and it is the
top element in the column of the i-th divided differences.
The Newton polynomial of degree that passes through the
points , for is








Example. Construct an interpolating polynomial for the following data set using the formula
in Equations 3.2.1 and 3.2.2

i 1 2 3 4 5
x 0 5 7 8 10
y 0 2 -1 -2 20

Step1: for 1 = i

0 ) (
1 0 0
= = = y c x p

Step 2: adding point #2

x c x x c x p x p
1 1 1 0 1
) ( ) ( ) ( = + =

Applying
2 2 1
) ( y x p = , we get 4 . 0
1
= c . So

x x x c x p x p 4 . 0 ) ( ) ( ) (
1 1 0 1
= + =

Step 3: adding point #3

) 5 ( 4 . 0 ) )( ( ) ( ) (
2 2 1 2 1 2
+ = + = x x c x x x x x c x p x p

Applying
3 3 2
) ( y x p = , we get 2714 . 0
2
= c . So

) 5 ( 2714 . 0 4 . 0 ) (
2
= x x x x p

Step 4: adding point #4

) 7 )( 5 ( ) ( ) )( )( ( ) ( ) (
3 2 3 2 1 3 2 3
+ = + = x x x c x p x x x x x x c x p x p

Applying
4 4 3
) ( y x p = , we get 0548 . 0
3
= c . So

) 7 )( 5 ( 0548 . 0 ) ( ) (
2 3
+ = x x x x p x p








Step 5: adding point #5

) 8 )( 7 )( 5 ( ) ( ) )( )( )( ( ) ( ) (
4 3 4 3 2 1 4 3 4
+ = + = x x x x c x p x x x x x x x x c x p x p

Applying
5 5 4
) ( y x p = , we get 0712 . 0
4
= c . So

) 8 )( 7 )( 5 ( 0712 . 0 ) ( ) (
3 4
+ = x x x x x p x p
which is the final answer.



If we expand the recursive form, the r.h.s of Equation (3.2.1), we obtain the more
familiar form of a polynomial

) ( ) )( ( ) )( ( ) ( ) (
2 1 2 1 2 1 1 0 1 n n n
x x x x x x c x x x x c x x c c x p + + + + =



which is called the Newtons interpolation polynomial. Its constants can be determined
from the data set: ) , , 2 , 1 , , ( n i y x
i i
=


) )( ( ) ( ) (
) ( ) (
) (
2 3 1 3 2 1 3 1 0 3 3 2
1 2 1 0 2 2 1
0 1 1 0
x x x x c x x c c y x p
x x c c y x p
c y x p
+ + = =
+ = =
= =

which gives


) )( (
) (
2 3 1 3
1 3 1 0 3
2
1 2
1 2
1 2
0 2
1
1 0
x x x x
x x c c y
c
x x
y y
x x
c y
c
y c


=

=
=




We should note that forcing the polynomial through data with no regard for rates of
change in the data (i.e., derivatives) results in a
0
C continuous interpolating polynomial.
Alternatively, each data condition
i i
y x p = ) ( is called a
0
C constraint.
Lets use the following notation for these constants

, 2 , 1 , ] [
2 1 1
= =

i y x x x c
i i


which has the following property

1
1 2 1 3 2
2 1
] [ ] [
] [
x x
y x x x y x x x
y x x x
i
i i
i

=




so that it is called the divided difference. For the proof of this formula, please refer to
Gautschi (1997), but for example: | | | |
| | | |
1 3
2 1 3 2
3 2 1
1 2
1 2
2 1
, ,
, , , ,
x x
y x x y x x
y x x x
x x
y y
y x x

= ,
etc. Using this recursion property, a table of divided differences can be generated as follows


y x x x x y x x x y x x y x
y x x x y x x y x
y x x y x
y x
] [ ] [ ] [
] [ ] [
] [
4 3 2 1 4 3 2 4 3 4 4
3 2 1 3 2 3 3
2 1 2 2
1 1


This table can be viewed as part of an ) 1 ( + n n matrix for a data set that has n
points. The first column is the x values of the data set and the second column is the y or
function values of the data set. For the rest of the ) 1 ( ) 1 ( n n lower triangle, the rule for
the construction of its elements, say, element(i, j), is as follows

(1) It takes the form of a division ( 1 , 3 > > j i j )

) 1 , 2 ( ) 1 , (
) 1 , 1 ( ) 1 , (
) , (
+

=
j i element i element
j i element j i element
j i element

where

Element(i, j-1) is the element in the matrix immediately left of element(i, j);
Element(i-1, j-1) is the element above and immediately left;
Element(i, 1) is the x on the same row;
Element(i-j+2, 1). To find it, going from element(i, j) diagonally upward and leftward, when
reaching the second column, it is the element to the left.

(2) The denominator is easier to see in this form:

k q
q l k
x x
left above element left on element
y x x x

= ] [




General Form of Newtons Divided Difference Polynomial
In the two previous cases, we found linear and quadratic interpolants for Newtons divided
difference method. Let us revisit the quadratic polynomial interpolant formula
) )( ( ) ( ) (
1 0 2 0 1 0 2
x x x x b x x b b x f + + =
where
) (
0 0
x f b =

0 1
0 1
1
) ( ) (
x x
x f x f
b

=

0 2
0 1
0 1
1 2
1 2
2
) ( ) ( ) ( ) (
x x
x x
x f x f
x x
x f x f
b

=
Note that ,
0
b ,
1
b and
2
b are finite divided differences. ,
0
b ,
1
b and
2
b are the first, second,
and third finite divided differences, respectively. We denote the first divided difference by
) ( ] [
0 0
x f x f =
the second divided difference by

0 1
0 1
0 1
) ( ) (
] , [
x x
x f x f
x x f

=
and the third divided difference by

0 2
0 1 1 2
0 1 2
] , [ ] , [
] , , [
x x
x x f x x f
x x x f

=

0 2
0 1
0 1
1 2
1 2
) ( ) ( ) ( ) (
x x
x x
x f x f
x x
x f x f

=
where ], [
0
x f ], , [
0 1
x x f and ] , , [
0 1 2
x x x f are called bracketed functions of their variables
enclosed in square brackets.
Rewriting,
) )( ]( , , [ ) ]( , [ ] [ ) (
1 0 0 1 2 0 0 1 0 2
x x x x x x x f x x x x f x f x f + + =
This leads us to writing the general form of the Newtons divided difference polynomial for
1 + n data points, ( ) ( ) ( ) ( )
n n n n
y x y x y x y x , , , ,......, , , ,
1 1 1 1 0 0
, as
) )...( )( ( .... ) ( ) (
1 1 0 0 1 0
+ + + =
n n n
x x x x x x b x x b b x f
where
] [
0 0
x f b =
] , [
0 1 1
x x f b =
] , , [
0 1 2 2
x x x f b =

] ,...., , [
0 2 1 1
x x x f b
n n n
=
] ,...., , [
0 1
x x x f b
n n n
=
where the definition of the
th
m divided difference is
] ,........, [
0
x x f b
m m
=

0
0 1 1
] ,........, [ ] ,........, [
x x
x x f x x f
m
m m

=


From the above definition, it can be seen that the divided differences are calculated
recursively.
For an example of a third order polynomial, given ), , (
0 0
y x ), , (
1 1
y x ), , (
2 2
y x and ), , (
3 3
y x
) )( )( ]( , , , [
) )( ]( , , [ ) ]( , [ ] [ ) (
2 1 0 0 1 2 3
1 0 0 1 2 0 0 1 0 3
x x x x x x x x x x f
x x x x x x x f x x x x f x f x f
+
+ + =




Figure 5 Table of divided differences for a cubic polynomial.

( )
0 0
x f x
0
b
( )
1 1
x f x
( )
2 2
x f x
( )
3 3
x f x
1
b
2
b
3
b
| |
0 1
, x x f
| |
1 2
, x x f
| |
2 3
, x x f
| |
0 1 2
, , x x x f
| |
1 2 3
, , x x x f
| |
0 1 2 3
, , , x x x x f


Example 3.2.2. Using the table of divided differences, construct the Newton interpolating
polynomial for the data set in Example 3.2.1.

071 . 0
0 10
055 . 0 767 . 0
767 . 0
5 10
167 . 0 4
4
7 10
1 11
11
8 10
2 20
20 10
055 . 0
0 8
271 . 0 167 . 0
167 . 0
5 8
5 . 1 1
1
7 8
1 2
2 8
271 . 0
0 7
4 . 0 5 . 1
5 . 1
5 7
2 1
1 7
4 . 0
0 5
0 2
2 5
0 0
=

+
=

+
=

+
=

+
=


where the number of decimal digits is reduced so that the table fits the page here. The
bracketed terms <> are the coefficients of the Newton polynomial. Then

))) 0712 . 0 ) 8 ( 0548 . 0 )( 7 ( 2714 . 0 )( 5 ( 4 . 0 ( 0
) 8 )( 7 )( 5 ( 0712 . 0 ) 7 )( 5 ( 0548 . 0 ) 5 ( 2714 . 0 4 . 0 0 ) (
4
+ + + + =
+ + + =
x x x x
x x x x x x x x x x x p


The second line above is called a nested form that can save computation operations and
produces a more accurate solution numerically. Note in passing how similar this table is to
Romberg quadrature (or Richardsons extrapolation), only in here the formula for calculating
the rightmost terms is a simple ratio of differences.
A MATLAB code newton_example.m is written to incorporate the divided difference
scheme and calculate the Newton interpolation polynomial using the nested form. The
algorithm is as follows

(1) Input and plot data set points;

(2) Declare c(n, n + 1) as the matrix for the table; Note: c = element in Equation (3.2.9);

(3) c(i, 1) x; c(i, 2) y;

(4) Calculate the rest of the table due to Equation (3.2.9);

(5) Calculate the polynomial using c(i, i +1) as the coefficients of the polynomial.
Figure 3.2.1 shows the resulting polynomial for the above example.


Figure 3.2.1 Newton interpolation polynomial.

Through the above example, we can see the advantages of the divided difference table
over the algebraic approach we have in Example 3.2.1. First, it has less computational
operations. We do not need to write the polynomial and then use the C
0
condition to calculate
the constants. Second, it is much easier to incorporate it in a computer code.

Theorem. (Error Bounds for Newton Interpolation, Equally Spaced Nodes) Assume
that defined on , which contains the equally spaced nodes
. Additionally, assume that and the derivatives of up to the order are
continuous and bounded on the special subintervals , , , ,
and , respectively; that is,

,

for . The error terms corresponding to these three cases have the following
useful bounds on their magnitude

(i). is valid for ,

(ii). is valid for ,

-2 0 2 4 6 8 10 12
-10
-5
0
5
10
15
20
x
y
Newton Interpolating Polynomial
data points
Newton Polynomial
(iii). is valid for ,

(iv). is valid for ,

(v). is valid for .


Algorithm (Newton Interpolation Polynomial). To construct and evaluate the Newton
polynomial of degree that passes through the n+1 points
, for



where

and


Remark 1. Newton polynomials are created "recursively."

.

Remark 2. Mathematica's arrays are lists and the subscripts must start with 1 instead of 0.









Report to be handed in.
Computer Exercises






First. Enter the subroutine which will construct the Newton polynomials.



Exercise 1. (a) Construct the Newton polynomials , of degree n = 1, 2 using
the divided difference formulae.
Use the data points (1, 3.6), (2, 1.8), (3, 1.2).
1. (b) Evaluate the Newton polynomials you found in part (a) at x = 2.5.

















Exercise 2. (a) Construct the Newton polynomial of degree n = 4, for the data points
(1, 3.6), (2, 1.8), (3, 1.2), (4, 0.9), (5, 0.72) using the Mathematica subroutine for constructing
a Newton polynomial.
2. (b) Show the divided difference table used in the construction.
2. (c) Evaluate at x = 2.5,


The divided difference table for this problem is:


Observe that the coefficients are decreasing in size. Can you explain why this might happen.
Is it desirable?


Exercise 3. Investigate the Newton polynomials of degree n = 1,2,3 for f(x) = cos(x) over the
interval [0,3].

















Exercise 4. Application to number theory.
4. (a) Find the formula for the sum of the first n integers.




Notice that the divided difference table has zeros for the 2nd and higher order differences.


Thus the formula for the sum of the first n integers is:




4. (b) Find the formula for the sum of the squares of the first n integers is:




Notice that the divided difference table has zeros for the 3rd and higher order differences.


Thus the formula for the sum of the squares of the first n integers is:











Excercise 5
The upward velocity of a rocket is given as a function of time in Table 3.



Table 3 Velocity as a function of time.
(s) t (m/s) ) (t v
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67

a) Determine the value of the velocity at 16 = t seconds with third order polynomial
interpolation using Newtons divided difference polynomial method.
b) Using the third order polynomial interpolant for velocity, find the distance covered by the
rocket from s 11 = t to s 16 = t .
c) Using the third order polynomial interpolant for velocity, find the acceleration of the
rocket at s 16 = t .
Solution
a) For a third order polynomial, the velocity is given by
) )( )( ( ) )( ( ) ( ) (
2 1 0 3 1 0 2 0 1 0
t t t t t t b t t t t b t t b b t v + + + =
Since we want to find the velocity at , 16 = t and we are using a third order polynomial, we
need to choose the four data points that are closest to 16 = t that also bracket 16 = t to
evaluate it. The four data points are , 10
0
= t , 15
1
= t , 20
2
= t and 5 . 22
3
= t .
Then
, 10
0
= t 04 . 227 ) (
0
= t v
, 15
1
= t 78 . 362 ) (
1
= t v
, 20
2
= t 35 . 517 ) (
2
= t v
, 5 . 22
3
= t 97 . 602 ) (
3
= t v
gives
] [
0 0
t v b =
) (
0
t v =
04 . 227 =
] , [
0 1 1
t t v b =

0 1
0 1
) ( ) (
t t
t v t v

=

10 15
04 . 227 78 . 362

=
148 . 27 =
] , , [
0 1 2 2
t t t v b =

0 2
0 1 1 2
] , [ ] , [
t t
t t v t t v

=
1 2
1 2
1 2
) ( ) (
] , [
t t
t v t v
t t v

=

15 20
78 . 362 35 . 517

=
914 . 30 =
148 . 27 ] , [
0 1
= t t v
0 2
0 1 1 2
2
] , [ ] , [
t t
t t v t t v
b

=

10 20
148 . 27 914 . 30

=
37660 . 0 =
] , , , [
0 1 2 3 3
t t t t v b =

0 3
0 1 2 1 2 3
] , , [ ] , , [
t t
t t t v t t t v

=
1 3
1 2 2 3
1 2 3
] , [ ] , [
] , , [
t t
t t v t t v
t t t v

=
2 3
2 3
2 3
) ( ) (
] , [
t t
t v t v
t t v

=

20 5 . 22
35 . 517 97 . 602

=
248 . 34 =
1 2
1 2
1 2
) ( ) (
] , [
t t
t v t v
t t v

=

15 20
78 . 362 35 . 517

=
914 . 30 =
1 3
1 2 2 3
1 2 3
] , [ ] , [
] , , [
t t
t t v t t v
t t t v

=

15 5 . 22
914 . 30 248 . 34

=
44453 . 0 =
37660 . 0 ] , , [
0 1 2
= t t t v

0 3
0 1 2 1 2 3
3
] , , [ ] , , [
t t
t t t v t t t v
b

=

10 5 . 22
37660 . 0 44453 . 0

=

3
10 4347 . 5

=


Hence
) )( )( ( ) )( ( ) ( ) (
2 1 0 3 1 0 2 0 1 0
t t t t t t b t t t t b t t b b t v + + + =

) 20 )( 15 )( 10 ( 10 5347 . 5
) 15 )( 10 ( 37660 . 0 ) 10 ( 148 . 27 04 . 227
3
+
+ + =

t t t
t t t

At , 16 = t

) 20 16 )( 15 16 )( 10 16 ( 10 5347 . 5
) 15 16 )( 10 16 ( 37660 . 0 ) 10 16 ( 148 . 27 04 . 227 ) 16 (
3
+
+ + =

v

m/s 06 . 392 =
b) The distance covered by the rocket between s 11 = t and s 16 = t can be calculated from
the interpolating polynomial

) 20 )( 15 )( 10 ( 10 5347 . 5
) 15 )( 10 ( 37660 . 0 ) 10 ( 148 . 27 04 . 227 ) (
3
+
+ + =

t t t
t t t t v

, 0054347 . 0 13204 . 0 265 . 21 2541 . 4
3 2
t t t + + + = 5 . 22 10 s s t
Note that the polynomial is valid between 10 = t and 22.5 = t and hence includes the limits
of 11 = t and 16 = t .
So
( ) ( ) ( )
}
=
16
11
11 16 dt t v s s
dt t t t ) 0054347 . 0 13204 . 0 265 . 21 2541 . 4 (
3 2
16
11
+ + + =
}


16
11
4 3 2
4
0054347 . 0
3
13204 . 0
2
265 . 21 2541 . 4
(

+ + + =
t t t
t
m 1605 =
c) The acceleration at 16 = t is given by

16
) ( ) 16 (
=
=
t
t v
dt
d
a
) ( ) ( t v
dt
d
t a =
( )
3 2
0054347 . 0 13204 . 0 265 . 21 2541 . 4 t t t
dt
d
+ + + =

2
016304 . 0 26408 . 0 265 . 21 t t + + =

2
) 16 ( 016304 . 0 ) 16 ( 26408 . 0 265 . 21 ) 16 ( + + = a

2
m/s 664 . 29 =

Any kind programs of polynomial Lagrange in Matlab:
1. function [C,D]=newpoly(X,Y)

%Input - X is a vector that contains a list of abscissas
% - Y is a vector that contains a list of ordinates
%Output - C is a vector that contains the coefficients
% of the Newton intepolatory polynomial
% - D is the divided difference table

% NUMERICAL METHODS: MATLAB Programs
%(c) 1999 by John H. Mathews and Kurtis D. Fink
%To accompany the textbook:
%NUMERICAL METHODS Using MATLAB,
%by John H. Mathews and Kurtis D. Fink
%ISBN 0-13-270042-5, (c) 1999
%PRENTICE HALL, INC.
%Upper Saddle River, NJ 07458

n=length(X);
D=zeros(n,n);
D(:,1)=Y';

%Use formula (20) to form the divided difference table

for j=2:n
for k=j:n
D(k,j)=(D(k,j-1)-D(k-1,j-1))/(X(k)-X(k-j+1));
end
end

%Determine the coefficients of the Newton interpolatory
polynomial

C=D(n,n);

for k=(n-1):-1:1
C=conv(C,poly(X(k)));
m=length(C);
C(m)=C(m)+D(k,k);
end


2. function nf = divdiff ( xi, fi )

%DIVDIFF compute the coefficients for the Newton forward divided
% difference form of the interpolating polynomial
% associated with a given set of interpolating points
%
% calling sequences:
% nf = divdiff ( xi, fi )
% divdiff ( xi, fi )
%
% inputs:
% xi vector containing the interpolating points
% fi vector containing function values
% the i-th entry in this vector is the function
% value associated with the i-th entry in the 'xi'
% vector
%
% output:
% nf vector containing coefficients for the Newton
% forward divided difference form of the interpolating
% polynomial associated with the given set of
% interpolating points
%
% NOTE:
% to evaluate the Newton form, apply the routine NF_EVAL
%

n = length ( xi );
m = length ( fi );

if ( n ~= m )
disp ( 'divdiff error: number of ordinates and number of function values
must be equal' )
return
end

nf = fi;
for j = 2:n
for i = n:-1:j
nf(i) = ( nf(i) - nf(i-1) ) / ( xi(i) - xi(i-j+1) );
end
end


3. function yi = NewtonInter(x,y,xi)
% Newton interpolation algorithm
% x,y - row-vectors of (n+1) data values (x,y)
% xi - a row-vector of x-values, where interpolation is to be found (could be a single value)
% yi - a row-vector of interpolated y-values

n = length(x) - 1; % the degree of interpolation polynomial
ni = length(xi); % the number of x-values, where interpolation is to be found

D = ones(n,n); % the matrix for Newton divided differences
% has n rows for divided differences of the corresponding order
% has n columns corresponding to data values x(1),x(2),...,x(n)

for k = 1 : n
D(k,1) = (y(k+1)-y(k))/(x(k+1)-x(k)); % first divided difference
end

for k = 2 : n % start the outer loop through the k-th order divided differences

for kk = 1 : (n-k+1) % start the inner loop through the data values
% the matrix of divided differences is triangular!

D(kk,k) = (D(kk+1,k-1) - D(kk,k-1))/(x(kk+k)-x(kk)); % see the Newton divided differences
end % end of the inner loop

end % the end of the outer loop

% define the (n+1) coefficients of the Newton interpolating polynomial
a(1) = y(1);

for k = 2 : (n+1)
a(k) = D(1,k-1); % the first row of the matrix of divided differences corresponds to the point x(1)
end

% compute values of the Newton interpolating polynomial at each x-value of xi

% Note: the algorithm uses the Horner's rule for polynomial evaluation,
% where the nested multiplication is performed in parallel for each x-value of the row xi

yi = a(n+1)*ones(1,ni); % initialization of the vector yi as the coefficient of the highest degree

for k = 1 : n
yi = a(n+1-k)+yi.*(xi-x(n+1-k)); % nested multiplication, where xi is a row-vector
end

% BONUS-PROBLEM: this program can be improved for space savings (set D as a vector rather than a
matrix!)
% If you get a solution, send it to the instructor. The first student, who gets a correct solution,
% will get a bonus mark to the final mark.