Transcript PPT
Direct Method of
Interpolation
Computer Engineering Majors
Authors: Autar Kaw, Jai Paul
http://numericalmethods.eng.usf.edu
Transforming Numerical Methods Education for STEM
Undergraduates
http://numericalmethods.eng.usf.edu
1
Direct Method of
Interpolation
http://numericalmethods.eng.usf.edu
What is Interpolation ?
Given (x0,y0), (x1,y1), …… (xn,yn), find the value of ‘y’ at a
value of ‘x’ that is not given.
Figure 1 Interpolation of discrete.
3
http://numericalmethods.eng.usf.edu
Interpolants
Polynomials are the most common
choice of interpolants because they
are easy to:
Evaluate
Differentiate, and
Integrate
4
http://numericalmethods.eng.usf.edu
Direct Method
Given ‘n+1’ data points (x0,y0), (x1,y1),………….. (xn,yn),
pass a polynomial of order ‘n’ through the data as given
below:
y a0 a1 x .................... an x .
n
where a0, a1,………………. an are real constants.
Set up ‘n+1’ equations to find ‘n+1’ constants.
To find the value ‘y’ at a given value of ‘x’, simply
substitute the value of ‘x’ in the above polynomial.
5
http://numericalmethods.eng.usf.edu
Example
A robot arm with a rapid laser scanner is doing a quick quality check
on holes drilled in a rectangular plate. The hole centers in the plate that
describe the path the arm needs to take are given below.
If the laser is traversing from x = 2 to x = 4.25 in a linear path, find
the value of y at x = 4 using the direct method for linear interpolation.
6
x (m)
y (m)
2
4.25
5.25
7.81
9.2
10.6
7.2
7.1
6.0
5.0
3.5
5.0
Figure 2 Location of holes on the
rectangular plate.
http://numericalmethods.eng.usf.edu
Linear Interpolation
yx a0 a1 x
7.2
y 2.00 a0 a1 2.00 7.2
y 4.25 a0 a1 4.25 7.1
7.2
7.18
7.16
ys
f ( range)
f x desired
7.14
7.12
Solving the above two equations gives,
a0 7.2889
a1 0.044444
7.1
7.1
7.08
5
x s 10
0
Hence
7
0
5
10
x s range x desired
y x 7.2889 0.044444 x, 2.00 x 4.25
y 4.00 7.2889 0.0444444.00 7.1111 in.
http://numericalmethods.eng.usf.edu
x s 10
1
Example
A robot arm with a rapid laser scanner is doing a quick quality check
on holes drilled in a rectangular plate. The hole centers in the plate that
describe the path the arm needs to take are given below.
If the laser is traversing from x = 2 to x = 4.25 in a linear path, find
the value of y at x = 4 using the direct method for quadratic interpolation.
8
x (m)
y (m)
2
4.25
5.25
7.81
9.2
10.6
7.2
7.1
6.0
5.0
3.5
5.0
Figure 2 Location of holes on the
rectangular plate.
http://numericalmethods.eng.usf.edu
Quadratic Interpolation
y x a 0 a1 x a 2 x 2
y 2.00 a 0 a1 2.00 a 2 2.00 7.2
2
y 4.25 a0 a1 4.25 a 2 4.25 7.1
2
y 5.25 a0 a1 5.25 a 2 5.25 6.0
2
Solving the above three equations gives
a0 4.5282
9
a1 1.9855
a 2 0.32479
http://numericalmethods.eng.usf.edu
Quadratic Interpolation (contd)
y x 4.5282 1.9855 x 0.32479 x 2 , 2.00 x 5.25
y 4.00 4.5282 1.98554.00 0.324794.00
7.2735 in.
7.56258
The absolute relative approximate error a obtained
between first and second order polynomial is
a
7.2735 7.1111
100
7.2735
2
8
7.5
ys
f ( range)
f x desired
7
6.5
2.2327%
6
6
2
2
10
2.5
3
3.5
4
4.5
5
x s range x desired
http://numericalmethods.eng.usf.edu
5.5
5.25
Comparison Table
11
Order of
Polynomial
1
2
Location (in.)
7.1111
7.2735
Absolute Relative
Approximate Error
----------
2.2327%
http://numericalmethods.eng.usf.edu
Example
A robot arm with a rapid laser scanner is doing a quick quality check
on holes drilled in a rectangular plate. The hole centers in the plate that
describe the path the arm needs to take are given below.
If the laser is traversing from x = 2 to x = 4.25 in a linear path, find
the value of y at x = 4 using the direct method using a fifth order
polynomial.
12
x (m)
y (m)
2
4.25
5.25
7.81
9.2
10.6
7.2
7.1
6.0
5.0
3.5
5.0
Figure 2 Location of holes on the
rectangular plate.
http://numericalmethods.eng.usf.edu
Fifth Order Interpolation
2
3
4
5
y x a 0 a1 x a 2 x a3 x a 4 x a5 x
y 2.00 7.2 a0 a1 2.00 a 2 2.00 a3 2.00 a 4 2.00 a 5 2.00
2
3
4
5
y 4.25 7.1 a0 a1 4.25 a 2 4.25 a3 4.25 a 4 4.25 a5 4.25
2
3
4
5
y 5.25 6.0 a 0 a1 5.25 a 2 5.25 a3 5.25 a 4 5.25 a5 5.25
2
3
4
5
y 7.81 5.0 a0 a1 7.81 a 2 7.81 a3 7.81 a 4 7.81 a5 7.81
2
3
4
5
y 9.20 3.5 a 0 a1 9.20 a 2 9.20 a3 9.20 a 4 9.20 a5 9.20
2
3
4
5
y 10.60 5.0 a0 a1 10.60 a 2 10.60 a3 10.60 a 4 10.60 a5 10.60
2
13
3
4
5
http://numericalmethods.eng.usf.edu
Fifth Order Interpolation (contd)
Writing the six equations in matrix form, we have
1
1
1
1
1
1
2.00
4.25
5.25
7.81
9.20
10.6
4.00
18.063
27.563
60.996
84.640
112.36
8.00
76.766
144.70
476.38
778.69
1191.0
a0 30.898 a1 41.344
a3 2.7862
16.00
32 a0 7.2
326.25 1386.6 a1 7.1
759.69 3988.4 a 2 6.0
3720.5 29057 a3 5.0
7163.9 65908 a 4 3.5
12625 133820 a5 5.0
a2 15.855
a4 0.23091 a5 0.0072923
yx 30.898 41.344 x 15.855 x 2 2.7862 x 3 0.23091x 4 0.0072923x 5 ,2 x 10.6
14
http://numericalmethods.eng.usf.edu
Fifth Order Interpolation (contd)
yx 30.898 41.344 x 15.855 x 2 2.7862 x 3 0.23091x 4 0.0072923x 5 ,2 x 10.6
15
http://numericalmethods.eng.usf.edu
Additional Resources
For all resources on this topic such as digital audiovisual
lectures, primers, textbook chapters, multiple-choice
tests, worksheets in MATLAB, MATHEMATICA, MathCad
and MAPLE, blogs, related physical problems, please
visit
http://numericalmethods.eng.usf.edu/topics/direct_met
hod.html
THE END
http://numericalmethods.eng.usf.edu