Professional Documents
Culture Documents
CH 5 Interpolation, Approximation and Curve Fitting
CH 5 Interpolation, Approximation and Curve Fitting
===========================Chapter 5=========================
====================Curve Fitting and Interpolation==============
=====================================================================
Experimental data is given only in the form of discrete points such as x0 , y0 , x1 , y1 , ......,
xn 1, yn 1 , xn , yn which means that there are only fixed data we are able to know.
Consequently, if someone wants to know the value of y at any x, it could not be possible
unless a continuous function f x is used to represent the data values. This is called
interpolation, if x falls inside the range of x for which the data is given. But, if x falls
outside the range of x for which the data is given, it is no longer interpolation, instead, it is
extrapolation.
Some of the methods of interpolation are direct method, Newton’s divided difference
polynomial method, Lagrangian interpolation method, and spline interpolation.
y
x3 , y 3
x1 , y1
x2 , y 2 ) f x
x0 , y 0
x
Direct Method
The direct method of interpolation is based on the following premise. Given n 1 data
points, we can fit a polynomial of order n as given as
y a0 a1 x ............... an x n (1)
1
through the data, where a0 , a1 ,..., an are real constants found by solving the n 1
simultaneous linear equations determined by the n+1 data points. To find the value of y at
a given value of x , simply substitute the value of x in Equation1. However, it may not be
necessary to use all the data points, and the selection of appropriate data points to be used
relays on the order of the polynomial required and actual value of x used to find y.
Example 1
A manufacturer of thermistors makes several observations with a thermistor, which are
given in Table 1.
R ohm T C
1101.0 25.113
911.3 30.131
636.0 40.120
451.1 50.128
Determine the temperature corresponding to 754.8 ohms using the direct method of
interpolation and
(a) First order polynomial approximation.
(b) Second order polynomial.
(c) Third order polynomial
Solution
(a) For first order polynomial interpolation (also called linear interpolation), we choose the
temperature given by
T R a0 a1 R
x1 , y1
f1 x
x0 , y 0
x
Figure 3 linear interpolation.
2
Since we want to find the temperature at R 754.8 , and we are using a first order
polynomial, we need to choose the two data points that are closest to R 754.8 that also
bracket R 754.8 to evaluate it. The two points are R0 911.3 and R1 636.0 .
Then
T R0 T 911.3 a0 a1 911.3 30.131
T R1 T 636.0 a0 a1 636.0 40.120
a0 63.197 , a1 0.036284
Hence
T R a0 a1 R
63.197 0.036284R, 636.0 R 911.3
At R 754.8 ,
T 754.8 63.197 0.036284754.8
35.809 C
(b) For second order polynomial interpolation (also called quadratic interpolation), we
choose the temperature given by
T R a0 a1 R a2 R 2
y
x1 , y1
x2 , y2
f 2 x
x0 , y 0
x
Figure 4 Quadratic interpolation.
3
Since we want to find the temperature at R 754.8 and we are using a second order
polynomial, we need to choose the three data points that are closest to R 754.8 that also
bracket R 754.8 to evaluate it. The three points are R0 911.3 , R1 636.0 and R2 451.1 .
Then
T 911.3 a0 a1 911.3 a2 911.3 30.131
2
a0 85.668
a1 0.096275
a 2 3.8771 10 5
Hence
T R 85.668 0.096275R 3.8771 10 5 R 2 , 451.1 R 911.3
At R 754.8 ,
T 754.8 85.668 0.096275754.8 3.8771 10 5 754.8
2
35.089 C
The absolute relative approximate error a obtained between the results from the first
and second order polynomial is
35.089 35.809
a 100%
35.089
2.0543%
(c) For third order polynomial interpolation (also called cubic interpolation), we choose
the temperature given by
T R a0 a1 R a2 R 2 a3 R 3
4
y
x 3 , y 3
x1 , y1 f 3 x
x0 , y 0 x2 , y 2
x
Figure 5 Cubic interpolation.
Since we want to find the temperature at R 754.8 , and we are using a third order
polynomial, we need to choose the four data points closest to R 754.8 that also bracket
R 754.8 to evaluate it. The four points are R0 1101.0 , R1 91.3 , R2 636.0 and
R3 451.1 .
Then
T 1101.0 a0 a1 1101.0 a2 1101.0 a3 1101.0 25.113
2 3
a0 92.759
a1 0.13093
a2 9.2975 10 5
a3 2.7124 10 8
Hence
T 754.8 35.242 C
5
The absolute relative approximate error a for the results from the second and third
order polynomial is
35.242 35.089
a 100 0.43458%
35.242
where
b0 f [ x0 ]
b1 f [ x1 , x0 ]
b2 f [ x2 , x1 , x0 ]
bn f [ xn , xn1 ,...., x0 ]
From the above definition, it can be seen that the divided differences are calculated
recursively. A clear understanding of Newton’s divided difference could be made using
examples.
Example 2
a) Using the data given under example 1, determine the temperature corresponding to
754.8 ohms using Newton’s divided difference method of interpolation and a third
order polynomial.
b) Find the absolute relative true error, if the actual measured value of the resistor is
35.285 C
Solution
T ( R) b0 b1 ( R R0 ) b2 ( R R0 )( R R1 ) b3 ( R R0 )( R R1 )( R R2 )
6
Since we want to find the temperature at R 754.8, we need to choose the four data points
that are closest to R 754.8 that also bracket R 754.8 to evaluate it. The four data points
are R0 1101.0, R1 911.3, R2 636.0 and R3 451.1 .
Then
b0 T [ R0 ] T ( R0 ) 25.113
T ( R1 ) T ( R0 ) 30.131 25.113
b1 T [ R1 , R0 ] 0.026452
R1 R0 911.3 1101.0
T [ R2 , R1 ] T [ R1 , R0 ]
b2 T [ R2 , R1 , R0 ]
R2 R0
T ( R2 ) T ( R1 )
T [ R2 , R1 ] 0.036284
R2 R1
T [ R1 , R0 ] 0.026452
T [ R2 , R1 ] T [ R1 , R0 ] 0.036284 0.026452
b2 2.1144 10 5
R2 R0 636.0 1101.0
T [ R3 , R2 , R1 ] T [ R2 , R1 , R0 ]
b3 T [ R3 , R2 , R1 , R0 ]
R3 R0
T [ R3 , R2 ] T [ R2 , R1 ]
T [ R3 , R2 , R1 ]
R3 R1
T ( R3 ) T ( R2 ) 50.128 40.120
T [ R3 , R2 ] 0.054127
R3 R2 451.1 636.0
T [ R2 , R1 ] 0.036284
T [ R3 , R2 ] T [ R2 , R1 ] 0.054127 0.036284
T [ R3 , R2 , R1 ] 3.8771 10 5
R3 R1 451.1 911.3
T [ R2 , R1 , R0 ] 2.1144 10 5
7
T [ R3 , R2 , R1 ] T [ R2 , R1 , R0 ] 3.8771 10 5 2.1144 10 5
b3 2.7124 10 8
R3 R0 451.1 1101.0
Hence
T ( R) b0 b1 ( R R0 ) b2 ( R R0 )( R R1 ) b3 ( R R0 )( R R1 )( R R2 )
25.113 0.026452( R 1101.0) 2.1144 10 5 ( R 1101.0)( R 911.3)
2.7124 10 8 ( R 1101.0)( R 911.3)( R 636.0), 451.1 R 1101.0
This is the same expression that was obtained with the direct method.
At R 754.8,
T (754.8) 35.242 C
b) The absolute relative true error t obtained between the results from the second
and third order polynomial is
35.242 35.285
t 100
35.242
0.122%
Lagrange Method
where n in f n (x) stands for the n order polynomial that approximates the function
th
y f (x) given at n 1 data points as x0 , y0 , x1 , y1 ,......, xn1 , y n1 , xn , y n , and
n x xj
Li ( x)
j 0 xi x j
j i
8
Example 3
Use data from example 1 to determine second order Lagrangian interpolating polynomial
and find the temperature for a resistor value of 754.8 0hm.
Solution
2
T ( R) Li ( R)T ( Ri )
i 0
Since we want to find the temperature at R 754.8, we need to choose the three data
points that are closest to R 754.8 that also bracket R 754.8 to evaluate it. The three
points are R0 911.3, R1 636.0 and R2 451.1 .
Then
R0 911.3, T ( R0 ) 30.131
R1 636.0, T ( R1 ) 40.120
R2 451.1, T ( R2 ) 50.128
gives
2 R Rj
L0 ( R)
j 0 R0 R j
j 0
R R1 R R2
R0 R1 R0 R2
2 RR
L1 ( R)
j
j 0 R1 R j
j 1
R R0 R R2
1
R R 0 R1 R2
2 R Rj
L2 ( R)
j 0 R2 R j
j 2
R R0 R R1
R2 R0 R2 R1
Hence
9
R R1 R R2 R R0 R R2
T ( R) T ( R0 ) T ( R1 )
R0 R1 R0 R2 R1 R0 R1 R2
R R0 R R1
T ( R2 ), R0 R R2
R2 R0 R2 R1
Spline Interpolation
This simply involves forming straight lines through the consecutive data.
y
(x3, y3)
(x1, y1)
(x2, y2)
(x0, y0)
x
Figure 6 Linear splines.
So if the above data is given in an ascending order, the linear splines are given by:
f ( x1 ) f ( x0 )
f ( x) f ( x0 ) ( x x0 ), x0 x x1
x1 x0
f ( x2 ) f ( x1 )
f ( x1 ) ( x x1 ), x1 x x2
x2 x1
.
.
.
f ( xn ) f ( xn1 )
f ( xn1 ) ( x xn1 ), xn1 x xn
xn xn1
10
Note the terms of
f ( xi ) f ( xi 1 )
xi xi 1
in the above function are simply slopes between xi 1 and xi .
(2)Quadratic Splines
One of the drawbacks of linear spline is the abrupt change of slope at the interior points of
the data that makes the first derivative to be discontinuous at these points. This can be
improved by using quadratic splines.
So given x0 , y0 , x1 , y1 ,......, xn1 , y n1 , xn , y n , we can fit quadratic polynomials between
two consecutive points determined by:
f ( x) a1 x 2 b1 x c1 , x0 x x1
a2 x 2 b2 x c2 , x1 x x2
.
.
.
an x 2 bn x cn , xn1 x xn
Determining Coefficients:
a1 x1 b1 x1 c1 f ( x1 )
2
.
.
.
an xn1 bn xn1 cn f ( xn1 )
2
an xn bn xn cn f ( xn )
2
This condition gives 2n equations as there are n quadratic splines going through two
consecutive data points.
2. The first derivatives of two quadratic splines are continuous at the interior points. For
example, the derivative of the first spline
11
a1 x 2 b1 x c1
is
2a1 x b1
The derivative of the second spline
a2 x 2 b2 x c2
is
2a2 x b2
and the two are equal at x x1 giving
2a1 x1 b1 2a2 x1 b2
2a1 x1 b1 2a2 x1 b2 0
Similarly at the other interior points,
2a2 x2 b2 2a3 x2 b3 0
.
.
.
2ai xi bi 2ai 1 xi bi 1 0
.
.
.
2an1 xn1 bn1 2an xn1 bn 0
Since there are (n 1) interior points, we have (n 1) such equations. So far, the total
number of equations is (2n) (n 1) (3n 1) equations. We still then need one more
equation.
We can assume that the first spline is linear, that is
a1 0
This gives us 3n equations and 3n unknowns. These can be solved by a number of
techniques used to solve simultaneous linear equations.
Exercise 1
Use data from example 1 to determine the temperature corresponding to 754.8 ohms using
linear and quadratic splines and compare the results.
12