18.1 - Newton's Divided-Difference Interpolating

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 23

Sec:18.

NEWTON’S DIVIDED-
DIFFERENCE
INTERPOLATING
POLYNOMIALS
Sec:18.1 NEWTON’S DIVIDED-DIFFERENCE INTERPOLATING POLYNOMIALS

How many lines passes through How many parabola passes


these two points ? through these three points ?

How many polynomial of


degree one passes
through these two points ?
How many polynomial of degree two
there is one and only one polynomial of passes through these three points ?
order n that passes through
all the points.

…… Polynomial interpolation consists of


determining the unique nth-order
polynomial that fits n + 1 data points.
How many polynomial of degree n
passes through these (n+1) points ?
Sec:18.1 NEWTON’S DIVIDED-DIFFERENCE INTERPOLATING POLYNOMIALS

…… Polynomial interpolation consists of


determining the unique nth-order
polynomial that fits n + 1 data points.
How many polynomial of degree n
passes through these (n+1) points ?

Applications
X Y X f(x)
Sometimes we need to estimate intermediate 2.1 99.0 x1 f(x1)
values between precise data points.
3.7 23.56 x2 f(x2)

Sometimes we need to a function by nth-order … … … …


polynomial 35.6 22.12 xn f(xn)
Sec:18.1 NEWTON’S DIVIDED-DIFFERENCE INTERPOLATING POLYNOMIALS

Linear Interpolation Example

Estimate the natural logarithm of 2


(𝑥 ¿ ¿ 0 , 𝑓 ( 𝑥 0 ) )¿ using linear interpolation. First,
𝑓 (𝑥 ) perform the computation by
interpolating between ln 1 = 0 and
ln 6 = 1.791759.

(𝑥 ¿ ¿ 1 , 𝑓 ( 𝑥 1 ) )¿

𝑓 ( 𝑥1 ) − 𝑓 ( 𝑥 0 ) 𝑝1 ( 2 ) − 𝑙𝑛 ( 1 ) 𝑙𝑛 ( 6 ) − 𝑙𝑛 ( 1 )
=
𝑝 1 ( 𝑥 )=
𝑥1− 𝑥0
( 𝒙 − 𝑥0)+ 𝒇 ( 𝑥0) 2 −1 6 −1

𝑝1 ( 𝑥 ) − 𝑓 ( 𝑥 0 ) 𝑓 ( 𝑥1 ) − 𝑓 ( 𝑥 0 ) 𝑝1 ( 2 ) 1 . 791759
= =
1 5
𝑥 − 𝑥0 𝑥1− 𝑥0
= 0.3583519
The notation designates that this is a
first order interpolating polynomial.
Sec:18.1 NEWTON’S DIVIDED-DIFFERENCE INTERPOLATING POLYNOMIALS

Quadratic Interpolation 𝑓 (𝑥 )
(𝑥 ¿ ¿ 0 , 𝑓 ( 𝑥 0 ) )¿

(𝑥 ¿ ¿ 2 , 𝑓 ( 𝑥 2 ) )¿

(𝑥 ¿ ¿ 1 , 𝑓 ( 𝑥 1 ) )¿

A particularly convenient form


𝑝 2 ( 𝑥 )= 𝒃𝟎 + 𝒃𝟏 ( 𝒙 − 𝑥 0 ) + 𝒃𝟐 ( 𝒙 − 𝑥 0 ) ( 𝒙 − 𝑥 1 )

𝒃 𝟎= 𝒇 ( 𝑥 0 )
𝑝 2 ( 𝑥0 ) = 𝑓 ( 𝑥 0 )
𝑓 ( 𝑥1 ) − 𝑓 ( 𝑥0 )
𝑝 2 ( 𝑥1 ) = 𝑓 ( 𝑥1 ) 𝒃 𝟏=
𝑥1 − 𝑥 0

𝑝 2 ( 𝑥2 ) = 𝑓 ( 𝑥 2 ) 𝑓 ( 𝑥 2 ) − 𝑓 ( 𝑥2 ) 𝑓 ( 𝑥1) − 𝑓 ( 𝑥0)

𝑥 2 − 𝑥1 𝑥1 − 𝑥 0
𝒃 𝟐=
𝑥2 − 𝑥0
Sec:18.1 NEWTON’S DIVIDED-DIFFERENCE INTERPOLATING POLYNOMIALS

A particularly convenient form


𝑝 2 ( 𝑥 )= 𝒃𝟎 + 𝒃𝟏 ( 𝒙 − 𝑥 0 ) + 𝒃𝟐 ( 𝒙 − 𝑥 0 ) ( 𝒙 − 𝑥 1 )

finite divided differences


𝒃 𝟎= 𝒇 ( 𝑥 0 ) 𝒃 𝟎 = 𝒇 [ 𝑥0 ]
𝑓 ( 𝑥1) − 𝑓 ( 𝑥0)
𝒃 𝟏= 𝒃 𝟏 = 𝒇 [ 𝑥1 , 𝑥 0 ]
𝑥1 − 𝑥 0
𝑓 ( 𝑥 2 ) − 𝑓 ( 𝑥1 ) 𝑓 ( 𝑥1) − 𝑓 ( 𝑥0)
− 𝒃 𝟐 = 𝒇 [ 𝑥2 , 𝑥 1 , 𝑥 0 ]
𝑥 2 − 𝑥1 𝑥1 − 𝑥 0
𝒃 𝟐=
𝑥 2 − 𝑥0
Definition:

𝑓 [ 𝑥 𝑛 , 𝑥𝑛 − 1 , ⋯ , 𝑥 1 ] − 𝑓 [ 𝑥 𝑛 −1 , ⋯ , 𝑥 1 , 𝑥0 ]
𝑓 [ 𝑥 𝑛 , 𝑥𝑛 − 1 , ⋯ , 𝑥 1 , 𝑥 0 ] =
𝑥 𝑛 − 𝑥0
Sec:18.1 NEWTON’S DIVIDED-DIFFERENCE INTERPOLATING POLYNOMIALS

Definition:
= second finite divided difference

𝑓 [ 𝑥 𝑛 , 𝑥𝑛 − 1 , ⋯ , 𝑥 1 ] − 𝑓 [ 𝑥 𝑛 −1 , ⋯ , 𝑥 1 , 𝑥0 ]
𝑓 [ 𝑥 𝑛 , 𝑥𝑛 − 1 , ⋯ , 𝑥 1 , 𝑥 0 ] =
𝑥 𝑛 − 𝑥0
nth finite divided difference

A polynomial of order 2 that passes through the three points

)), )), )).

𝑝 2 ( 𝑥 )= 𝒃𝟎 + 𝒃𝟏 ( 𝒙 − 𝑥 0 ) + 𝒃𝟐 ( 𝒙 − 𝑥 0 ) ( 𝒙 − 𝑥 1 )

𝑝 2 ( 𝑥 )= 𝒇 [ 𝒙 𝟎 ]+ 𝒇 [ 𝒙 𝟏 , 𝒙 𝟎] ( 𝒙 − 𝑥 0 ) + 𝒇 [ 𝒙 𝟐 , 𝒙 𝟏 , 𝒙 𝟎] ( 𝒙 − 𝑥 0 ) ( 𝒙 − 𝑥 1 )
Sec:18.1 NEWTON’S DIVIDED-DIFFERENCE INTERPOLATING POLYNOMIALS

Example
Fit a second-order polynomial to the three points

1= 1=
2= 8=
4= 14=

𝒇 [ 𝒙𝟏 ] − 𝒇 [ 𝒙 𝟎 ] 𝟖 −𝟏
𝒇 [ 𝒙𝟏 , 𝒙 𝟎 ]= = =𝟕
𝒙𝟏 − 𝒙 𝟎 𝟐 −𝟏
𝒇 [ 𝒙𝟐 , 𝒙 𝟏 ] − 𝒇 [ 𝒙 𝟏 , 𝒙 𝟎 ] 𝟑− 𝟕 𝟒
𝒇 [ 𝒙𝟐 , 𝒙 𝟏 , 𝒙 𝟎 ]= = =−
𝒙𝟐− 𝒙𝟎 𝟒 −𝟏 𝟑
𝒇 [ 𝒙 𝟐 ] − 𝒇 [ 𝒙 𝟏 ] 𝟏𝟒 −𝟖
𝒇 [ 𝒙𝟐 , 𝒙 𝟏 ]= = =𝟑
𝒙𝟐 − 𝒙𝟏 𝟒 −𝟐

𝑝 2 ( 𝑥 )= 𝒇 [ 𝒙 𝟎 ]+ 𝒇 [ 𝒙 𝟏 , 𝒙 𝟎] ( 𝒙 − 𝑥 0 ) + 𝒇 [ 𝒙 𝟐 , 𝒙 𝟏 , 𝒙 𝟎] ( 𝒙 − 𝑥 0 ) ( 𝒙 − 𝑥 1 )

𝟒
𝑝 2 ( 𝑥 )=𝟏 +𝟕 ( 𝒙 − 1 ) − ( 𝒙 −1) ( 𝒙 −2)
𝟑
Sec:18.1 NEWTON’S DIVIDED-DIFFERENCE INTERPOLATING POLYNOMIALS

Definition: = second finite divided difference

𝑓 [ 𝑥 𝑛 , 𝑥𝑛 − 1 , ⋯ , 𝑥 1 ] − 𝑓 [ 𝑥 𝑛 −1 , ⋯ , 𝑥 1 , 𝑥0 ]
𝑓 [ 𝑥 𝑛 , 𝑥𝑛 − 1 , ⋯ , 𝑥 1 , 𝑥 0 ] =
𝑥 𝑛 − 𝑥0
nth finite divided difference

General Form of Newton’s Interpolating Polynomials

A polynomial of order n that passes through the (n+1) points

)), )), )).


Sec:18.1 NEWTON’S DIVIDED-DIFFERENCE INTERPOLATING POLYNOMIALS

notice how divided differences are recursive that is, higher-order differences are
computed by taking differences of lower-order differences.
Sec:18.1 NEWTON’S DIVIDED-DIFFERENCE INTERPOLATING POLYNOMIALS

Example
1 3 Calculate f (4) using Newton’s
Given the data 2 6 interpolating polynomials of
3 19 order 1 through 3.
5 99

First Second Third


1 3
2 6
3 19
5 99
Sec:18.1 NEWTON’S DIVIDED-DIFFERENCE INTERPOLATING POLYNOMIALS

Example
1 3 Calculate f (4) using Newton’s
Given the data 2 6 interpolating polynomials of
3 19 order 1 through 3.
5 99

First Second Third


1 3 3 5 1
2 6 13 9
3 19 40
5 99

𝒑 𝟏 ( 𝒙 ) =𝟑+𝟑 ( 𝒙 −𝟏) 𝒑 𝟏 ( 𝟒 ) =𝟏𝟐

𝒑 𝟐 ( 𝒙 ) =𝟑+𝟑 ( 𝒙 − 𝟏 ) +𝟓( 𝒙 −𝟏)( 𝒙 − 𝟐) 𝒑 𝟐 ( 𝟒 ) =𝟒𝟐

𝒑 𝟑 ( 𝒙 ) =𝟑+𝟑 ( 𝒙 − 𝟏 ) +𝟓 ( 𝒙 −𝟏 )( 𝒙 − 𝟐 ) +( 𝒙 −𝟏)( 𝒙 − 𝟐)( 𝒙 −𝟑) 𝒑 𝟑 ( 𝟒 ) =𝟒𝟖


Sec:18.1 NEWTON’S DIVIDED-DIFFERENCE INTERPOLATING POLYNOMIALS

Example
x f (x)
Complete the divided difference table for 1.0 0.7651977
the data given in the adjacent Table and 1.3 0.6200860
construct the interpolating polynomial that 1.6 0.4554022
1.9 0.2818186
uses all this data. 2.2 0.1103623

𝒊 𝒙 𝒊 𝒇 [ 𝒙𝒊 ] First Second Third Fourth

0 1.0 0.7651977 0.4837057− 0.1087339− 0.0658784 0.0018251

1 1.3 0.6200860 0.5489460− 0.0494433− 0.0680685

2 1.6 0.4554022 0.5786120− 0.0118183

3 1.9 0.2818186 0.5715210−

4 2.2 0.1103623

The coefficients of the Newton forward divided-difference form of the interpolating


polynomial are along the first row in the table.
Sec:18.1 NEWTON’S DIVIDED-DIFFERENCE INTERPOLATING POLYNOMIALS

𝒊 𝒙 𝒊 𝒇 [ 𝒙𝒊 ] First Second Third Fourth

0 1.0 0.7651977 0.4837057− 0.1087339− 0.0658784 0.0018251

1 1.3 0.6200860 0.5489460− 0.0494433− 0.0680685

2 1.6 0.4554022 0.5786120− 0.0118183

3 1.9 0.2818186 0.5715210−

4 2.2 0.1103623

Remark Remark Remark


The coefficients of the Newton The poly of degree 1 for If poly of degree 5 is
forward divided-difference (1.0.7651977) and (1.3,0.6200860) needed, then just complete
form of the interpolating the diagonal .
polynomial are along the first 𝒑 𝟒( 𝒙)=𝟎.𝟕𝟔𝟓𝟏𝟗𝟕𝟕 − 𝟎.𝟒𝟖𝟑𝟕𝟎𝟓𝟕 ( 𝒙 −𝟏.𝟎 )
row in the table.
Sec:18.1 NEWTON’S DIVIDED-DIFFERENCE INTERPOLATING POLYNOMIALS

data=[1.0 0.7651977;
function [d]=Divided_diff(x,y) 1.3 0.6200860;
d=y; 1.6 0.4554022;
n=length(x); 1.9 0.2818186;
for j=2:n 2.2 0.1103623];
for k=n:-1:j
d(k)=(d(k)-d(k-1))/(x(k)-x(k-j+1)); x =data(:,1);
end y=data(:,2);
end [d]=Divided_diff(x,y);
d

𝒊 𝒙 𝒊 𝒇 [ 𝒙𝒊 ] First Second Third Fourth

0 1.0 0.7651977 0.4837057− 0.1087339− 0.0658784 0.0018251

1 1.3 0.6200860 0.5489460− 0.0494433− 0.0680685

2 1.6 0.4554022 0.5786120− 0.0118183

3 1.9 0.2818186 0.5715210−

4 2.2 0.1103623
Sec:18.1 NEWTON’S DIVIDED-DIFFERENCE INTERPOLATING POLYNOMIALS

Example
1 3 Write the Newton’s
Given the data 2 6 interpolating polynomials of
3 19 order 4.
5 99
7 291

First Second Third Fourth


1 3
2 6
3 19
5 99
7 291
Sec:18.1 NEWTON’S DIVIDED-DIFFERENCE INTERPOLATING POLYNOMIALS

Example
1 3 Write the Newton’s
Given the data 2 6 interpolating polynomials of
3 19 order 4.
5 99
7 291

First Second Third Fourth


1 3 3 5 1 0
2 6 13 9 1
3 19 40 14
5 99 96
7 291
Sec:18.1 NEWTON’S DIVIDED-DIFFERENCE INTERPOLATING POLYNOMIALS

Example x=[8 9 11 12];


Problem 18.2 pp522
y=log10(x); 0.9031
Fit a third-order Newton’s 0.0512
interpolating polynomial to [d]=Divided_diff(x,y); -0.0025
estimate log(10) using the data d 0.0001
[yi] = eval_poly(x,d,10)
at x = 8, 9, 11 and 12. Compute
Rel_err = (yi-1)/1*100
the true percent relative error.
𝒙𝒊 𝒇 (𝒙¿¿𝒊)¿ function [yi] = eval_poly(x,d,xi)
yi = d(1);
8 0.9031 prod = 1;
9 0.9542 n = length(d);
for k=1:n-1
11 1.0414 prod=prod*(xi-x(k))
12 1.0792 yi=yi+d(k+1)*prod;
end

𝒑 𝟑 (𝟏𝟎)=1 .000044924225105
True percent relative error = 0.0045%
Sec:18.1 NEWTON’S DIVIDED-DIFFERENCE INTERPOLATING POLYNOMIALS

Example
Problem 18.2 pp522 x=[0 pi/2 pi 3*pi/2 2*pi];
y=sin(x);
Fit a 4th-order Newton’s [d]=Divided_diff(x,y);
interpolating polynomial to xx=[0:0.1:2*pi];
approximate sin(x) using the [yy] = eval_poly(x,d,xx);
data at x = 0, pi/2, pi, 3*pi/2 and ezplot('sin(x)',[0,2*pi]); grid on; hold on
2*pi. Plot sin(x) and . plot(xx,yy); plot(x,y,'k*'); hold off

𝒚 =𝐬𝐢𝐧 ⁡( 𝒙)

𝒑 𝟒( 𝒙)
Sec:18.1 NEWTON’S DIVIDED-DIFFERENCE INTERPOLATING POLYNOMIALS

Errors of Newton’s Interpolating Polynomials

𝑝 𝑛 ( 𝑥 ) = 𝒇 [ 𝒙 𝟎 ] + 𝒇 [ 𝒙 𝟏 , 𝒙 𝟎 ] ( 𝒙 − 𝑥 0 ) + ⋯ + 𝒇 [ 𝒙 𝒏 , ⋯ , 𝒙 𝟎 ] ( 𝒙 − 𝑥 0 ) ⋯ ( 𝒙 − 𝑥 𝑛 −1 )

𝑓 ( 𝑥 ) −𝑝 𝑛 ( 𝑥 ) = 𝑹𝒏 ( 𝒙 ) ( 𝑛+ 1 )
𝑓 (𝜉 )
𝑹 𝒏 ( 𝑥)=
(𝑛+1) !
( 𝒙 − 𝑥0 ) ⋯ ( 𝒙 − 𝑥𝑛)

The structure is similar to the Taylor series expansion in the sense that
terms are added sequentially to capture the higher-order behavior.

( 𝒏 +𝟏 )
Taylor series 𝒇 (𝝃 )
𝑹 𝒏 ,𝑻𝒂𝒚𝒍𝒐𝒓 = ( 𝒙 − 𝒙 𝒊 ) 𝒏+𝟏
(𝒏+𝟏) !
𝒇 ′ ( 𝒙𝒊) 𝒇 ( 𝒏) ( 𝒙 𝒊 )
𝒇 ( 𝒙 ) = 𝒇 ( 𝒙𝒊 ) + ( 𝒙 − 𝒙 𝒊 ) +… + ( 𝒙 − 𝒙 𝒊 )𝒏 + 𝑹𝒏 , 𝑻𝒂𝒚𝒍𝒐𝒓
𝟏! 𝒏!
Sec:18.1 NEWTON’S DIVIDED-DIFFERENCE INTERPOLATING POLYNOMIALS

Errors of Newton’s Interpolating Polynomials

𝑝 𝑛 ( 𝑥 ) = 𝒇 [ 𝒙 𝟎 ] + 𝒇 [ 𝒙 𝟏 , 𝒙 𝟎 ] ( 𝒙 − 𝑥 0 ) + ⋯ + 𝒇 [ 𝒙 𝒏 , ⋯ , 𝒙 𝟎 ] ( 𝒙 − 𝑥 0 ) ⋯ ( 𝒙 − 𝑥 𝑛 −1 )

𝑓 ( 𝑥 ) =𝑝 𝑛 ( 𝑥 ) + 𝑹 𝒏 ( 𝒙 )
( 𝑛 +1 )
𝑓 (𝜉 )
𝑹 𝒏 ( 𝒙 )=
(𝑛+ 1) !
( 𝒙 − 𝑥0 ) ⋯ ( 𝒙 − 𝑥𝑛 )

For an nth-order interpolating polynomial,


an alternative relationship for the error is

𝑹 𝒏 ( 𝒙 )= 𝒇 [ 𝒙 , 𝒙 𝒏 , ⋯ , 𝒙 𝟎 ] ( 𝒙 − 𝑥 0 ) ⋯ ( 𝒙 − 𝑥 𝑛 )
Sec:18.1 NEWTON’S DIVIDED-DIFFERENCE INTERPOLATING POLYNOMIALS

nth-order error is𝑹 𝒏 ( 𝒙 )= 𝒇 [ 𝒙 , 𝒙𝒏 , ⋯ , 𝒙 𝟎 ] ( 𝒙 − 𝑥 0 ) ⋯ ( 𝒙 − 𝑥 𝑛 )


Example
Problem 18.2 pp522
+
Fit a second-order Newton’s
interpolating polynomial to True error = - 3.434e-04
estimate log(10) using the data
at x = 8, 9, and 11. Compute the 𝑹 𝟐( 𝒙 )= 𝒇 [ 𝒙 , 𝒙 𝟐 , 𝒙 𝟏 , 𝒙 𝟎 ] ( 𝒙 − 𝒙 𝟎 ) ( 𝒙 − 𝒙 𝟏) ( 𝒙 − 𝒙 𝟐 )
true error. 𝒙 𝒇 (𝒙¿¿𝒊)¿ 𝑹 𝟐( 𝟏𝟎)= 𝒇 [ 𝟏𝟎 , 𝟏𝟏 , 𝟗 ,𝟖 ] ( 𝟏𝟎 −𝟖 ) (𝟏𝟎 − 𝟗) ( 𝟏𝟎 −𝟏𝟏 )
𝒊
(*)
8 0.9031 𝑹 𝟐 ( 𝟏𝟎 ) =𝟎 . 𝟎𝟎𝟎𝟏𝟕𝟏𝟕 ( 𝟏𝟎 −𝟖 ) ( 𝟏𝟎 −𝟗) (𝟏𝟎 − 𝟏𝟏 )
9 0.9542 (10) = -3.434e-04
11 1.0414
12 1.0792

x=[8 9 11]; Because (*) contains the unknown f (10), it cannot be solved
y=log10(x); for the error. However, if an additional data point f () is
0.9031 available, (*) can be used to estimate the error, as in
[d]=Divided_diff(x,y); 0.0512
[yi] = eval_poly(x,d,10) -0.0025
err = yi-1 𝑹 𝟐( 𝟏𝟎)≈ 𝒇 [ 𝟏𝟐 , 𝟏𝟏 , 𝟗 ,𝟖 ] ( 𝟏𝟎 −𝟖 ) (𝟏𝟎 − 𝟗) ( 𝟏𝟎 − 𝟏𝟏 )
𝑹 𝟐 ( 𝟏𝟎 ) ≈ 𝟏 . 𝟒𝟗 𝒆 −𝟒 (𝟏𝟎 − 𝟖 ) (𝟏𝟎 − 𝟗) ( 𝟏𝟎 −𝟏𝟏 )

-2.985e-04
Sec:18.1 NEWTON’S DIVIDED-DIFFERENCE INTERPOLATING POLYNOMIALS

Notation

𝑹 𝒏 ( 𝒙 )= 𝒇 [ 𝒙 , 𝒙 𝒏 , ⋯ , 𝒙 𝟎 ] ( 𝒙 − 𝑥 0 ) ( 𝒙 − 𝑥 1) ⋯ ( 𝒙 − 𝑥 𝑛 − 1) ( 𝒙 − 𝑥 𝑛 )

𝒏 ( 𝒙 )= 𝒇 [ 𝒙 , 𝒙 𝒏 , ⋯ , 𝒙 𝟎 ] ∏ ( 𝒙 − 𝑥 𝑗 )
𝒋=𝟎

You might also like