0% found this document useful (0 votes)
252 views59 pages

(Ch4) - Interpolation-Material

The document discusses Lagrange polynomial interpolation. It provides examples of calculating the Lagrange interpolating polynomial for different data sets with 2-4 points. For the example of interpolating between points (2,7.2) and (4.25, 7.1), the Lagrange interpolating polynomial is calculated to be L0(x)f(x0) + L1(x)f(x1). This is evaluated at x=4 to find the corresponding y-value, which is 7.15.

Uploaded by

Sky Fire
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
252 views59 pages

(Ch4) - Interpolation-Material

The document discusses Lagrange polynomial interpolation. It provides examples of calculating the Lagrange interpolating polynomial for different data sets with 2-4 points. For the example of interpolating between points (2,7.2) and (4.25, 7.1), the Lagrange interpolating polynomial is calculated to be L0(x)f(x0) + L1(x)f(x1). This is evaluated at x=4 to find the corresponding y-value, which is 7.15.

Uploaded by

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

Chapter 4: Interpolation

1. Polynomial Interpolation.
• Lagrange Interpolation.
• Newton’s divided difference method
2. Natural Cubic Spline Interpolation
Why need interpolation?
This called as linear interpolation
General Form of Lagrange

for
  i=0,1,2,3 …n

n = number of interval/number of degree interpolating


polynomial
 n=3,
If
f3(x)=L0(x)f(x0) + L1(x)f(x1)+ L2(x)f(x2)+
L3(x)f(x3)

L0(x)=, 

L1(x)=

L2(x)=

L3(x)=
Example 1
a)Find the Lagrange interpolating polynomial for
data f(0) = 1, f(2)= -1, f(4)= -1 and f(6)= 1.
b)Hence evaluate f(3), f(5) and f(6.5) if applicable.

Solution;
i 0 1 2 3

xi 0 2 4 6

f(xi) 1 -1 -1 1
Lagrange polynomial; given i=0,1,2,3
Pn ( x)  L0 ( x) f ( x0 )  L1 ( x) f ( x1 )  L2 ( x) f ( x2 )  L3 ( x) f ( x3 )

a) Find L0(x), L1(x), …. L3(x),

L0 ( x) 
 x  x1  x  x2  x  x3 
 x0  x1  x0  x2  x0  x3 

L1 ( x) 
 x  x0  x  x2  x  x3 
 x1  x0  x1  x2  x1  x3 
L2 ( x) 
 x  x0  x  x1  x  x3 
 x2  x0  x2  x1  x2  x3 

L3 ( x) 
 x  x0  x  x1  x  x2 
 x3  x0  x3  x1  x3  x2 
L0 ( x ) 
 x  x1  x  x2  x  x3 

 x  2  x  4  x  6 
 x0  x1  x0  x2  x0  x3   0  2 0  4 0  6
1
  x  2 x  4 x  6
48

L1 ( x) 
 x  x0  x  x2  x  x3 

 x  0  x  4  x  6 
 x1  x0  x1  x2  x1  x3   2  0 2  4 2  6
1
  x  x  4  x  6 
16

L2 ( x) 
 x  x0  x  x1  x  x3 

 x  0 x  2 x  6 
 x2  x0  x2  x1  x2  x3   4  0 4  2 4  6
1
 x x  2  x  6
16
L3 ( x) 
 x  x0  x  x1  x  x2 

 x  0 x  2  x  4 
 x3  x0  x3  x1  x3  x2   6  0 6  2 6  4
1
 x x  2 x  4 
48

As we know Lagrange polynomial;


Pn ( x)  L0 ( x) f ( x0 )  L1 ( x) f ( x1 )  L2 ( x) f ( x2 )  L3 ( x) f ( x3 )

 1  1 
   x  2  x  4  x  6   (1)    x  x  4  x  6   (1) 
 48  16 
 1  1 
 16 x  x  2  x  6   ( 1)   48 x x  2  x  4   (1)
   
b) Hence evaluate f(3), f(5) and f(6.5)
From the table, we only can interpolate xi3 and
5. Coz xi=6.5 is not in interval.

Subs into Pn (x).

How to know number of Lagrange polynomials


you need?  Refer to i = 0,1,2,3  4 poly OR

Pn ( x)  L0 ( x) f ( x0 )  L1 ( x) f ( x1 )  L2 ( x) f ( x2 )  L3 ( x) f ( x3 )

1 2 3 4
Example 2
Given (x,y) (1,2) , (2,3) and (3,7). Approximate
f(1.5) using Langrange interpolating polynomial.

Solution;

i 0 1 2

xi 1 2 3

f(xi) 2 3 7
How many Lagrange polynomials you need?
L (x) given i = 0,1,2 so we have
i

L0 ( x), L1 ( x), L2 ( x)

L0 ( x) 
 x  x1  x  x2  x  x3 

 x  2  x  3
 x0  x1  x0  x2  x0  x3  1  21  3
1
  x  2  x  3
2
Coz value of last i 2, xi=x2 ….No x3
L1 ( x) 
 x  x0  x  x2   x  1 x  3

 x1  x0  x1  x2   2  1 2  3
 1 x  1 x  3

L2 ( x) 
 x  x0  x  x1 

 x  1 x  2
 x2  x0  x2  x1   3  1 3  2
1
  x  1 x  2 
2
Find f(1.5) with subs x = 1.5 into each Langrange polynomial

1 
L0   1.5  2 1.5  3 ,
2 
L1   (1)(1.5  1)(1.5  3),
1 
L2   (1.5  1)(1.5  2)
2 
L0  0.375, L1  0.75, L2  0.125
Using Lagrange polynomial;

Pn ( x)  L0 ( x) f ( x0 )  .....Li ( x) f ( xi )

Pn ( x)  L0 ( x) f ( x0 )  L1 ( x) f ( x1 )  L2 ( x) f ( x2 )
 0.375(2)  0.75(3)  0.125(7)  2.215
xy

Example 3
A robot arm with a rapid laser scanner is doing a quick quality
check on holes drilled in a rectangular plate. The centers of the
holes in the plate describe the path the arm needs to take, and
the hole centers are located on a Cartesian coordinate system
(with the origin at the bottom left corner of the plate) given by
the specifications in Table 1: The coordinates of the holes on
the plate.
x (in.) y (in.)
2.00 7.2
4.25 7.1
5.25 6.0
7.81 5.0
9.20 3.5
10.60 5.0
a) If the laser is traversing from x=2 to
x=4.25 in a linear path, what is the value
of y at x=4 using the Lagrangian method
and a first order polynomial?

Solution;
i x (in.) y (in.)
0 2.00 7.2
7.25 1 4.25 7.1
7.2
7.15
7.1
7.05
7 x=4, y?
0.5 1 1.5 2 2.5 3 3.5
Given;
x0  2.00, y  x0   7.2 x1  4.25, y  x1   7.1

For sequence of x0 and x1. i=0,1. We have 2 basic


polynomial L0 ( x ), L1 ( x)
Pn ( x)  L0 ( x) f ( x0 )  .....Li ( x) f ( xi )
 L0 ( x) f ( x0 )  L1 ( x) f ( x1 )

L0 ( x) 
 x  x1  x  x2  x  x3 

 x  4.25
 x0  x1  x0  x2  x0  x3   2  4.25
L1 ( x ) 
 x  x0  
 x  2
 x1  x0   4.25  2 
The value of y when x=4;
 L0 ( x) f ( x0 )  L1 ( x) f ( x1 )


 4  4.25
(7.2) 
 4  2
(7.1)
 2  4.25  4.25  2
 0.8  6.31  7.11inch
xy

Exercise 1
1) A robot arm with a rapid laser scanner is doing a quick
quality check on holes drilled in a rectangular plate. The
centers of the holes in the plate describe the path the arm
needs to take, and the hole centers are located on a
Cartesian coordinate system (with the origin at the bottom
left corner of the plate) given by the specifications in Table
2.
x (in.) y (in.)
2.00 7.2
4.25 7.1
5.25 6.0
7.81 5.0
9.20 3.5
10.60 5.0
a) If the laser is traversing from x=2 to x=4.25
and to x=5.25 in a quadratic path, what is the
value of y at x=4 using a second order
Lagrange polynomial?

2) By using Lagrange interpolation, evaluate f(3)


if f(0)=2, f(1)=1 and f(4)=4.
Newton Divided Difference Method
Example 4
a)Find the Newton’s interpolatory divided
difference polynomial and approximate value
for f(2.5).
b)Find f(2.5) if f(2)= 0.51 is added in the data
given.
i 0 1 2

xi 2.1 2.4 2.6

f(xi) 0.521 0.51 0.381


Solution;

i xi fi(0) fi(1) fi(2)

0 2.1 0.521 0.51  0.521  0.645  (0.037)


-0.037 -1.216
2.4  2.1 2.6  2.1
1 2.4 0.51 0.381  0.51
-0.645
2.6  2.4
2 2.6 0.381
Formula of Newton interpolatory divided
difference polynomial
(0) (1) ( 2) ( 3)
Pn ( x)  f 0  f 0 ( x  x0 )  f 0 ( x  x0 )( x  x1 )  f 0 ( x  x0 )( x  x1 )( x  x2 )
(n)
 f 0 ( x  x0 )....( x  xn1 )

Find f(2.5) which is same with P(2.5);

( 0) (1) ( 2)
P( x)  f 0  f 0 ( x  x0 )  f 0 ( x  x0 )( x  x1 )
 0.521   (0.037)( x  2.1)   (1.216)( x  2.1)( x  2.4)
P(2.5)  subs x  2.5  0.458
b)Find f(2.5) if f(2)= 0.51 is added in the
data given
i xi fi(0) fi(1) fi(2) fi(3)

0 2.0 0.51 0.521  0.51  0.037  0.11  1.216  (0.36


2.1  2.0 2.4  2.0 2.6  2
1 2.1 0.521
0.51  0.521  0.645  (0.037)
2.4  2.1 2.6  2.1
2 2.4 0.51
0.381  0.51
3 2.6 0.381 2.6  2.4
Formula of Newton interpolatory divided
difference polynomial
(0) (1) ( 2) ( 3)
Pn ( x)  f 0  f 0 ( x  x0 )  f 0 ( x  x0 )( x  x1 )  f 0 ( x  x0 )( x  x1 )( x  x2 )
(n)
 f 0 ( x  x0 )....(x  xn1 )

Find f(2.5);
( 0) (1) ( 2) ( 3)
P ( x )  f0  f0 ( x  x 0 )  f0 ( x  x 0 )( x  x1 )  f0 ( x  x 0 )( x  x1 )( x  x 2 )

 0.51 ( 0.11)( x  2.0 )  ( 0.368)( x  2.0 )( x  2.1)  ( 1.413)( x  2.0 )( x  2.1)( x  2.4 )

P ( 2.5 )  subs x  2.5  0.463


Example 5
Find the Newton’s interpolatory divided
difference polynomial and approximate value
for f(2.5)

xi 2.4 2.6 2.1

f(xi) 0.510 0.381 0.521


Solution;
i xi fi(0) fi(1) fi(2)

0 2.4 0.51 0.381  0.51  0.28  (0.645)


2-0.645
.6  2 .4 2.-1.217
1  2.4
1 2.6 0.381 0.521  0.381
-0.28
2.1  2.6
2 2.1 0.521
Formula of Newton interpolatory divided
difference polynomial
(0) (1) ( 2) ( 3)
Pn ( x)  f 0  f 0 ( x  x0 )  f 0 ( x  x0 )( x  x1 )  f 0 ( x  x0 )( x  x1 )( x  x2 )
(n)
 f 0 ( x  x0 )....( x  xn1 )

Find f(2.5) =?
(0) (1) ( 2)
P2 ( x)  f 0  f 0 ( x  x0 )  f 0 ( x  x0 )( x  x1 )
 0.510   (0.645)( x  2.4)   (1.217)( x  2.4)( x  2.6)
P2 (2.5)  subs x  2.5  0.458
Exercise 2
Page 106No-9
Piecewise Polynomial Approximation
Step 4: Generate formula

Where k=0,1,2,3 …. n-1


Known y=f
Example 6
Construct natural cubic spline if S(x) interpolates
the data f(-1) = -1, f(0)=0, f(1)=1 and f(2)=0.

Solution;
Step 1: Construct divided difference table
k xk yk hk dk bk
f1  f 0
0 -1 -1 x1  x0 6( d1  d 0 )
h0
1 0 0 f 2  f1
x2  x1 6( d 2  d1 )
h1
2 1 1 f3  f 2
x3  x2
h2
3 2 0
Solve it; yk = fk

k xk yk hk dk bk

0 -1 -1 0  (1)  1 0  (1)  1 6(1  1)  0


1
1 0
1 0 0 1 0  1 1 6(1  1)  12
1
2 1 1 0 1
2 1  1  1
1
3 2 0
Step 2: Derive simultaneous equation
Subs value of k= 0,1,2,3..n-2 into;
How to know total of k? k=4, 0,1,2,3.
n-2  4-2=2. So k=0, k=1  m0=m(n-1=4-13)=0

k=0 h0 m0  2(h0  h1 )m1  h1m2  b0


1m0  2(1  1) m1  1m2  0.....m0  0
4m1  m2  0

k=1 h1m1  2(h1  h2 )m2  h2 m3  b1


1m1  2(1  1)m2  1m3  12.....m3  0
m1  4m2  12
Step 3: Solve m1 and m2 = ?
4m1  m2  0
m1  4m2  12

4m1  m2  0
()4m1  16m2  48
m2  3.2, m1  0.8
Step 4: Generate equation,
How to know total of k that will be used?
Value of k=4, k=0,1,2,3 .. n-1 = 4-1 = 3
So k=0, k=1, k=2
Clamped Cubic Spline
Exercise
Page 96, No;6

You might also like