Lagrange Method of Interpolation

advertisement
Chapter 05.04
Lagrange Method of Interpolation – More Examples
Computer Engineering
Example 1
A robot arm with a rapid laser scanner is doing a quick quality check on holes drilled in a
15"10" 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.
Table 1 The coordinates of the holes on the plate.
y (in.)
x (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
Figure 1 Location of the holes on the rectangular plate.
05.04.1
05.04.2
Chapter 05.04
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.00 using the Lagrangian method and a first order polynomial?
Solution
For first order Lagrange polynomial interpolation (also called linear interpolation), we
choose the value of y as given by
1
y ( x)   Li ( x) y ( xi )
i 0
 L0 ( x) y( x0 )  L1 ( x) y( x1 )
y
(x1, y1)
f1(x)
(x0, y0)
x
Figure 2 Linear interpolation.
Since we want to find the value of y at x  4.00 , using the two points x0  2.00 and
x1  4.25 , then
x0  2.00, yx0   7.2
x1  4.25, yx1   7.1
gives
1
L0 ( x)  
j 0
j 0

x  xj
x0  x j
x  x1
x0  x1
1
x  xj
L1 ( x)  
j 0
j 1
x1  x j
Lagrange Method of Interpolation-More Examples: Computer Engineering

05.04.3
x  x0
x1  x0
Hence
x  x0
x  x1
y ( x0 ) 
y( x1 )
x0  x1
x1  x0
x  4.25
x  2.00

(7.2) 
(7.1), 2.00  x  4.25
2.00  4.25
4.25  2.00
4.00  4.25
4.00  2.00
y (4.00) 
(7.2) 
(7.1)
2.00  4.25
4.25  2.00
 0.11111(7.2)  0.88889(7.1)
 7.1111 in .
You can see that L0 ( x)  0.11111 and L1 ( x)  0.88889 are like weightages given to the
values of y at x0  2.00 and x1  4.25 to calculate the value of y at x  4.00.
y ( x) 
Example 2
A robot arm with a rapid laser scanner is doing a quick quality check on holes drilled in a
15"10" 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.
Table 2 The coordinates of the holes on the plate.
y (in.)
x (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
If the laser is traversing from x  2.00 to x  4.25 to x  5.25 in a quadratic path, what is
the value of y at x  4.00 using a second order Lagrange polynomial? Find the absolute
relative approximate error for the second order polynomial approximation.
Solution
For second order Lagrange polynomial interpolation (also called quadratic interpolation), we
choose the value of y given by
2
y ( x)   Li ( x) y ( xi )
i 0
 L0 ( x) y( x0 )  L1 ( x) y( x1 )  L2 ( x) y( x2 )
05.04.4
Chapter 05.04
y
(x2, y2)
(x1, y1)
f2(x)
(x0, y0)
x
Figure 3 Quadratic interpolation.
Since we want to find the value of y at x  4.00 , using the three points as x0  2.00 ,
x1  4.25 and x2  5.25 , then
x0  2.00, yx0   7.2
x1  4.25, yx1   7.1
x2  5.25, yx2   6.0
gives
2
L0 ( x)  
j 0
j 0
x  xj
x0  x j
 x  x1  x  x2 


 
x

x
x

x
1  0
2 
 0
2
x  xj
L1 ( x)  
j 0 x1  x j
j 1
 x  x0  x  x2 


 
 x1  x0  x1  x2 
2
x  xj
L2 ( x)  
j 0 x 2  x j
j 2
 x  x0  x  x1 


 
x

x
0  x 2  x1 
 2
Lagrange Method of Interpolation-More Examples: Computer Engineering
05.04.5
Hence
 x  x1  x  x2 
 x  x0  x  x2 
 x  x0  x  x1 

 y ( x0 )  


 y ( x1 )  
 y ( x 2 ),
y ( x)  
x

x
x

x
x

x
x

x
x

x
x

x
1  0
2 
0  1
2 
0  2
1 
 0
 1
 2
x0  x  x 2
(4.00  4.25)( 4.00  5.25)
(4.00  2.00)( 4.00  5.25)
y (4.00) 
(7.2) 
(7.1)
(2.00  4.25)( 2.00  5.25)
(4.25  2.00)( 4.25  5.25)
(4.00  2.00)( 4.00  4.25)

(6.0)
(5.25  2.00)(5.25  4.25)
 (0.042735)(7.2)  (1.1111)(7.1)  (0.15385)(6.0)
 7.2735 in .
The absolute relative approximate error a obtained between the results from the first and
second order polynomial is
7.2735  7.1111
a 
 100
7.2735
 2.2327%
Example 3
A robot arm with a rapid laser scanner is doing a quick quality check on holes drilled in a
15"10" 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 3.
Table 3 The coordinates of the holes on the plate.
y (in.)
x (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
Find the path traversed through the six points using a fifth order Lagrange polynomial.
Solution
For fifth order Lagrange polynomial interpolation (also called quintic interpolation), we
choose the value of y given by
5
y ( x)   Li ( x) y ( xi )
i 0
 L0 ( x) y ( x0 )  L1 ( x) y ( x1 )  L2 ( x) y ( x2 )
 L3 ( x) y ( x3 )  L4 ( x) y ( x4 )  L5 ( x) y ( x5 )
05.04.6
Chapter 05.04
y
(x2, y2)
(x4, y4)
(x0, y0)
(x1, y1)
(x3, y3)
(x5, y5)
f5(x)
x
Figure 4 5th order polynomial interpolation.
Using the six points,
x0  2.00, yx0   7.2
x1  4.25, yx1   7.1
x2  5.25, yx2   6.0
x3  7.81, yx3   5.0
x4  9.20, yx4   3.5
x5  10.60, yx5   5.0
gives
5
L0 ( x)  
j 0
j 0
x  xj
x0  x j
 x  x1  x  x2  x  x3  x  x4  x  x5 





 
 x0  x1  x0  x2  x0  x3  x0  x4  x0  x5 
5
x  xj
L1 ( x)  
j 0 x1  x j
j 1
 x  x0  x  x2  x  x3  x  x4  x  x5 





 
x

x
x

x
x

x
x

x
x

x
0  1
2  1
3  1
4  1
5 
 1
5
x  xj
L2 ( x)  
j 0 x 2  x j
j 2
Lagrange Method of Interpolation-More Examples: Computer Engineering
 x  x0  x  x1  x  x3  x  x4  x  x5 





 
 x2  x0  x2  x1  x2  x3  x2  x4  x2  x5 
5
x  xj
L3 ( x)  
j  0 x3  x j
j 3
 x  x0  x  x1  x  x2  x  x4  x  x5 





 
x

x
x

x
x

x
x

x
x

x
0  3
1  3
2  3
4  3
5 
 3
5
x  xj
L4 ( x)  
j 0 x 4  x j
j 4
 x  x0  x  x1  x  x2  x  x3  x  x5 





 
 x4  x0  x4  x1  x4  x2  x4  x3  x4  x5 
5
x  xj
L5 ( x)  
j  0 x5  x j
j 5
 x  x0  x  x1  x  x2  x  x3  x  x4 





 
x

x
x

x
x

x
x

x
x

x
0  5
1  5
2  5
3  5
4 
 5
 x  x1  x  x 2  x  x3  x  x 4  x  x5 




 y ( x0 )
y ( x)  
x

x
x

x
x

x
x

x
x

x
0
1
0
2
0
3
0
4
0
5






 x  x0  x  x 2  x  x3  x  x 4  x  x5 


 y ( x1 )


 
 x1  x0  x1  x 2  x1  x3  x1  x 4  x1  x5 
 x  x0  x  x1  x  x3  x  x 4  x  x5 


 y ( x 2 )


 
 x 2  x0  x 2  x1  x 2  x3  x 2  x 4  x 2  x5 
 x  x0  x  x1  x  x 2  x  x 4  x  x5 




 y ( x3 )
 
x

x
x

x
x

x
x

x
x

x
0  3
1  3
2  3
4  3
5 
 3
 x  x0
 
 x 4  x0
 x  x1  x  x 2


 x 4  x1  x 4  x 2
 x  x3  x  x5 

 y ( x 4 )

 x 4  x3  x 4  x5 
 x  x0
 
 x5  x 0
 x  x1  x  x 2


 x5  x1  x5  x 2
 x  x3  x  x 4


 x5  x3  x5  x 4

 y ( x5 )

05.04.7
05.04.8
Chapter 05.04
( x  4.25)( x  5.25)( x  7.81)( x  9.20)( x  10.60)
(7.2)
(2.00  4.25)( 2.00  5.25)( 2.00  7.81)( 2.00  9.20)( 2.00  10.60)
( x  2.00)( x  5.25)( x  7.81)( x  9.20)( x  10.60)

(7.1)
(4.25  2.00)( 4.25  5.25)( 4.25  7.81)( 4.25  9.20)( 4.25  10.60)
( x  2.00)( x  4.25)( x  7.81)( x  9.20)( x  10.60)

(6.0)
(5.25  2.00)(5.25  4.25)(5.25  7.81)(5.25  9.20)(5.25  10.60)
( x  2.00)( x  4.25)( x  5.25)( x  9.20)( x  10.60)

(5.0)
(7.81  2.00)(7.81  4.25)(7.81  5.25)(7.81  9.20)(7.81  10.60)
( x  2.00)( x  4.25)( x  5.25)( x  7.81)( x  10.60)

(3.5)
(9.20  2.00)(9.20  4.25)(9.20  5.25)(9.20  7.81)(9.20  10.60)
( x  2.00)( x  4.25)( x  5.25)( x  7.81)( x  9.20)

(5.0)
(10.60  2.00)(10.60  4.25)(10.60  5.25)(10.60  7.81)(10.60  9.20)

x 5  37.11x 4  536.77 x 3  3773.2 x 2  12862 x  16994

 365.38
5
4
x  34.86 x  462.83 x 3  2879.7 x 2  8169.5 x  7997.1

35.461
5
4
3
x  33.86 x  433.22 x  2572.3 x 2  6903.5 x  6473.9

 29.304
5
4
3
x  31.3 x  366.53 x  1984.1x 2  4912.4 x  4351.8

41.069
5
4
3
x  29.91x  335.81x  1757.2 x 2  4241.6 x  3694.3

 78.273
5
4
x  28.51x  308.78 x 3  1573.7 x 2  3727.5 x  3206.4

228.24
y ( x)  30.898  41.344 x  15.855 x 2  2.7862 x 3  0.23091x 4  0.0072923x 5 ,
2  x  10.6
Lagrange Method of Interpolation-More Examples: Computer Engineering
Figure 5 Fifth order polynomial to traverse points of robot path (using
Lagrangian method of interpolation).
05.04.9
Download