1. 1
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Interpolation/Curve Fitting
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Objectives
• Understanding the difference between
regression and interpolation
• Knowing how to “best fit” a polynomial into
a set of data
• Knowing how to use a polynomial to
interpolate data
2. 2
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Measured Data
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Polynomial Fit!
3. 3
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Line Fit!
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Which is better?
4. 4
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Curve Fitting
• If the data measured is of high accuracy
and it is required to estimate the values of
the function between the given points,
then, polynomial interpolation is the best
choice.
• If the measurements are expected to be of
low accuracy, or the number of measured
points is too large, regression would be
the best choice.
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Interpolation
5. 5
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Why Interpolation?
• When the accuracy of your measurements
are ensured
• When you have discrete values for a
function (numerical solutions, digital
systems, etc …)
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Acquired Data
6. 6
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
But, how to get the equation of a
function that passes by all the
data you have!
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Equation of a Line: Revision
xaay 10 +=
If you have two points
1101 xaay +=
2102 xaay +=
=
2
1
1
0
2
1
1
1
y
y
a
a
x
x
7. 7
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Solving for the constants!
12
12
1
12
2112
0 &
xx
yy
a
xx
yxyx
a
−
−
=
−
−
=
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
What if I have more than two
points?
• We may fit a
polynomial of order
one less that the
number of points we
have. i.e. four points
give third order
polynomial.
8. 8
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Third-Order Polynomial
3
3
2
210 xaxaxaay +++=
For the four points
3
13
2
121101 xaxaxaay +++=
3
23
2
222102 xaxaxaay +++=
3
33
2
323103 xaxaxaay +++=
3
43
2
424104 xaxaxaay +++=
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
In Matrix Form
=
4
3
2
1
3
2
1
0
3
4
2
24
3
3
2
23
3
2
2
22
3
1
2
11
1
1
1
1
y
y
y
y
a
a
a
a
xxx
xxx
xxx
xxx
Solve the above equation for the constants of the polynomial.
9. 9
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Example
• Find a 3rd order
polynomial to
interpolate the
function described by
the given points
162
51
20
1-1
Yx
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Solution: System of equations
• A third order polynomial is given by:
( ) 3
4
2
321 xaxaxaaxf +++=
( ) 11 4321 =−+−=− aaaaf
( ) 20 1 == af
( ) 51 4321 =+++= aaaaf
( ) 168422 4321 =+++= aaaaf
10. 10
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
In matrix form
=
−−
16
5
2
1
8421
1111
0001
1111
4
3
2
1
a
a
a
a
=
1
1
1
2
4
3
2
1
a
a
a
a
( ) 32
2 xxxxf +++=
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Newton's Interpolation
Polynomial
11. 11
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Newton’s Method
• In the previous procedure, we needed to solve a
system of linear equations for the unknown
constants.
• This method suggests that we may just proceed
with the values of x & y we have to get the
constants without setting a set of equations
• The method is similar to Taylor’s expansion
without differentiation!
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
For the two points
( )110 xxbby −+=
( ) 0111101 byxxbby =⇒−+=
( )1
12
12
1 xx
xx
yy
yy −
−
−
+=
( )⇒−+= 12102 xxbby
( ) ( )
( )12
12
112112
xx
yy
bxxbyy
−
−
=⇒−+=
12. 12
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Homework
• Show that the polynomial obtained by
solving a set of equations is equivalent to
that obtained by Newton method
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
For the three points
( ) ( )
( )( )213
121
xxxxb
xxbbxf
−−+
−+=
10 yb =
12
12
1
xx
yy
b
−
−
=
13
12
12
23
23
2
xx
xx
yy
xx
yy
b
−
−
−
−
−
−
=
13. 13
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Using a table
y3x3
y2x2
y1x1
yixi
13
12
12
23
23
xx
xx
yy
xx
yy
−
−
−
−
−
−
12
12
xx
yy
−
−
23
23
xx
yy
−
−
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
In General
• Newton’s Interpolation is performed for an
nth order polynomial as follows
( ) ( ) ( )( )
( ) ( )nn xxxxb
xxxxbxxbbxf
−−++
−−+−+=
...... 1
212110
14. 14
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Example
• Find a 3rd order
polynomial to
interpolate the
function described by
the given points using
Newton’s method
162
51
20
1-1
Yx
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Newton’s Method
• Newton’s methods defines the polynomial in the
form:
( ) ( ) ( )( )
( )( )( )3213
212110
xxxxxxb
xxxxbxxbbxf
−−−+
−−+−+=
( ) ( ) ( )( )
( )( )( )11
11
3
210
−++
++++=
xxxb
xxbxbbxf
15. 15
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Newton’s Method
162
1151
4320
1111-1
Yx
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Newton’s Method
• Finally:
( ) ( ) ( )( )
( )( )( )11
111
−++
++++=
xxx
xxxxf
( ) ( ) ( ) ( )xxxxxxf −+++++= 32
11
( ) 32
2 xxxxf +++=
16. 16
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Advantage of Newton’s Method
• The main advantage of Newton’s method
is that you do not need to invert a matrix!
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Homework #6
• Chapter 18, pp. 505-506, numbers:
18.1, 18.2, 18.3, 18.5.