Divided Difference
Divided Difference
Divided Difference
Spring 2010
Joe Mahaffy, hmahaffy@math.sdsu.edui
Outline
Input:
Output:
y = P(x0 ), z = P (x0 ).
1.
Set y = an , z = an
2.
3.
Set y = x0 y + a0
4.
Output (y , z)
5.
End program
Joe Mahaffy, hmahaffy@math.sdsu.edui
Representing Polynomials
Divided Differences
Different forms of Divided Difference Formulas
Representing Polynomials
If Pn (x) is the nth degree polynomial that agrees with f (x) at the
points {x0 , x1 , . . . , xn }, then we can (for the appropriate constants
{a0 , a1 , . . . , an }) write:
Pn (x) =
a0 + a1 (x x0 ) + a2 (x x0 )(x x1 ) +
+ an (x x0 )(x x1 ) (x xn1 )
Representing Polynomials
Divided Differences
Different forms of Divided Difference Formulas
Representing Polynomials
If Pn (x) is the nth degree polynomial that agrees with f (x) at the
points {x0 , x1 , . . . , xn }, then we can (for the appropriate constants
{a0 , a1 , . . . , an }) write:
Pn (x) =
a0 + a1 (x x0 ) + a2 (x x0 )(x x1 ) +
+ an (x x0 )(x x1 ) (x xn1 )
a0 + (x x0 ) (a1 + (x x1 ) (a2 +
+ (x xn2 ) (an1 + an (x xn1 )))) ,
Representing Polynomials
Divided Differences
Different forms of Divided Difference Formulas
Just Algebra
a0 + a1 (x x0 ) + a2 (x x0 )(x x1 ) +
+ an (x x0 )(x x1 ) (x xn1 )
at x0 : a0 = Pn (x0 ) = f (x0 ).
at x1 : f (x0 ) + a1 (x1 x0 ) = Pn (x1 ) = f (x1 )
f (x1 ) f (x0 )
.
x1 x 0
f (x1 ) f (x0 )
f (x2 ) f (x0 )
.
at x2 : a2 =
(x2 x0 )(x2 x1 ) (x2 x0 )(x1 x0 )
a1 =
Representing Polynomials
Divided Differences
Different forms of Divided Difference Formulas
f [xi+1 ] f [xi ]
.
xi+1 xi
k th Divided Difference:
f [xi , xi+1 , . . . , xi+k ] =
Representing Polynomials
Divided Differences
Different forms of Divided Difference Formulas
.
at x2 : a2 =
(x2 x0 )(x2 x1 ) (x2 x0 )(x1 x0 )
a1 =
Clearly:
a0 = f [x0 ],
a1 = f [x0 , x1 ].
Representing Polynomials
Divided Differences
Different forms of Divided Difference Formulas
f (x2 ) f (x0 )
f (x1 ) f (x0 )
(x2 x0 )(x2 x1 )
(x2 x1 )(x1 x0 )
(f (x2 ) f (x1 ))
(f (x1 ) f (x0 ))
(x2 x0 )(x2 x1 )
(x2 x0 )(x1 x0 )
f [x0 , x1 ]
f [x1 , x2 ]
= f[x0 , x1 , x2 ]
x2 x 0
x2 x 0
(!!!)
Representing Polynomials
Divided Differences
Different forms of Divided Difference Formulas
n
X
k=1
"
f [x0 , . . . , xk ]
k1
Y
m=0
(x xm ) .
Pn (x) = f [x0 ] +
f [x0 , x1 ](x x0 ) +
f [x0 , x1 , x2 ](x x0 )(x x1 ) +
f [x0 , x1 , x2 , x3 ](x x0 )(x x1 )(x x2 ) +
This expression is known as Newtons Interpolatory Divided
Difference Formula.
Joe Mahaffy, hmahaffy@math.sdsu.edui
Representing Polynomials
Divided Differences
Different forms of Divided Difference Formulas
f(x)
f [x0 ]
f [x1 ]f [x0 ]
x1 x0
f [x1 , x2 ] =
f [x2 ]f [x1 ]
x2 x1
f [x2 , x3 ] =
f [x3 ]f [x2 ]
x3 x2
f [x3 , x4 ] =
f [x4 ]f [x3 ]
x4 x3
f [x4 , x5 ] =
f [x5 ]f [x4 ]
x5 x4
f [x1 ]
f [x2 ]
f [x3 ]
f [x4 ]
f [x5 ]
f [x0 , x1 , x2 ] =
f [x1 , x2 , x3 ] =
f [x2 , x3 , x4 ] =
f [x3 , x4 , x5 ] =
Representing Polynomials
Divided Differences
Different forms of Divided Difference Formulas
Representing Polynomials
Divided Differences
Different forms of Divided Difference Formulas
f (n) ()
.
n!
Representing Polynomials
Divided Differences
Different forms of Divided Difference Formulas
Representing Polynomials
Divided Differences
Different forms of Divided Difference Formulas
n
X
k=0
s(s 1) (s k + 1)
s
=
k
k!
n
X
s
k=1
k! hk f[x0 , . . . , xk ].
Representing Polynomials
Divided Differences
Different forms of Divided Difference Formulas
1
1 f (x1 ) f (x0 )
= 2 2 f (x0 ).
f [x0 , x1 , x2 ] =
2h
h
2h
f [x0 , x1 ] =
1
k f (x0 ).
k! hk
Thus we can write Newtons Forward Difference Formula
n
X
s
k f(x0 ).
Pn (x0 + sh) = f[x0 ] +
k
f [x0 , . . . , xk ] =
k=1
Representing Polynomials
Divided Differences
Different forms of Divided Difference Formulas
1
k f (xn ).
k! hk
where
s
k
= (1)k
s(s + 1) (s + k 1)
.
k!
Representing Polynomials
Divided Differences
Different forms of Divided Difference Formulas
f (x)
f [x0 ]
f[x1 ]f[x0 ]
x1 x0
f [x1 , x2 ] =
f [x2 ]f [x1 ]
x2 x1
f [x2 , x3 ] =
f [x3 ]f [x2 ]
x3 x2
f [x3 , x4 ] =
f [x4 ]f [x3 ]
x4 x3
f [x1 ]
f [x2 ]
f [x3 ]
x4
f [x4 ]
x5
f [x5 ]
f[x4 , x5 ] =
f[x0 , x1 , x2 ] =
f [x1 , x2 , x3 ] =
f [x2 , x3 , x4 ] =
f[x3 , x4 , x5 ] =
f[x5 ]f[x4 ]
x5 x4
Forward: The fwd div. diff. are the top entries in the table.
Backward: The bwd div. diff. are the bottom entries in the table.
Representing Polynomials
Divided Differences
Different forms of Divided Difference Formulas
f (x)
f [x2 ]
x1
f [x1 ]
x0
f[x0 ]
x1
f [x1 ]
x2
f [x2 ]
x3
f [x3 ]
f[x2 , x1 , x0 , x1 ]
f[x1 , x0 , x1 , x2 ]
f [x0 , x1 , x2 , x3 ]
f[x2 , x1 , x0 , x1 , x2 ]
f [x1 , x0 , x1 , x2 , x3 ]
Representing Polynomials
Divided Differences
Different forms of Divided Difference Formulas
f [x1 , x0 ] + f [x0 , x1 ]
2
f [x2 , x1 , x0 , x1 ] + f [x1 , x0 , x1 , x2 ]
2
+ s 2 (s 2 1)h4 f [x2 , x1 , x0 , x1 , x2 ]
+ s(s 2 1)h3
+ ...
+ s 2 (s 2 1) (s 2 (m 1)2 )h2m f [xm , . . . , xm ]
+ s(s 2 1) (s 2 m2 )h2m+1
Representing Polynomials
Divided Differences
Different forms of Divided Difference Formulas
n
X
s
k! hk f [x0 , . . . , xk ]
k
k=1
n
s
X
(1)k
k f (xn )
k
k=1
s
s(s + 1) (s + k 1)
= (1)k
k
k!
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
Osculating Polynomials
In Painful Generality
n
X
mi .
i=0
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
n
X
j=0
where
n
X
n,j (x),
f (xj )H
j=0
h
i
Hn,j (x) = 1 2(x xj )Ln,j (xj ) L2n,j (x)
n,j (x) = (x xj )L2 (x),
H
n,j
and Ln,j (x) are our old friends, the Lagrange coefficients:
n
Y
Ln,j (x) =
i=0, i6=j
x xi
.
xj x i
Qn
xi )2 (2n+2)
f
((x)).
(2n + 2)!
i=0 (x
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
Recall:
0,
1
if i 6= j
if i = j
1 of 2
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
Recall:
0,
1
if i 6= j
if i = j
1 of 2
n,j (xi ) = 0.
If follows that when i 6= j: Hn,j (xi ) = H
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
Recall:
0,
1
if i 6= j
if i = j
1 of 2
n,j (xi ) = 0.
If follows that when i 6= j: Hn,j (xi ) = H
i
h
(
Hn,j (xj ) = 1 2(xj xj )Ln,j (xj ) 1 = 1
When i = j:
n,j (xj ) = (xj xj )L2 (xj ) = 0.
H
n,j
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
Recall:
0,
1
if i 6= j
if i = j
1 of 2
n,j (xi ) = 0.
If follows that when i 6= j: Hn,j (xi ) = H
i
h
(
Hn,j (xj ) = 1 2(xj xj )Ln,j (xj ) 1 = 1
When i = j:
n,j (xj ) = (xj xj )L2 (xj ) = 0.
H
n,j
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
Recall:
0,
1
if i 6= j
if i = j
1 of 2
n,j (xi ) = 0.
If follows that when i 6= j: Hn,j (xi ) = H
i
h
(
Hn,j (xj ) = 1 2(xj xj )Ln,j (xj ) 1 = 1
When i = j:
n,j (xj ) = (xj xj )L2 (xj ) = 0.
H
n,j
=
=
[2Ln,j (xj )]L2n,j (x) + [1 2(x xj )Ln,j (xj )] 2Ln,j (x)Ln,j (x)
h
i
Ln,j (x) 2Ln,j (xj )Ln,j (x) + [1 2(x xj )Ln,j (xj )] 2(x)Ln,j
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
Recall:
0,
1
if i 6= j
if i = j
1 of 2
n,j (xi ) = 0.
If follows that when i 6= j: Hn,j (xi ) = H
i
h
(
Hn,j (xj ) = 1 2(xj xj )Ln,j (xj ) 1 = 1
When i = j:
n,j (xj ) = (xj xj )L2 (xj ) = 0.
H
n,j
=
=
[2Ln,j (xj )]L2n,j (x) + [1 2(x xj )Ln,j (xj )] 2Ln,j (x)Ln,j (x)
h
i
Ln,j (x) 2Ln,j (xj )Ln,j (x) + [1 2(x xj )Ln,j (xj )] 2(x)Ln,j
(x): H (x ) = 0 when i 6= j.
Since Ln,j (x) is a factor in Hn,j
n,j i
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
Proof, continued...
(x )
Hn,j
j
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
Proof, continued...
(x )
Hn,j
j
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
Proof, continued...
(x )
Hn,j
j
=
=
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
Proof, continued...
(x )
Hn,j
j
=
=
n,j
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
Proof, continued...
(x )
Hn,j
j
=
=
n,j
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
Uniqueness Proof
Assume there is a second polynomial G (x) (of degree
2n + 1) interpolating the same data.
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
Uniqueness Proof
Assume there is a second polynomial G (x) (of degree
2n + 1) interpolating the same data.
Define R(x) = H2n+1 (x) G (x).
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
Uniqueness Proof
Assume there is a second polynomial G (x) (of degree
2n + 1) interpolating the same data.
Define R(x) = H2n+1 (x) G (x).
Then by construction R(xi ) = R (xi ) = 0, i.e. all the xi s are
zeros of multiplicity at least 2.
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
Uniqueness Proof
Assume there is a second polynomial G (x) (of degree
2n + 1) interpolating the same data.
Define R(x) = H2n+1 (x) G (x).
Then by construction R(xi ) = R (xi ) = 0, i.e. all the xi s are
zeros of multiplicity at least 2.
Q
This can only be true if R(x) = q(x) ni=0 (x xi )2 , for some
q(x).
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
Uniqueness Proof
Assume there is a second polynomial G (x) (of degree
2n + 1) interpolating the same data.
Define R(x) = H2n+1 (x) G (x).
Then by construction R(xi ) = R (xi ) = 0, i.e. all the xi s are
zeros of multiplicity at least 2.
Q
This can only be true if R(x) = q(x) ni=0 (x xi )2 , for some
q(x).
If q(x) 6 0 then the degree of R(x) is 2n + 2, which is a
contradiction.
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
Uniqueness Proof
Assume there is a second polynomial G (x) (of degree
2n + 1) interpolating the same data.
Define R(x) = H2n+1 (x) G (x).
Then by construction R(xi ) = R (xi ) = 0, i.e. all the xi s are
zeros of multiplicity at least 2.
Q
This can only be true if R(x) = q(x) ni=0 (x xi )2 , for some
q(x).
If q(x) 6 0 then the degree of R(x) is 2n + 2, which is a
contradiction.
Hence q(x) 0 R(x) 0 H2n+1 (x) is unique.
Joe Mahaffy, hmahaffy@math.sdsu.edui
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
H3 (x0 ) = f (x0 )
H3 (x1 ) = f (x1 ).
=
+
0
1 + 2 xxx
1 x0
x
1 + 2 xx11x
0
ih
ih
x1 x
x1 x0
xx0
x1 x0
i2
i2
f (x0 ) + (x x0 )
f (x1 ) + (x x1 )
h
h
x1 x
x1 x0
xx0
x1 x0
i2
i2
f (x0 )
f (x1 ).
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
f [xi + ] f [xi ]
,
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
y
y0 = x0
f(x)
f [y0 ]
y1 = x0
f [y1 ]
y2 = x1
f [y2 ]
y3 = x1
f [y3 ]
y4 = x2
f [y4 ]
y5 = x2
f [y5 ]
y6 = x3
f [y6 ]
y7 = x3
f [y7 ]
y8 = x4
f [y8 ]
y9 = x4
f [y9 ]
f (y
f [y1 , y2 ]
f [y2 , y3 ] =
f (y
2)
f [y3 , y4 ]
f [y4 , y5 ] = f (y4 )
f [y5 , y6 ]
f [y6 , y7 ] =
f (y
6)
f [y7 , y8 ]
f [y8 , y9 ] =
f (y
8)
f [y0 , y1 , y2 ]
f [y1 , y2 , y3 ]
f [y2 , y3 , y4 ]
f [y3 , y4 , y5 ]
f [y4 , y5 , y6 ]
f [y5 , y6 , y7 ]
f [y6 , y7 , y8 ]
f [y7 , y8 , y9 ]
f [y0 , y1 , y2 , y3 ]
f [y1 , y2 , y3 , y4 ]
f [y2 , y3 , y4 , y5 ]
f [y3 , y4 , y5 , y6 ]
f [y4 , y5 , y6 , y7 ]
f [y5 , y6 , y7 , y8 ]
f [y6 , y7 , y8 , y9 ]
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
H3 (x) revisited...
Old notation
H3 (x)
=
+
ih
i2
ih
i2
h
x1 x
x1 x
xx0
0
1 + 2 xxx
f
(x
)
+
1
+
2
f (x1 )
0
x
x
x
x
x
x
x
1
0
1
0
1
0
1
0
i2
i2
h
h
x
0
f (x0 ) + (x x1 ) xxx
f (x1 ).
(x x0 ) xx11x
0
1 x0
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
H3 (x) Example
4
0.2
0.4
x0 = 0,
f (x0 ) = 0,
f (x0 ) = 4,
0.6
0.8
x1 = 1
f (x1 ) = 3,
f (x1 ) = 1
H3 (x) = 4x x 2 3x 2 (x 1)
Joe Mahaffy, hmahaffy@math.sdsu.edui
H3 (x) Example
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
Example
x0 = 0; x1 = 1;
fv0 = 0; fpv0 = 4;
fv1 = 3; fpv1 = -1;
y0
y1
y2
y3
=
=
=
=
x0;
x0;
x1;
x1;
f0=fv0;
f1=fv0;
f2=fv1;
f3=fv1;
f01 = fpv0;
f12 = (f2-f1)/(y2-y1);
f23 = fpv1;
f012 = (f12-f01)/(y2-y0);
f123 = (f23-f12)/(y3-y1);
f0123 = (f123-f012)/(y3-y0);
x=(0:0.01:1);
H3 = f0 + f01*(x-y0) + f012*(x-y0).*(x-y1) + ...
f0123*(x-y0).*(x-y1).* (x-y2);
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
Osculating Polynomials
Hermite Interpolatory Polynomials
Computing Hermite Interpolatory Polynomials
2n+1
k1
X
Y
qi
H2n+1 (x) = q0 +
(x yj ) .
k=1
j=0
1 of 3
1 of 3
2 of 3
f(x)
f [y0 ]
y1 = x0
f [y1 ]
y2 = x0
f [y2 ]
y3 = x1
f [y3 ]
y4 = x1
f [y4 ]
y5 = x1
f [y5 ]
3 of 3
f [y0 , y1 ] =
f (x
0)
f [y1 , y2 ] =
f (x
0)
f [y2 , y3 ]
f [y3 , y4 ] =
f (x
1)
f [y4 , y5 ] =
f (x
1)
f [y0 , y1 , y2 ] = 12 f (x0 )
f [y1 , y2 , y3 ]
f [y2 , y3 , y4 ]
f [y3 , y4 , y5 ] = 12 f (x1 )
f [y0 , y1 , y2 , y3 ]
f [y1 , y2 , y3 , y4 ]
f [y2 , y3 , y4 , y5 ]
Examples...
Osculating Polynomials
1
0.8
0.6
f(0) = +0.00
f(1) = 1.00
df(0) = +1.00
df(1) = 1.00
ddf(0) = +0.00
ddf(1) = +0.00
0.4
0.2
0
0.2
0.4
f(1) = +1.00
0.6
df(1) = +1.00
ddf(1) = +0.00
0.8
1
1
0.8
0.6
0.4
0.2
0.2
0.4
0.6
0.8
Examples...
Osculating Polynomials
1
0.8
0.6
f(0) = +0.00
f(1) = 1.00
df(0) = 1.00
df(1) = 1.00
ddf(0) = +0.00
ddf(1) = +0.00
0.4
0.2
0
0.2
0.4
f(1) = +1.00
0.6
df(1) = +1.00
ddf(1) = +0.00
0.8
1
1
0.8
0.6
0.4
0.2
0.2
0.4
0.6
0.8
Examples...
Osculating Polynomials
0.5
f(0) = +0.00
f(1) = 1.00
df(0) = +0.00
df(1) = +1.00
ddf(0) = +10.00
ddf(1) = +3.00
f(1) = +1.00
0.5
df(1) = +2.00
ddf(1) = 1.00
1
1
0.8
0.6
0.4
0.2
0.2
0.4
0.6
0.8
Examples...
Osculating Polynomials
1
0.8
0.6
f(0) = +0.00
f(1) = 1.00
df(0) = 1.00
df(1) = 1.00
ddf(0) = 10.00
ddf(1) = +10.00
0.4
0.2
0
0.2
0.4
f(1) = +1.00
0.6
df(1) = 1.00
ddf(1) = 10.00
0.8
1
1
0.8
0.6
0.4
0.2
0.2
0.4
0.6
0.8
Examples...
Osculating Polynomials
Osculating Polynomials
1
0.8
0.6
f(0) = +0.00
f(1) = 1.00
df(0) = +1.00
df(1) = 1.00
ddf(0) = +0.00
ddf(1) = +0.00
0.8
0.6
0.4
0.4
0.2
0.2
0.2
0.2
0.4
f(0) = +0.00
f(1) = 1.00
df(0) = 1.00
df(1) = 1.00
ddf(0) = +0.00
ddf(1) = +0.00
0.4
f(1) = +1.00
0.6
f(1) = +1.00
0.6
df(1) = +1.00
ddf(1) = +0.00
0.8
df(1) = +1.00
ddf(1) = +0.00
0.8
1
1
0.8
0.6
0.4
0.2
0.2
0.4
0.6
0.8
0.8
0.6
0.4
Osculating Polynomials
0.2
0.2
0.4
0.6
0.8
Osculating Polynomials
1
0.8
1
0.6
0.5
f(0) = +0.00
f(1) = 1.00
df(0) = +0.00
df(1) = +1.00
ddf(0) = +10.00
ddf(1) = +3.00
f(0) = +0.00
f(1) = 1.00
df(0) = 1.00
df(1) = 1.00
ddf(0) = 10.00
ddf(1) = +10.00
0.4
0.2
0
0.2
0.4
f(1) = +1.00
f(1) = +1.00
0.5
0.6
df(1) = 1.00
df(1) = +2.00
ddf(1) = 10.00
0.8
ddf(1) = 1.00
1
1
1
0.8
0.6
0.4
0.2
0.2
0.4
0.6
0.8
0.8
0.6
0.4
0.2
0.2
0.4
0.6
0.8