100% found this document useful (3 votes)
3K views18 pages

PDF

1) The document is a tutorial on polynomial interpolation that provides examples of using Newton's and Lagrange interpolation polynomials. 2) In one example, the interpolation polynomials of orders 1 through 3 are used to estimate the value of f(2.8) for a given data set, and the errors are estimated. 3) In another example, interpolation polynomials of orders 1 through 4 are used to estimate f(4) for a different data set, and the results indicate the data was generated by a cubic polynomial.

Uploaded by

mage kieloi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
3K views18 pages

PDF

1) The document is a tutorial on polynomial interpolation that provides examples of using Newton's and Lagrange interpolation polynomials. 2) In one example, the interpolation polynomials of orders 1 through 3 are used to estimate the value of f(2.8) for a given data set, and the errors are estimated. 3) In another example, interpolation polynomials of orders 1 through 4 are used to estimate f(4) for a different data set, and the results indicate the data was generated by a cubic polynomial.

Uploaded by

mage kieloi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

CV2019

Matrix Algebra and Computational Methods

Tutorial 6 – Interpolation

1
General Form of Polynomial Interpolation (1)

2
General Form of Polynomial Interpolation (2)

3
T6 – Q1

Given the data

x 1.6 2 2.5 3.2 4 4.5


f(x) 2 8 14 15 8 2

(a) Calculate f(2.8) using Newton’s interpolating polynomials of order


1 through 3. Choose the sequence of points for your estimates to
attain the best possible accuracy.

(b) Utilize Eq. (18.18) to estimate the error for each prediction.

Rn ≈ f [ x n +1, x n , x n −1,L, x1, x0 ]( x − x0 )( x − x1)L ( x − x n ) (18.18)

4
T6-Q1

First, order the points so that they are as close to and as centered
about the unknown as possible
x0 = 2.5 f ( x0 ) = 14
x1 = 3.2 f ( x1 ) = 15
x2 = 2 f ( x2 ) = 8
x3 = 4 f ( x3 ) = 8
x4 = 1 . 6 f ( x4 ) = 2
Next, the divided differences can be computed and displayed in the
format of Fig. 18.5,

5
1st divided difference 2nd divided difference
15 − 14
f [ x0 , x1 ] = = 1.428571
3.2 − 2.5 5.83333 − 1.428571
f [ x0 , x1 , x2 ] = = −8.809524
2 − 2.5
8 − 15
f [ x1 , x2 ] = = 5.833333
2 − 3.2
0 − 5.833333
f [ x1 , x2 , x3 ] = = −7.291667
4 − 3.2
8−8
f [ x2 , x3 ] = =0
4−2

2−8
f [ x3 , x4 ] = = 2.5
1.6 − 4

3rd divided difference


− 7.291667 + 8.809524
f [ x0 , x1 , x2 , x3 ] = = −1.011905
4 − 2 .5 6
T6-Q1

The first through third-order interpolations can then be implemented as


f1 ( 2.8) = 14 + 1.428571( 2.8 − 2.5) = 14.428571
f 2 ( 2.8) = 14 + 1.428571(2.8 − 2.5) − 8.809524 ( 2.8 − 2.5)(2.8 − 3.2) = 15.485714
f 3 ( 2.8) = 14 + 1.428571( 2.8 − 2.5) − 8.809524 (2.8 − 2.5)(2.8 − 3.2)
+ 1.011905( 2.8 − 2.5)( 2.8 − 3.2)( 2.8 − 2.) = 15.388571
The errors estimates for the first and second-order predictions can be
computed with Eq. 18.19 Rn = f n+1 ( x) − f n ( x) as
R1 = 15.485714 − 14.428571 = 1.057143
R2 = 15.388571 − 15.485714 = −0.097143
The error for the third-order prediction can be computed with Eq. 18.18 as
R3 = 1.847718 ( 2.8 − 2.5)( 2.8 − 3.2)( 2.8 − 2)( 2.8 − 4) = 0.212857
7
T6-Q2

Given the data

x 1 2 3 5 7 8
f(x) 3 6 19 99 291 444

Calculate f(4) using Newton’s interpolating polynomials of


order 1 through 4. Choose your base points to attain good
accuracy.

What do your results indicate regarding the order of the


polynomial used to generate the data in the table?

8
T6-Q2

First, order the points so that they are as close to and as centered
about the unknown as possible
x0 = 3 f ( x0 ) = 19
x1 = 5 f ( x1 ) = 99
x2 = 2 f ( x2 ) = 6
x3 = 7 f ( x3 ) = 291
x4 = 1 f ( x4 ) = 3

Next, the divided differences can be computed and displayed in the


format of Fig. 18.5,

9
T6 – Q2

The first through fourth‐order interpolations can then be 
implemented as 

f1 (4) = 19 + 40(4 − 3) = 59
f 2 (4) = 59 + 9(4 − 3)(4 − 5) = 50
f 3 (4) = 50 + 1(4 − 3)(4 − 5)(4 − 2) = 48
f 4 (4) = 48 + 0(4 − 3)(4 − 5)(4 − 2)(4 − 7) = 48

Clearly the data was generated with a cubic polynomial since the 
difference between the 4th and the 3rd‐order versions is zero.

10
T6‐Q3: Lagrange Interpolating Polynomial

(Q3) Repeat T6‐Q2 using Lagrange Polynomial

Given the data 

x 1 2 3 5 7 8
f(x) 3 6 19 99 291 444

11
T6-Q3: Lagrange Interpolating Polynomial

The data points are chosen and ordered in the same way as that used
in the Newton’s polynomial, i.e. based on proximity to the target x=4.

i xi f(xi)
0 3 19
1 5 99
2 2 6
3 7 291
4 1 3

12
T6‐Q3: Lagrange Interpolating Polynomial
n
fn ( x) = ∑ L (x) f (x )
i=0
i i

n
x − xj
where: Li ( x ) = ∏ j=0 xi − x j
Π denotes the “product of”.
j≠i

For example, the 2nd order Lagrange Polynomial is:


( x − x1 )( x − x2 ) 2nd-order polynomial requires 3
f2 ( x) = f ( x0 )
( x0 − x1 )( x0 − x2 ) [x, f(x)] data points.
( x − x0 )( x − x2 )
+ f ( x1 ) In general, nth-order polynomial
( x1 − x0 )( x1 − x2 )
requires (n+1) data pairs.
( x − x0 )( x − x1 )
+ f ( x2 )
( x2 − x0 )( x2 − x1 )

The Lagrange polynomial gives exactly the same interpolated result as


the Newton’s polynomial. It is simple to code as it does not requires the
computation of divided differences.
13
T6-Q3: Lagrange Interpolating Polynomial

The results for the Lagrange Polynomial of the 1st to 4 order are as
follow: f ( x) =
( x − x )( x − x ) 1 2
f ( x0 )
( x0 − x1 )( x0 − x2 )
2

(4 − 5) ( 4 − 3) ( x − x0 )( x − x2 )
f1 (4) = 19 + 99 = 59 +
( x1 − x0 )( x1 − x2 )
f ( x1 )

(3 − 5) (5 − 3) +
( x − x0 )( x − x1 )
f ( x2 )
( x2 − x0 )( x2 − x1 )

( 4 − 5)( 4 − 2) (4 − 3)( 4 − 2) ( 4 − 3)( 4 − 5)


f 2 ( 4) = 19 + 99 + 6 = 50
(3 − 5)(3 − 2) (5 − 3)(5 − 2) ( 2 − 3)( 2 − 5)
i xi f(xi)
0 3 19
( 4 − 5)( 4 − 2)( 4 − 7) ( 4 − 3)( 4 − 2)( 4 − 7)
f 3 ( 4) = 19 + 99 1 5 99
(3 − 5)(3 − 2)(3 − 7) (5 − 3)(5 − 2)(5 − 7) 2 2 6
( 4 − 3)( 4 − 5)( 4 − 7) ( 4 − 3)( 4 − 5)( 4 − 2) 3 7 291
+ 6+ 291 = 48
( 2 − 3)( 2 − 5)( 2 − 7) (7 − 3)(7 − 5)(7 − 2) 4 1 3

14
T6-Q3: Lagrange Interpolating Polynomial

( 4 − 5)( 4 − 2)( 4 − 7)( 4 − 1) ( 4 − 3)( 4 − 2)( 4 − 7)( 4 − 1)


f 4 ( 4) = 19 + 99
(3 − 5)(3 − 2)(3 − 7)(3 − 1) (5 − 3)(5 − 2)(5 − 7)(5 − 1)
( 4 − 3)( 4 − 5)( 4 − 7)( 4 − 1) ( 4 − 3)( 4 − 5)( 4 − 2)( 4 − 1)
+ 6+ 291
( 2 − 3)( 2 − 5)( 2 − 7)( 2 − 1) (7 − 3)(7 − 5)(7 − 2)(7 − 1)
( 4 − 3)( 4 − 5)( 4 − 2)( 4 − 7)
+ 3 = 48
(1 − 3)(1 − 5)(1 − 2)(1 − 7)
i xi f(xi)
0 3 19
1 5 99
2 2 6
3 7 291
4 1 3

15
T6 – Q4

Employ a cubic interpolating polynomial and Bisection to determine the


value of x that corresponds to f(x) = 0.23 for the following tabulated
data:

x 2 3 4 5 6 7
f(x) 0.5 0.3333 0.25 0.2 0.167 0.1429

16
T6 – Q4

The following points are used to generate a cubic interpolating


polynomial
x0 = 3 f ( x0 ) = 0.3333
x1 = 4 f ( x1 ) = 0.25
x2 = 5 f ( x2 ) = 0.2
x3 = 6 f ( x3 ) = 0.1667

The polynomial can be generated in a number of ways including


simultaneous equations (Eq. 18.26) or a software tool. The result is
f 3 ( x ) = 0.943 − 0.3261833 x + 0.0491x 2 − 0.00271667 x 3
The roots problem can then be developed by setting this polynomial
equal to the desired value of 0.23
0 = 0.713 − 0.3261833 x + 0.0491x 2 − 0.00271667 x 3
17
T6 – Q4

Bisection can then be used to determine the root. Using initial guesses
of xl = 4 and xu = 5, the first five iterations are

i xl xu xr f(xl) f(ri) f(xl) f(xr) εa


1 4.00000 5.00000 4.50000 0.02000 ‐0.00811 ‐0.00016 11.11%
2 4.00000 4.50000 4.25000 0.02000 0.00504 0.00010 5.88%
3 4.25000 4.50000 4.37500 0.00504 ‐0.00174 ‐0.00001 2.86%
4 4.25000 4.37500 4.31250 0.00504 0.00160 0.00001 1.45%
5 4.31250 4.37500 4.34375 0.00160 ‐0.00009 0.00000 0.72%

If the iterations are continued, the final result is


x = 4.34213.

18

You might also like