1 Newton`s Divided Difference Form

1
Newton’s Divided Difference Form
Suppose we have n + 1 distinct nodes, x0 , x1 , x2 , x3 , . . . xn with corresponding function values (or abscissas)
f0 , f1 , . . . fn .
Define the interpolating polynomial in the form:
Pn (x) = a0 + a1 (x − x0 ) + a2 (x − x0 )(x − x1 ) + . . . + an (x − x0 )(x − x1 ) . . . (x − xn−1 )
In class we talked about an algorithm for evaluating this polynomial that you will need to implement for
your homework assignment. Before you can evaluate it though you need to know how to find the values of
the coefficients an .
At x0 we must have Pn (x0 ) = f0 so,
Pn (x0 ) = a0 = f0 .
Giving a0 = f0 .
At x1 we must have Pn (x1 ) = f1 so,
P (x1 ) = a0 + a1 (x1 − x0 ) = f1 .
Since a0 = f0 we have that
f1 = f0 + a1 (x1 − x0 ).
Solving for a1 gives
a1 =
f1 − f0
.
x1 − x0
At x2 we must have that P( x2 ) = f2 . Using a0 and a1 from above we then have:
f1 − f0
f2 = f0 +
(x2 − x0 ) + a2 (x2 − x0 )(x2 − x1 )
x1 − x0
Solving for a1 leads to:
f2 − f0 −
a2
=
=
=
=
=
=
=
=
=
f1 −f0
x1 −x0
(x2 − x0 )
(x2 − x0 )(x2 − x1 )
−f0
− xf11 −x
(x2 − x0 )
0
(f2 −f0 )(x1 −x0 )
x1 −x0
(x2 − x0 )(x2 − x1 )
(f2 − f0 )(x1 − x0 ) − (f1 − f0 ) (x2 − x0 )
(x2 − x0 )(x2 − x1 )(x1 − x0 )
f2 x1 − f2 x0 − f0 x1 + f0 x1 − f1 x2 + f1 x0 + f0 x2 − f0 x0
(x2 − x0 )(x2 − x1 )(x1 − x0 )
f2 x1 − f2 x0 − f1 x2 + f1 x0 + f0 x2 − f0 x0 − f1 x1 + f1 x1
(x2 − x0 )(x2 − x1 )(x1 − x0 )
f2 x1 − f2 x0 − f1 x1 + f1 x0 − f1 x2 + f0 x2 − f0 x0 + f1 x1
(x2 − x0 )(x2 − x1 )(x1 − x0 )
f2 (x1 − x0 ) − f1 (x1 − x0 ) − (f1 − f0 )x2 + f1 (x1 − x0 )
(x2 − x0 )(x2 − x1 )(x1 − x0 )
(f2 − f1 )(x1 − x0 ) − (f1 − f0 )(x2 − x0 )
(x2 − x0 )(x2 − x1 )(x1 − x0 )
(f2 −f1 )
(x2 −x1 )
−
(f1 −f0 )
(x1 −x0 )
(x2 − x0 )
1
Thus
a2 =
(f2 −f1 )
(x2 −x1 )
−
(f1 −f0 )
(x1 −x0 )
(x2 − x0 )
Now, we define the divided differences as follows: Given x0 , x1 , x2 , x3 , . . . xn are n + 1 and a function f (x)
then we have:
f [xi ] = f (xi ) = fi
and
f [xi1 , xi2 , . . . xim ] − f xi0 , xi1 , . . . xim−1
, m ≥ 1.
f [xi0 , xi1 , . . . xim ] =
xim − xi0
By looking at the formulas we have derived above, we note that
a0
=
a1
=
a2
=
f0 = f [x0 ],
f1 − f0
f [x1 ] − f [x0 ]
=
= f [x0 , x1 ],
x1 − x0
x1 − x0
(f2 −f1 )
(x2 −x1 )
−
(f1 −f0 )
(x1 −x0 )
(x2 − x0 )
=
(f [x2 ]−f [x1 ])
(x2 −x1 )
−
(f [x1 ]−f [x0 ])
(x1 −x0 )
(x2 − x0 )
=
f [x1 , x2 ] − f [x0 , x1 ]
= f [x0 , x1 , x2 ].
x2 , −x0
This trend continues, leading to
ak = f [x0 , x1 , x2 , . . . , xk ], k = 0, 1, . . . n.
You will need to use this idea and the definition of divided differences to create an algorithm that inputs the
{xi }ni=0 and the {fi }ni=0 and then returns a vector containing the values {ai }ni=0 .
Example: Find the Newton form of the interpolating polynomial for the following set of corresponding x
and y values.
x
y
.5
2
1
-1
3
7
4
6
The complete divided difference table is:
x0 = .5
f [x0 ] = 2
f [x0 , x1 ] = −6
x1 = 1
f [x1 ] = −1
f [x0 , x1 , x2 ] = 4
34
f [x0 , x1 , x2 , x3 ] = − 21
f [x1 , x2 ]=4
x2 = 3
f [x1 , x2 , x3 ] = −5/3
f [x2 ] = 7
f [x2 , x3 ]=-1
x3 = 4
f [x3 ] = 6
and the Newton form of the interpolating polynomial is
P0,1,2,3 = 2 − 6(x − .5) + 4(x − .5)(x − 1) −
2
34
21 (x
− .5)(x − 1)(x − 3)
Here we compute the vales by:
2
f [x0 , x1 ]
=
f [x1 , x2 ]
=
f [x2 , x3 ]
=
f [x0 , x1 , x2 ]
=
f [x1 , x2 , x3 ]
=
f [x0 , x1 , x2 , x3 ]
=
f [x1 ] − f [x0 ]
−1 − 2
= −6
=
x1 − x0
1 − .5
f [x2 ] − f [x1 ]
7 − (−1)
=
=4
x2 − x1
3−1
f [x3 ] − f [x2 ]
6−7
=
= −1
x3 − x2
4−3
f [x1 , x2 ] − f [x0 , x1 ]
4 − (−6)
=
= 2.5
x2 − x0
3 − .5
f [x2 , x3 ] − f [x1 , x2 ]
−1 − 4
=
= −5/3
x3 − x1
4−1
f [x1 , x2 , x3 ] − f [x0 , x1 , x2 ]
−(5/3) − 4
=
= −34/21
x3 − x0
4 − .5
Neville’s Algorithm
Suppose we have n + 1 distinct nodes x0 , x1 , x2 , x3 , . . . xn with corresponding function values f0 , f1 , . . . fn .
Define the polynomial Pm1 ,m2 ,...,mk (x) as the polynomial that interpolates at the subset {xm1 , xm2 , xm3 . . . xmk }.
For example P1,3,4 (x) would be a second degree polynomial that interpolates at x1 , x3 and x4 . These polynomials satisfy the property:
Pi (x) = fi
Pm1 ,m2 ,...mk (x) =
(x − xm1 )Pm2 ,...mk (x) − (x − xmk )Pm1 ,m2 ,...mk−1 (x)
,
xmk − xm1
k≥2
To prove this fact one just checks that the polynomial defined in this way does indeed interpolate where it
is supposed to and that its degree is correct. You can find the proof of this on page 355 of your text , but to
see the idea lets look at an example. Consider P0,1,2 (x). This is supposed to be the interpolating polynomial
for x0 , x1 and x2 . Since there are three interpolating points the degree should be 2 or less. Now, P1,2 (x)
and P0,1 (x) are degree 1 or less, thus when I multiply them by linear factors then result is degree 2 or less.
Namely:
(x − x0 )P1,2 (x) − (x − x2 )P0,1 (x)
x2 − x0
is degree 2 or less. Now we just need to check to see that this formula immediately above does indeed
interpolate at x0 , x1 and x2 . We use the fact that P1,2 (x) interpolates at x1 and x2 and P0,1 (x) interpolates
at x0 and x1 . So
:
0
(x
(x0 −
x
)P
−(x
0−x2 )f0
0
1,2 0 ) − (x0 − x2 )P0,1 (x0 )
=
= f0
x2
−
x
x2 − x0
0
Similar calculations will verify that indeed this formula interpolates at x1 and x2 as well. Since the formula
is a degree 2 (or less) polynomial that interpolates at x0 , x1 and x2 , then it is the interpolating polynomial
and thus we have verified that
P0,1,2 (x) =
(x − x0 )P1,2 (x) − (x − x2 )P0,1 (x)
x2 − x0
3
Example: Neville’s Algorithm uses this fact to evaluate Pn (x) = P0,1,2,3,...n (x) for one give x. Lets start
with an example. Suppose we have the data given by:
x
y
0
2
1
-1
2
4
and we want to evaluate P2 (1.3). We start by finding P0 (1.3), P1 (1.3) and P2 (1.3), since these are just
constant functions these are in fact just the y values from the table.
x0 = 0 P0 (1.3) = 2
x1 = 1 P1 (1.3) = −1
x2 = 2 P2 (1.3) = 4
Next we compute P0,1 (1.3) and P1,2 (1.3).
P0,1 (1.3)
=
P1,2 (1.3)
=
(1.3 − x0 )P1 (1.3) − (1.3 − x1 )P0 (1.3)
(1.3)(−1) − (.3)(2)
=
= −1.9
x1 − x0
1
(1.3 − x1 )P2 (1.3) − (1.3 − x2 )P1 (1.3)
(.3)(4) − (−.7)(−1)
=
= .5
x2 − x1
1
We can record these in our table by writing:
x0 = 0 P0 (1.3) = 2
x1 = 1 P1 (1.3) = −1 P0,1 (1.3) = −1.9
x2 = 2 P2 (1.3) = 4
P1,2 (1.3) = .5
Finally we compute P0,1,2 (1.3) by:
P0,1,2 (1.3)
=
=
(1.3 − x0 )P1,2 (1.3) − (1.3 − x2 )P0,1 (1.3)
x2 − x0
(1.3)(.5) − (−.7)(−1.9)
= −.34
2
Completing our table one would have:
x0 = 0 P0 (1.3) = 2
x1 = 1 P1 (1.3) = −1 P0,1 (1.3) = −1.9
x2 = 2 P2 (1.3) = 4
P1,2 (1.3) = .5
P0,1,2 (1.3) = −.34
This last value is the value of our interpolating polynomial at 1.3. Namely P2 (1.3) = −.34 . One interesting
observation is that here we started with three nodes {0, 1, 2} and three corresponding abscissas {2, −1, 4}. If
we wanted to add another point (or points) to this and still evaluate at 1.3 then we would just add another
row to the bottom of the table. Newton’s form has the same property. If you add another point, you
only need to add one line to your table and you don’t need to recompute everything. Also nothing in our
arguments relies on the xi ’s being in any particular order so you can order them however you like.
4