Spline Interpolation Method Power Point

Download Report

Transcript Spline Interpolation Method Power Point

Spline Interpolation Method
Electrical 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
Spline 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.
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
Why Splines ?
1
f ( x) 
1  25 x 2
Table : Six equidistantly spaced points in [-1, 1]
x
1
1  25 x 2
-1.0
0.038461
-0.6
0.1
-0.2
0.5
0.2
0.5
0.6
0.1
1.0
5
y
0.038461
Figure : 5th order polynomial vs. exact function
http://numericalmethods.eng.usf.edu
Why Splines ?
1.2
0.8
y
0.4
0
-1
-0.5
0
0.5
1
-0.4
-0.8
x
19th Order Polynomial
f (x)
5th Order Polynomial
Figure : Higher order polynomial interpolation is a bad idea
6
http://numericalmethods.eng.usf.edu
Linear Interpolation
Given  x0 , y0 , x1 , y1 ,......, x n1 , y n 1  x n , y n  , fit linear splines to the data. This simply involves
forming the consecutive data through straight lines. So if the above data is given in an ascending
order, the linear splines are given by  yi  f ( xi ) 
Figure : Linear splines
7
http://numericalmethods.eng.usf.edu
Linear Interpolation (contd)
f ( x )  f ( x0 ) 
f ( x1 )  f ( x 0 )
( x  x 0 ),
x1  x 0
x 0  x  x1
 f ( x1 ) 
f ( x 2 )  f ( x1 )
( x  x1 ),
x2  x1
x1  x  x 2
.
.
.
 f ( x n 1 ) 
f ( x n )  f ( x n 1 )
( x  x n 1 ), x n 1  x  x n
x n  x n 1
Note the terms of
f ( xi )  f ( x i 1 )
xi  x i 1
in the above function are simply slopes between xi 1 and x i .
8
http://numericalmethods.eng.usf.edu
Example
Thermistors are based on materials’ change in resistance with
temperature. A manufacturer of thermistors makes the following
observations on a thermistor. Determine the temperature
corresponding to 754.8 ohms using linear spline interpolation.
9
R (Ω)
T(°C)
1101.0
911.3
636.0
451.1
25.113
30.131
40.120
50.128
http://numericalmethods.eng.usf.edu
Linear Interpolation
R0  911.3,
T ( R0 )  30.131
R1  636.0,
26.36
y l 0.05h
T ( R1 )  40.120
31.36
T ( R)  T ( R0 ) 
T ( R1 )  T ( R0 )
( R  R0 )
R1  R0
40.120 30.131
 30.131
( R  911.3)
636.0  911.3
636.0  R  911.3
y
36.36
f lin ear( range)


f lin ear x d esired
41.36
46.36
y 0 0.05 h
T ( R)  30.131 0.036284( R  911.3)
500
x0 0.05 w
600
700
800
x range x d esired
900
1000
1100
xl 0.05 w
At R  754.8,
T (754.8)  30.131 0.036284(754.8  911.3)
 35.809 C
10
http://numericalmethods.eng.usf.edu
Quadratic Interpolation
Given  x0 , y0 ,  x1 , y1 ,......, x n 1 , y n 1 ,  x n , y n  , fit quadratic splines through the data. The splines
are given by
f ( x )  a1 x 2  b1 x  c1 ,
 a 2 x 2  b2 x  c2 ,
x 0  x  x1
x1  x  x 2
.
.
.
 a n x 2  bn x  cn ,
x n 1  x  x n
Find a i , bi , ci , i  1, 2, …, n
11
http://numericalmethods.eng.usf.edu
Quadratic Interpolation (contd)
Each quadratic spline goes through two consecutive data points
a1 x 0  b1 x 0  c1  f ( x0 )
2
a1 x1  b1 x1  c1  f ( x1 )
2
.
.
.
a i xi 1  bi xi 1  ci  f ( xi 1 )
2
a i xi  bi xi  c i  f ( xi )
2
.
.
.
a n x n 1  bn x n 1  c n  f ( xn 1 )
2
a n x n  bn xn  cn  f ( x n )
2
12
This condition gives 2n equations
http://numericalmethods.eng.usf.edu
Quadratic Splines (contd)
The first derivatives of two quadratic splines are continuous at the interior points.
For example, the derivative of the first spline
a1 x 2  b1 x  c1 is
2 a1 x  b1
The derivative of the second spline
a 2 x 2  b2 x  c 2 is
2 a2 x  b2
and the two are equal at x  x1 giving
2 a1 x1  b1  2a 2 x1  b2
2 a1x1  b1  2a 2 x1  b2  0
13
http://numericalmethods.eng.usf.edu
Quadratic Splines (contd)
Similarly at the other interior points,
2a 2 x 2  b2  2a3 x 2  b3  0
.
.
.
2ai xi  bi  2ai 1 xi  bi 1  0
.
.
.
2a n 1 x n 1  bn 1  2a n x n1  bn  0
We have (n-1) such equations. The total number of equations is (2n)  (n  1)  (3n  1) .
We can assume that the first spline is linear, that is a1  0
14
http://numericalmethods.eng.usf.edu
Quadratic Splines (contd)
This gives us ‘3n’ equations and ‘3n’ unknowns. Once we find the ‘3n’ constants,
we can find the function at any value of ‘x’ using the splines,
f ( x)  a1 x 2  b1 x  c1 ,
 a 2 x 2  b2 x  c 2 ,
x0  x  x1
x1  x  x 2
.
.
.
 a n x 2  bn x  c n ,
15
x n 1  x  x n
http://numericalmethods.eng.usf.edu
Example
Thermistors are based on materials’ change in resistance with
temperature. A manufacturer of thermistors makes the following
observations on a thermistor. Determine the temperature
corresponding to 754.8 ohms using quadratic spline interpolation.
16
R (Ω)
T(°C)
1101.0
911.3
636.0
451.1
25.113
30.131
40.120
50.128
http://numericalmethods.eng.usf.edu
Solution
Since there are four data points,
three quadratic splines pass through them.
T ( R)  a1 R 2  b1 R  c1 ,
17
1101 .0  R  911 .3
 a2 R 2  b2 R  c2 ,
911 .3  R  636 .0
 a3 R 2  b3 R  c3 ,
636 .0  R  451 .1
http://numericalmethods.eng.usf.edu
Solution (contd)
Setting up the equations
Each quadratic spline passes through two consecutive data points giving
a1 R 2  b1 R  c1 passes through R = 1101.0 and R = 911.3,
a1 (1101.0) 2  b1 (1101.0)  c1  25.113
(1)
a1 (911.3) 2  b1 (911.3)  c1  30.131
(2)
Similarly,
18
a2 (911.3) 2  b2 (911.3)  c2  30.131
(3)
a2 (636.0) 2  b2 (636.0)  c2  40.120
(4)
a3 (636.0) 2  b3 (636.0)  c3  40.120
(5)
a3 (451.1) 2  b3 (451.1)  c3  50.128
(6)
http://numericalmethods.eng.usf.edu
Solution (contd)
Quadratic splines have continuous
derivatives at the interior data points
At R = 911.3
2a1 (911.3)  b1  2a2 (911.3)  b2  0
(7)
At R = 636.0
2a2 (636.0)  b2  2a3 (636.0)  b3  0
(8)
Assuming the first spline a1 R 2  b1 R  c1 is linear,
a1  0
19
(9)
http://numericalmethods.eng.usf.edu
Solution (contd)
1.2122106 1101.0

5
8
.
3047

10
911.3


0
0

0
0


0
0

0
0

 1822.6
1


0
0

1
0

20
1
0
0
0
0
0
0  a1   25.113
  

1
0
0
0
0
0
0  b1   30.131
0 8.3047105 911.3 1
0
0
0  c1   30.131
  

5
0 4.045010 636.0 1
0
0
0 a2  40.120
0
0
0
0 4.0450105 636.0 1 b2   40.120
  

0
0
0
0 2.0349105 451.1 1  c2  50.128
0  1822.6
1 0
0
0
0  a3   0 
  

0
1272
1
0
 1272
 1 0  b3   0 
 
0
0
0
0
0
0
0  c3   0 
http://numericalmethods.eng.usf.edu
Solution (contd)
Solving the above 9 equations gives the 9 unknowns as
21
i
ai
1
0
−0.026452 54.237
2
3.5713×10−5
−0.091543 83.895
3
4.3325×10−5
−0.10122
bi
ci
86.974
http://numericalmethods.eng.usf.edu
Solution (contd)
Therefore, the splines are given by
T ( R)  0.026452R  54.237,
911 .3  R  1101 .0
 3.5713105 R2  0.091543R  83.895,
636 .0  R  911 .3
 4.3325105 R2  0.10122R  86.974,
451 .1  R  636 .0
At R = 754.8
T (754.8)  3.5713105 (754.8)2  0.091543(754.8)  83.895
 35.145 C
The absolute relative approximate error a obtained between the results from the linear and
quadratic splines is
a 
35.145 35.809
 100
35.145
 1.8892 %
22
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/spline_met
hod.html
THE END
http://numericalmethods.eng.usf.edu