Numerical Methods Interpolation and Regression Notes
Numerical Methods Interpolation and Regression Notes
Interpolation
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.
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
5 http://numericalmethods.eng.usf.edu
Example 1
The upward velocity of a rocket is given as a
function of time in Table 1.
Find the velocity at t=16 seconds using the
direct method for linear interpolation.
Table 1 Velocity as a function
of time.
t , (s ) v(t ), (m/s )
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67 Figure 2 Velocity vs. time data for the
rocket example
6 http://numericalmethods.eng.usf.edu
Linear Interpolation
v(t ) = a0 + a1t y
Hence
v(t ) = −100.93 + 30.914t , 15 ≤ t ≤ 20.
v(16 ) = −100.93 + 30.914(16) = 393.7 m/s
7 http://numericalmethods.eng.usf.edu
Example 2
The upward velocity of a rocket is given as a
function of time in Table 2.
Find the velocity at t=16 seconds using the
direct method for quadratic interpolation.
Table 2 Velocity as a function
of time.
t , (s ) v(t ), (m/s )
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67 Figure 5 Velocity vs. time data for the
rocket example
8 http://numericalmethods.eng.usf.edu
Quadratic Interpolation
y
f 2 (x )
v(20) = a0 + a1 (20) + a2 (20) = 517.35
2
( x0 , y 0 )
x
ys
(
f x desired ) 350
250
227.04 200
10 12 14 16 18 20
10 x s , range , x desired 20
t , (s ) v(t ), (m/s )
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67 Figure 6 Velocity vs. time data for the
rocket example
11 http://numericalmethods.eng.usf.edu
Cubic Interpolation
y
(x3 , y3 )
v(t ) = a0 + a1t + a2t + a3t
2 3
(x1 , y1 )
v(10) = 227.04 = a0 + a1 (10) + a2 (10) + a3 (10)
2 3
f 3 (x )
( x2 , y 2 )
v(15) = 362.78 = a0 + a1 (15) + a2 (15) + a3 (15)
2 3
(x0 , y0 )
12 http://numericalmethods.eng.usf.edu
Cubic Interpolation (contd)
v(t ) = −4.2540 + 21.266t + 0.13204t 2 + 0.0054347t 3 , 10 ≤ t ≤ 22.5
v(16 ) = −4.2540 + 21.266(16 ) + 0.13204(16 ) + 0.0054347(16 )
2 3
= 392.06 m/s
700
(
f x desired )
392.06 − 392.19
400
300
∈a = × 100
392.06
227.04 200
10
10
12 14 16 18
x s , range , x desired
20 22 24
22.5
= 0.033269%
13 http://numericalmethods.eng.usf.edu
Comparison Table
14 http://numericalmethods.eng.usf.edu
Distance from Velocity Profile
Find the distance covered by the rocket from t=11s to t=16s ?
v(t ) = −4.3810 + 21.289t + 0.13064t 2 + 0.0054606t 3 , 10 ≤ t ≤ 22.5
16
s(16 ) − s(11) = ∫ v(t )dt
11
( )
16
= ∫ − 4.2540 + 21.266t + 0.13204t 2 + 0.0054347t 3 dt
11
16
t2 t3 t4
= − 4.2540t + 21.266 + 0.13204 + 0.0054347
2 3 4 11
= 1605 m
15 http://numericalmethods.eng.usf.edu
Acceleration from Velocity Profile
Find the acceleration of the rocket at t=16s given that
ν (t ) = −4.2540 + 21.266t + 0.13204 2 + 0.0054347t 3 ,10 ≤ t ≤ 22.5
a(t ) = v(t )
d
dt
=
d
dt
(
− 4.2540 + 21.266t + 0.13204t 2 + 0.0054347t 3 )
= 21.289 + 0.26130t + 0.016382t 2 , 10 ≤ t ≤ 22.5
= 29.665 m/s 2
16 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
Lagrangian Interpolation
http://numericalmethods.eng.usf.edu
Transforming Numerical Methods Education for STEM
Undergraduates
http://numericalmethods.eng.usf.edu 1
Lagrange 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
Lagrangian Interpolation
Lagrangian interpolating polynomial is given by
n
f n ( x) = ∑ Li ( x) f ( xi )
i =0
where ‘ n ’ in f n (x) stands for the n th order polynomial that approximates the function y = f (x)
5 http://numericalmethods.eng.usf.edu
Example
The upward velocity of a rocket is given as a function of
time in Table 1. Find the velocity at t=16 seconds using
the Lagrangian method for linear interpolation.
Table Velocity as a
function of time
t (s) v(t ) (m/s)
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67
1
v(t ) = ∑ Li (t )v(ti ) 500
i =0
= L0 (t )v(t 0 ) + L1 (t )v(t1 )
ys
f ( range)
450
(
f x desired )
7 http://numericalmethods.eng.usf.edu
Linear Interpolation (contd)
1 t −tj t − t1
L0 (t ) = ∏ =
j =0 t0 − t j t 0 − t1
j ≠0
1 t −tj t − t0
L1 (t ) = ∏ =
j =0 t1 − t j t1 − t 0
j ≠1
t − t1 t − t0 t − 20 t − 15
v(t ) = v(t 0 ) + v(t1 ) = (362.78) + (517.35)
t 0 − t1 t1 − t 0 15 − 20 20 − 15
16 − 20 16 − 15
v(16) = (362.78) + (517.35)
15 − 20 20 − 15
= 0.8(362.78) + 0.2(517.35)
= 393.7 m/s.
8 http://numericalmethods.eng.usf.edu
Quadratic Interpolation
For the second order polynomial interpolation (also called quadratic interpolation), we
choos e the veloc ity given by
2
v (t ) = ∑ Li ( t ) v(t i )
i =0
= L0 (t )v (t 0 ) + L1 (t ) v( t1 ) + L2 (t ) v( t 2 )
9 http://numericalmethods.eng.usf.edu
Example
The upward velocity of a rocket is given as a function of
time in Table 1. Find the velocity at t=16 seconds using
the Lagrangian method for quadratic interpolation.
Table Velocity as a
function of time
t (s) v(t ) (m/s)
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67
ys
400
f ( range)
2 t −tj t − t1 t − t 2
L0 (t ) = ∏ = (
f x desired ) 350
j =0 t0 − t j t −
0 1 0 2
t t − t
j ≠0
300
2 t −t j t − t0 t − t 2
L1 (t ) = ∏ =
j =0 t1 − t j t1 − t 0 t1 − t 2 250
j ≠1
j =0 t2 − t j −
2 0 2 1
t t t − t 10 x s , range , x desired 20
j ≠2
11 http://numericalmethods.eng.usf.edu
Quadratic Interpolation (contd)
t − t1 t − t2 t − t0 t − t 2 t − t0 t − t1
v(t ) = v(t0 ) + v(t1 ) + v(t 2 )
t0 − t1 t0 − t 2 t1 − t0 t1 − t 2 t 2 − t0 t 2 − t1
16 − 15 16 − 20 16 − 10 16 − 20 16 − 10 16 − 15
v(16) = (227 . 04 ) + (362 . 78 ) + (517.35)
10 − 15 10 − 20 15 − 10 15 − 20 20 − 10 20 − 15
= (− 0.08)(227.04) + (0.96)(362.78) + (0.12)(527.35)
= 392.19 m/s
The absolute relative approximate error ∈a obtained between the
results from the first and second order polynomial is
392.19 − 393.70
∈a = ×100
392.19
= 0.38410%
12 http://numericalmethods.eng.usf.edu
Cubic Interpolation
For the third order polynomial (also called cubic interpolation), we choose the velocity given by
3
v (t ) = ∑ Li ( t ) v(t i )
i =0
600
ys 500
f ( range)
(
f x desired )
400
300
227.04 200
10 12 14 16 18 20 22 24
10 x s , range , x desired 22.5
13 http://numericalmethods.eng.usf.edu
Example
The upward velocity of a rocket is given as a function of
time in Table 1. Find the velocity at t=16 seconds using
the Lagrangian method for cubic interpolation.
Table Velocity as a
function of time
t (s) v(t ) (m/s)
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67
700
3 t −tj t − t 1 t − t 2 t − t 3 602.97
L0 (t ) = ∏ = ;
j =0 t0 − t j t 0 − t 1 t 0 − t 2 t 0 − t 3 600
j ≠0
3 t −t j t − t0 t − t 2 t − t 3
L1 (t ) = ∏ =
ys 500
j =0 t1 − t j t1 − t 0 t1 − t 2 t1 − t 3 f ( range)
j ≠1 (
f x desired )
400
3 t −tj t − t 0 t − t1 t − t 3
L2 (t ) = ∏ = ;
t2 − t j t 2 − t 0 t 2 − t 1 t 2 − t 3
300
j =0
j ≠2
t −tj t − t 0 t − t1 t − t 2
227.04 200
3
L3 ( t ) = ∏
10 12 14 16 18 20 22 24
= 10 x s , range , x desired 22.5
j =0 t3 − t j − t t −
3 0 3 1 3 2
t t t − t
j ≠3
15 http://numericalmethods.eng.usf.edu
Cubic Interpolation (contd)
t − t1 t − t 2 t − t3 t − t0 t − t 2 t − t3
v(t ) = v(t1 ) + v(t 2 )
t 0 − t1 t 0 − t 2 t 0 − t 3 t1 − t 0 t1 − t 2 t1 − t 3
t − t0 t − t1 t − t3 t − t1 t − t1 t − t 2
+ v(t 2 ) + v(t3 )
− t −
2 0 2 1 2 3
t t t t − t t − t t −
3 1 3 1 3 2
t t − t
16 − 15 16 − 20 16 − 22.5 16 − 10 16 − 20 16 − 22.5
v(16) = (227.04 ) + (362.78)
10 − 15 10 − 20 10 − 22.5 15 − 10 15 − 20 15 − 22.5
16 − 10 16 − 15 16 − 22.5 16 − 10 16 − 15 16 − 20
+ (517.35) + (602.97 )
20 − 10 20 − 15 20 − 22 . 5 22 .5 − 10 22 .5 − 15 22. 5 − 20
= (− 0.0416 )(227.04 ) + (0.832 )(362.78) + (0.312 )(517.35) + (− 0.1024 )(602.97 )
= 392.06 m/s
The absolute relative approximate error ∈a obtained between the
results from the first and second order polynomial is
392.06 − 392.19
∈a = ×100
392.06
= 0.033269%
16 http://numericalmethods.eng.usf.edu
Comparison Table
Order of
1 2 3
Polynomial
v(t=16) m/s 393.69 392.19 392.06
Absolute Relative
-------- 0.38410% 0.033269%
Approximate Error
17 http://numericalmethods.eng.usf.edu
Distance from Velocity Profile
Find the distance covered by the rocket from t=11s to
t=16s ?
v(t ) = (t 3 − 57.5t 2 + 1087.5t − 6750)(−0.36326) + (t 3 − 52.5t 2 + 875t − 4500)(1.9348)
+ (t 3 − 47.5t 2 + 712.5t − 3375)(−4.1388) + (t 3 − 45t 2 + 650t − 3000)(2.5727)
v (t ) = −4.245 + 21.265t + 0.13195t 2 + 0.00544t 3 , 10 ≤ t ≤ 22.5
16
s(16) − s (11) = ∫ v( t ) dt
11
16
t2 t3 t 4 16
= [ −4.245t + 21.265 + 0.13195 + 0.00544 ]11
2 3 4
= 1605 m
18 http://numericalmethods.eng.usf.edu
Acceleration from Velocity Profile
Find the acceleration of the rocket at t=16s given that
dt dt
= 29.665 m / s 2
19 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/lagrange_
method.html
THE END
http://numericalmethods.eng.usf.edu
Newton’s Divided Difference
Polynomial Method of
Interpolation
http://numericalmethods.eng.usf.edu
Transforming Numerical Methods Education for STEM
Undergraduates
http://numericalmethods.eng.usf.edu 1
Newton’s Divided
Difference 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
Newton’s Divided Difference
Method
Linear interpolation: Given ( x0 , y 0 ), ( x1 , y1 ), pass a
linear interpolant through the data
f1 ( x) = b0 + b1 ( x − x0 )
where
b0 = f ( x0 )
f ( x1 ) − f ( x0 )
b1 =
x1 − x0
5 http://numericalmethods.eng.usf.edu
Example
The upward velocity of a rocket is given as a function of
time in Table 1. Find the velocity at t=16 seconds using
the Newton Divided Difference method for linear
interpolation.
Table. Velocity as a
function of time
v(t ) = b0 + b1 (t − t 0 ) 500
ys
v(t ) − v(t 0 )
b1 = 1 = 30.914 362.78
t1 − t 0
350
10 12 14 16 18 20 22 24
x s − 10 x s , range , x desired x s + 10
0 1
7 http://numericalmethods.eng.usf.edu
Linear Interpolation (contd)
550
517.35
500
ys
f ( range)
450
(
f x desired )
400
362.78 350
10 12 14 16 18 20 22 24
x s − 10 x s , range , x desired x s + 10
v(t ) = b0 + b1 (t − t 0 )
0 1
8
= 393.69 m/s http://numericalmethods.eng.usf.edu
Quadratic Interpolation
Given ( x0 , y 0 ), ( x1 , y1 ), and ( x 2 , y 2 ), fit a quadratic interpolant through the data.
f 2 ( x) = b0 + b1 ( x − x0 ) + b2 ( x − x0 )( x − x1 )
b0 = f ( x0 )
f ( x1 ) − f ( x0 )
b1 =
x1 − x0
f ( x 2 ) − f ( x1 ) f ( x1 ) − f ( x0 )
−
x 2 − x1 x1 − x0
b2 =
x 2 − x0
9 http://numericalmethods.eng.usf.edu
Example
The upward velocity of a rocket is given as a function of
time in Table 1. Find the velocity at t=16 seconds using
the Newton Divided Difference method for quadratic
interpolation.
Table. Velocity as a
function of time
500
450
ys
400
f ( range)
(
f x desired ) 350
300
250
227.04 200
10 12 14 16 18 20
10 x s , range , x desired 20
392.19 − 393.69
∈a = x100
392.19
= 0.38502 %
13 http://numericalmethods.eng.usf.edu
General Form
f 2 ( x) = b0 + b1 ( x − x0 ) + b2 ( x − x0 )( x − x1 )
where
b0 = f [ x0 ] = f ( x0 )
f ( x1 ) − f ( x 0 )
b1 = f [ x1 , x0 ] =
x1 − x0
f ( x 2 ) − f ( x1 ) f ( x1 ) − f ( x0 )
−
f [ x 2 , x1 ] − f [ x1 , x0 ] x 2 − x1 x1 − x0
b2 = f [ x 2 , x1 , x0 ] = =
x 2 − x0 x 2 − x0
Rewriting
f 2 ( x) = f [ x0 ] + f [ x1 , x0 ]( x − x0 ) + f [ x 2 , x1 , x0 ]( x − x0 )( x − x1 )
14 http://numericalmethods.eng.usf.edu
General Form
Given (n + 1) data points, ( x0 , y 0 ), ( x1 , y1 ),......, ( x n −1 , y n −1 ), ( x n , y n ) as
f n ( x) = b0 + b1 ( x − x0 ) + .... + bn ( x − x0 )( x − x1 )...( x − x n −1 )
where
b0 = f [ x0 ]
b1 = f [ x1 , x0 ]
b2 = f [ x 2 , x1 , x0 ]
bn −1 = f [ x n −1 , x n − 2 ,...., x0 ]
bn = f [ x n , x n −1 ,...., x0 ]
15 http://numericalmethods.eng.usf.edu
General form
The third order polynomial, given ( x0 , y 0 ), ( x1 , y1 ), ( x 2 , y 2 ), and ( x3 , y 3 ), is
f 3 ( x) = f [ x0 ] + f [ x1 , x0 ]( x − x0 ) + f [ x 2 , x1 , x0 ]( x − x0 )( x − x1 )
+ f [ x3 , x 2 , x1 , x0 ]( x − x0 )( x − x1 )( x − x 2 )
b0
x0 f ( x0 ) b1
f [ x1 , x0 ] b2
x1 f ( x1 ) f [ x 2 , x1 , x0 ] b3
f [ x 2 , x1 ] f [ x3 , x 2 , x1 , x0 ]
x2 f ( x2 ) f [ x3 , x 2 , x1 ]
f [ x3 , x 2 ]
x3 f ( x3 )
16 http://numericalmethods.eng.usf.edu
Example
The upward velocity of a rocket is given as a function of
time in Table 1. Find the velocity at t=16 seconds using
the Newton Divided Difference method for cubic
interpolation.
Table. Velocity as a
function of time
19 http://numericalmethods.eng.usf.edu
Example
Hence
v (t ) = b0 + b1 (t − t 0 ) + b2 (t − t 0 )( t − t1 ) + b3 (t − t 0 )( t − t1 )(t − t 2 )
= 227.04 + 27.148( t − 10) + 0.37660(t − 10)(t − 15)
+ 5.4347 * 10 −3 (t − 10)( t − 15)( t − 20)
At t = 16,
v (16) = 227.04 + 27.148(16 − 10) + 0.37660(16 − 10)(16 − 15)
+ 5.4347 * 10 −3 (16 − 10)(16 − 15)(16 − 20)
= 392.06 m/s
The absolute relative approximate error ∈a obtained is
392.06 − 392.19
∈a = x100
392.06
= 0.033427 %
20 http://numericalmethods.eng.usf.edu
Comparison Table
Order of 1 2 3
Polynomial
v(t=16) 393.69 392.19 392.06
m/s
Absolute Relative ---------- 0.38502 % 0.033427 %
Approximate Error
21 http://numericalmethods.eng.usf.edu
Distance from Velocity Profile
Find the distance covered by the rocket from t=11s to
t=16s ?
v (t ) = 227.04 + 27.148(t − 10) + 0.37660( t − 10)( t − 15)
10 ≤ t ≤ 22.5
+ 5.4347 * 10 (t − 10)( t − 15)( t − 20)
−3
16
= ∫ ( − 4.2541 + 21.265t + 0.13204t 2 + 0.0054347t 3 ) dt
11
16
t2 t3 t4
= − 4.2541t + 21.265 + 0.13204 + 0.0054347
2 3 4 11
22 = 1605 m http://numericalmethods.eng.usf.edu
Acceleration from Velocity Profile
Find the acceleration of the rocket at t=16s given that
= 29.664 m / s 2
23 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/newton_div
ided_difference_method.html
THE END
http://numericalmethods.eng.usf.edu
Spline Interpolation Method
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
Rocket Example Results
t v Polynomial Velocity at Absolute Least
(s) (m/s) Order t=16 in Relative Number of
0 0 m/s Approxima Significant
10 227.04 te Error Digits
15 362.78 Correct
20 517.35 1 393.69 -------------
22.5 602.97 2 392.19 0.38% 2
30 901.67 3 392.05 0.036% 3
4 392.07 0.0051% 3
5 392.06 0.0026% 4
5 http://numericalmethods.eng.usf.edu
Why Splines ?
6 http://numericalmethods.eng.usf.edu
Why Splines ?
8 http://numericalmethods.eng.usf.edu
Linear Interpolation (contd)
9 http://numericalmethods.eng.usf.edu
Example
The upward velocity of a rocket is given as a
function of time in Table 1. Find the velocity at
t=16 seconds using linear splines.
Table Velocity as a
function of time
(s) (m/s)
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67
Figure. Velocity vs. time data
for the rocket example
10 http://numericalmethods.eng.usf.edu
Linear Interpolation
11 http://numericalmethods.eng.usf.edu
Quadratic Interpolation
12 http://numericalmethods.eng.usf.edu
Quadratic Interpolation (contd)
13 http://numericalmethods.eng.usf.edu
Quadratic Splines (contd)
14 http://numericalmethods.eng.usf.edu
Quadratic Splines (contd)
15 http://numericalmethods.eng.usf.edu
Quadratic Splines (contd)
16 http://numericalmethods.eng.usf.edu
Quadratic Spline Example
The upward velocity of a rocket is given as a function of time.
Using quadratic splines
a) Find the velocity at t=16 seconds
Table Velocity as a
function of time
(s) (m/s)
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67 Figure. Velocity vs. time data
for the rocket example
17 http://numericalmethods.eng.usf.edu
Solution
19 http://numericalmethods.eng.usf.edu
Each Spline Goes Through
Two Consecutive Data Points
t v(t)
s m/s
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67
20 http://numericalmethods.eng.usf.edu
Derivatives are Continuous at
Interior Data Points
21 http://numericalmethods.eng.usf.edu
Derivatives are continuous at
Interior Data Points
At t=10
At t=15
At t=20
At t=22.5
22 http://numericalmethods.eng.usf.edu
Last Equation
23 http://numericalmethods.eng.usf.edu
Final Set of Equations
24 http://numericalmethods.eng.usf.edu
Coefficients of Spline
i ai bi ci
1 0 22.704 0
2 0.8888 4.928 88.88
3 −0.1356 35.66 −141.61
4 1.6048 −33.956 554.55
5 0.20889 28.86 −152.13
25 http://numericalmethods.eng.usf.edu
Quadratic Spline Interpolation
Part 2 of 2
http://numericalmethods.eng.usf.edu
26 http://numericalmethods.eng.usf.edu
Final Solution
27 http://numericalmethods.eng.usf.edu
Velocity at a Particular Point
a) Velocity at t=16
28 http://numericalmethods.eng.usf.edu
Acceleration from Velocity Profile
b) The quadratic spline valid at t=16 is
given by
29 http://numericalmethods.eng.usf.edu
Distance from Velocity Profile
c) Find the distance covered by the rocket from t=11s to
t=16s.
30 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
Linear Regression
http://numericalmethods.eng.usf.edu
Transforming Numerical Methods Education for STEM
Undergraduates
7/17/2017 http://numericalmethods.eng.usf.edu 1
Linear Regression
http://numericalmethods.eng.usf.edu
What is Regression?
What is regression? Given n data points ( x1 , y1 ), ( x2 , y2 ),......, ( xn , yn )
best fity = f (x) to the data.
Ei is= yi − f ( xi )
Residual at each point
y
( xn , y n )
( xi , yi )
Ei = yi − f ( xi )
y = f (x)
( x1 , y1 )
x
http://numericalmethods.eng.usf.edu 3
Linear Regression-Criterion#1
Given n data points ( x1 , y1 ), ( x2 , y2 ),......, ( xn , yn ) best fit y = a 0 + a1 x to the data.
n
Does minimizing∑ Ei work as a criterion?
i =1
( xi , yi )
Ei = yi − a0 − a1 xi ( xn , y n )
( x2 , y 2 )
( x3 , y3 )
y = a0 + a1 x
( x1 , y1 )
x
Figure. Linear regression of y vs x data showing residuals at a typical point, xi .
http://numericalmethods.eng.usf.edu 4
Example for Criterion#1
Example: Given the data points (2,4), (3,6), (2,6) and (3,8), best fit
the data to a straight line using Criterion#1
n
Minimize ∑ Ei
i =1
Table. Data Points 10
8
x y
2.0 4.0 6
y
3.0 6.0 4
2.0 6.0 2
3.0 8.0 0
0 1 2 3 4
8
x y ypredicted E = y - ypredicted
6
2.0 4.0 4.0 0.0
y 4
3.0 6.0 8.0 -2.0
2
2.0 6.0 4.0 2.0
0
3.0 8.0 8.0 0.0 0 1 2 3 4
4
x
∑ Ei = 0
i =1
http://numericalmethods.eng.usf.edu 6
Linear Regression-Criterion#1
Using y=6 as a regression curve
Table. Residuals at each point
for regression model y=6 10
x y ypredicted E = y - ypredicted 8
2.0 4.0 6.0 -2.0 6
3.0 6.0 6.0 0.0
y
4
2.0 6.0 6.0 0.0 2
3.0 8.0 6.0 2.0 0
4 0 1 2 3 4
∑ Ei = 0
i =1
x
http://numericalmethods.eng.usf.edu 7
Linear Regression – Criterion #1
4
∑ Ei = 0 for both regression models of y=4x-4 and y=6
i =1
6
y
0
0 1 2 3 4
http://numericalmethods.eng.usf.edu 8
Linear Regression-Criterion#1
8
x y ypredicted E = y - ypredicted
6
2.0 4.0 4.0 0.0
y 4
3.0 6.0 8.0 -2.0
2
2.0 6.0 4.0 2.0
0
3.0 8.0 8.0 0.0 0 1 2 3 4
4
x
∑ Ei = 0
i =1
http://numericalmethods.eng.usf.edu 9
Linear Regression-Criterion#2
n
Will minimizing∑ | Ei | work any better?
i =1
( xi , yi )
Ei = yi − a0 − a1 xi ( xn , y n )
( x2 , y 2 )
( x3 , y3 )
y = a0 + a1 x
( x1 , y1 )
x
Figure. Linear regression of y vs. x data showing residuals at a typical point, xi .
http://numericalmethods.eng.usf.edu 10
Example for Criterion#2
Example: Given the data points (2,4), (3,6), (2,6) and (3,8), best fit
n
the data to a straight line using Criterion#2
Minimize ∑ | Ei |
i =1
Table. Data Points 10
8
x y
6
2.0 4.0
y
4
3.0 6.0
2
2.0 6.0
0
3.0 8.0 0 1 2 3 4
http://numericalmethods.eng.usf.edu 12
Linear Regression-Criterion#2
Using y=6 as a regression curve
Table. Residuals at each point
for regression model y=6 10
x y ypredicted E = y - ypredicted 8
2.0 4.0 6.0 -2.0 6
3.0 6.0 6.0 0.0
y
4
2.0 6.0 6.0 0.0 2
3.0 8.0 6.0 2.0 0
4 0 1 2 3 4
∑ | Ei | = 4
i =1
x
http://numericalmethods.eng.usf.edu 13
Linear Regression-Criterion#2
4
∑ Ei = 4 for both regression models of y=4x − 4 and y=6.
i =1
http://numericalmethods.eng.usf.edu 14
Least Squares Criterion
The least squares criterion minimizes the sum of the square of the
residuals in the model, and also produces a unique line.
n n 2
S r = ∑ Ei = ∑ ( yi − a0 − a1 xi )
2
i =1 i =1
xi , yi
Ei = yi − a0 − a1 xi xn , y n
x2 , y 2
x ,y
3 3
y = a0 + a1 x
x1 , y1
http://numericalmethods.eng.usf.edu 15
Finding Constants of Linear Model
n n 2
Minimize the sum of the square of the residuals: S r = ∑ Ei = ∑ ( yi − a0 − a1 xi )
2
i =1 i =1
To find a 0 and a1 we minimize Sr with respect to a1 and a 0 .
∂S r n
= −2∑ ( y i − a 0 − a1 xi )(− 1) = 0
∂a 0 i =1
∂S r n
= −2∑ ( y i − a 0 − a1 xi )(− xi ) = 0
∂a1 i =1
giving
n n n
∑a + ∑a x = ∑ y
i =1
0
i =1
1 i
i =1
i
n n n
∑a x + ∑a x = ∑ yi xi
2
0 i 1 i
i =1 i =1 i =1
16 http://numericalmethods.eng.usf.edu
Finding Constants of Linear Model
Solving for a 0 and a1 directly yields,
n n n
n∑ x i y i −∑ x i ∑ y i
i =1 i =1 i =1
a1 = 2
2
n n
n∑ x i − ∑ x i
i =1 i =1
and
n n n n
∑x ∑y −∑x ∑x y
2
i i i i i
a0 = i =1 i =1 i =1 i =1 a 0 = y − a1 x
2
n
n
n∑ x − ∑ x i
2
i
i =1 i =1
17 http://numericalmethods.eng.usf.edu
Example 1
The torque, T needed to turn the torsion spring of a mousetrap through
an angle, is given below. Find the constants for the model given by
T = k 1 + k 2θ
Angle, θ Torque, T
Torque (N-m)
0.3
Radians N-m
0.2
0.698132 0.188224
0.959931 0.209138
1.134464 0.230052 0.1
0.5 1 1.5 2
1.570796 0.250965 θ (radians)
1.919862 0.313707
Figure. Data points for Torque vs Angle data
18 http://numericalmethods.eng.usf.edu
Example 1 cont.
The following table shows the summations needed for the calculations of
the constants in the regression model.
Table. Tabulation of data for calculation of important
summations
Using equations described for
θ T θ2 Tθ
a 0 and a1 with n = 5
Radians N-m Radians2 N-m-Radians 5 5 5
0.698132 0.188224 0.487388 0.131405 n ∑ θ i Ti −∑ θ i ∑ Ti
0.959931 0.209138 0.921468 0.200758 k2 = i =1 i =1 i =1
2
2
5 5
1.134464 0.230052 1.2870 0.260986
n ∑ θ i − ∑ θ i
1.570796 0.250965 2.4674 0.394215 i =1 i =1
5(1.5896) − (6.2831)(1.1921)
1.919862 0.313707 3.6859 0.602274
5
=
∑=
i =1
6.2831 1.1921 8.8491 1.5896 5(8.8491) − (6.2831)
2
= 9.6091×10 −2 N-m/rad
19 http://numericalmethods.eng.usf.edu
Example 1 cont.
Use the average torque and average angle to calculate k1
5 5
_ ∑T i _ ∑θ i
T= i =1
θ= i =1
n n
1.1921 6.2831
= =
5 5
= 2.3842 × 10 −1 = 1.2566
Using,
_ _
k1 = T − k 2 θ
= 2.3842 × 10 −1 − (9.6091 × 10 −2 )(1.2566)
= 1.1767 × 10 −1 N-m
20 http://numericalmethods.eng.usf.edu
Example 1 Results
Using linear regression, a trend line is found from the data
Can you find the energy in the spring if it is twisted from 0 to 180 degrees?
21 http://numericalmethods.eng.usf.edu
Linear Regression (special case)
Given
best fit
y = a1 x
to the data.
22 http://numericalmethods.eng.usf.edu
Linear Regression (special case cont.)
y = a1 x
n n n
n∑ x i y i −∑ x i ∑ y i
i =1 i =1 i =1
a1 = 2
n
n
n∑ x i2 − ∑ x i
i =1 i =1
Is this correct?
23 http://numericalmethods.eng.usf.edu
Linear Regression (special case cont.)
y
xi , yi
ε i = yi − a1 xi xn , y n
xi , a1 xi
x1 , y1
24 http://numericalmethods.eng.usf.edu
Linear Regression (special case cont.)
ε i = yi − a1 xi
Sum of square of residuals
n
Sr = ∑ ε i
2
i =1
n 2
= ∑ ( yi − a1 xi )
i =1
25 http://numericalmethods.eng.usf.edu
Linear Regression (special case cont.)
Differentiate with respect to a1
dS r n
= ∑ 2( y i − a1 xi )(− xi )
da1 i =1
( )
n
= ∑ − 2 yi xi + 2a1 xi
2
i =1
dS r
=0
da1
gives
n
∑x y i i
a1 = i =1
n
∑ i
x 2
i =1
26 http://numericalmethods.eng.usf.edu
Linear Regression (special case cont.)
Does this value of a1 correspond to a local minima or local
maxima? n
∑x y i i
a1 = i =1
n
∑ i
x 2
i =1
dS r
( )
n
= ∑ − 2 y i xi + 2a1 xi
2
da1 i =1
d 2Sr n
= ∑ 2 xi > 0
2
2
da1 i =1
∑x y i i
a1 = i =1
n
∑x
i =1
2
i
27 http://numericalmethods.eng.usf.edu
Linear Regression (special case cont.)
Is this local minima of Sr an absolute minimum of S r?
Sr
a1
28 http://numericalmethods.eng.usf.edu
Example 2
To find the longitudinal modulus of composite, the following data is
collected. Find the longitudinal modulus, E using the regression model
Table. Stress vs. Strain data σ = Eε and the sum of the square of the
Strain Stress
(%) (MPa)
residuals.
0 0 3.0E+09
0.183 306
0.36 612 Stress, σ (Pa)
2.0E+09
0.5324 917
0.702 1223
0.867 1529 1.0E+09
1.0244 1835
1.1774 2140
0.0E+00
1.329 2446
0 0.005 0.01 0.015 0.02
1.479 2752
Strain, ε (m/m)
1.5 2767
1.56 2896 Figure. Data points for Stress vs. Strain data
29 http://numericalmethods.eng.usf.edu
Example 2 cont.
n
Table. Summation data for regression model ∑σ ε i i
i ε σ ε2 εσ E= i =1
n
∑ε
2
1 0.0000 0.0000 0.0000 0.0000 i
2 1.8300×10−3 3.0600×108 3.3489×10−6 5.5998×105 i =1
12
3
4
3.6000×10−3
5.3240×10−3
6.1200×108
9.1700×108
1.2960×10−5
2.8345×10−5
2.2032×106
4.8821×106
∑ε
i =1
i
2
= 1.2764 × 10 −3
5 7.0200×10−3 1.2230×109 4.9280×10−5 8.5855×106 12
30 http://numericalmethods.eng.usf.edu
Example 2 Results
The equation σ = 182.84 × 10 9 ε describes the data.
31 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/linear_regr
ession.html
THE END
http://numericalmethods.eng.usf.edu
Adequacy of Linear
Regression Models
http://numericalmethods.eng.usf.edu
Transforming Numerical Methods Education for STEM
Undergraduates
3/25/2015 http://numericalmethods.eng.usf.edu 1
Data
y vs x
6.5
5.5
4.5
y
3.5
2.5
2
-350 -300 -250 -200 -150 -100 -50 0 50 100
x
Is this adequate?
y vs x
7
6.5
5.5
5
y
4.5
3.5
2.5
2
-350 -300 -250 -200 -150 -100 -50 0 50 100
x
Straight Line Model
Quality of Fitted Data
• Does the model describe the data
adequately?
α = a0 + a1T
-340 2.45
-260 3.58
-180 4.52
-100 5.28
-20 5.86
60 6.36
END
1. Plot the data and the model
Data and model
α (T ) = 6.0325 + 0.0096964T
T α 7
6.5
(F) (μin/in/F) 6
-260 3.58 α 5
4.5
-180 4.52 4
3
-20 5.86
2.5
60 6.36 2
-350 -300 -250 -200 -150 -100 -50 0 50 100
T
END
2. Find the standard error of estimate
Standard error of estimate
Sr
sα / T =
n−2
n
S r = ∑ (α i − a0 − a1Ti ) 2
i =1
Standard Error of Estimate
α (T ) = 6.0325 + 0.0096964T
Ti αi a 0 + a1Ti α i − a 0 − a1Ti
S r = 0.25283
Sr
sα / T =
n−2
0.25283
=
6−2
= 0.25141
Standard Error of Estimate
8
6
α
2
-350 -300 -250 -200 -150 -100 -50 0 50 100
T
α i − a0 − a1Ti
Scaled Residual =
sα / T
Scaled Residuals
Residual
Scaled Residual =
Standard Error of Estimate
α i − a0 − a1Ti
Scaled Residual =
sα / T
Scaled
Ti αi Residual
Residual
-340 2.45 -0.28571 -1.1364
-260 3.58 0.068571 0.27275
-180 4.52 0.23286 0.92622
-100 5.28 0.21714 0.86369
-20 5.86 0.021429 0.085235
60 6.36 -0.25429 -1.0115
END
3. Find the coefficient of
determination
Coefficient of determination
n
S t = ∑ (α i − α )
2
i =1
n
S r = ∑ (α i − a0 − a1Ti )
2
i =1
St − S r
r = 2
St
Sum of square of residuals between
data and mean
n
S t = ∑ ( yi − y )
2
i =1
( xn , y n )
( xi , y i )
y
_
y−y _
y=y
(x2 , y 2 )
( x3 , y 3 )
(x1 , y1 )
x
Sum of square of residuals between
observed and predicted
n
S r = ∑ ( yi − a0 − a1 xi )
2
i =1
( xn , y n )
( xi , y i )
y
Ei = yi − a0 − a1 xi
(x2 , y 2 )
( x3 , y 3 )
(x1 , y1 )
x
Limits of Coefficient of
Determination
St − S r
r =
2
St
0 ≤ r ≤1
2
Calculation of St
Ti αi αi − α
-340 2.45 -2.2250 α = 4.6750
-260 3.58 -1.0950
-180 4.52 0.15500
S t = 10.783
-100 5.28 0.60500
-20 5.86 1.1850
60 6.36 1.6850
Calculation of Sr
Ti αi a 0 + a1Ti α i − a 0 − a1Ti
-340 2.45 2.7357 -0.28571
-260 3.58 3.5114 0.068571
-180 4.52 4.2871 0.23286
-100 5.28 5.0629 0.21714
-20 5.86 5.8386 0.021429
60 6.36 6.6143 -0.25429
S r = 0.25283
Coefficient of determination
St − Sr
r =
2
St
10.783 − 0.25283
=
10.783
= 0.97655
Correlation coefficient
St − Sr
r=
St
= 0.98820
100
90
80
Final Exam Grade
70
60
50
40
0 10 20 30 40 50 60
Student No
Final Exam Grade vs Pre-Req
GPA
y = 9.8669x + 41.75
R² = 0.2227
100 R=0.4719
90
80
FInal Exam Scores
70
60
50
40
1 1.5 2 2.5 3 3.5 4 4.5 5
Pre-Requisite GPA
END
4. Model meets assumption of random
errors
Model meets assumption of random
errors
• Residuals are negative as well as
positive
• Variation of residuals as a function of the
independent variable is random
• Residuals follow a normal distribution
• There is no autocorrelation between the
data points.
Therm exp coeff vs temperature
T α T α T α
60 6.36 -100 5.28 -280 3.33
40 6.24 -120 5.09 -300 3.07
20 6.12 -140 4.91 -320 2.76
0 6.00 -160 4.72 -340 2.45
-20 5.86 -180 4.52
-40 5.72 -200 4.30
-60 5.58 -220 4.08
-80 5.43 -240 3.83
Data and model
α = 6.0248 + 0.0093868T
7
6.5
5.5
5
α
4.5
3.5
2.5
2
-350 -300 -250 -200 -150 -100 -50 0 50 100
T
Plot of Residuals
0.3
0.2
0.1
Residual
-0.1
-0.2
-0.3
-0.4
-350 -300 -250 -200 -150 -100 -50 0 50 100
T
Histograms of Residuals
Check for Autocorrelation
• Find the number of times, q the sign of the
residual changes for the n data points.
• If (n-1)/2-√(n-1) ≤q≤ (n-1)/2+√(n-1), you
most likely do not have an autocorrelation.
( 22 − 1) 22 − 1
− 22 − 1 ≤ q ≤ + 22 − 1
2 2
5.9174 ≤ q ≤ 15.083
Is there autocorrelation?
0.3
0.2
0.1
Residual
-0.1
5.9174 ≤ q ≤ 15.083
-0.2
-0.3
-0.4
-350 -300 -250 -200 -150 -100 -50 0 50 100
T
y vs x fit and residuals
n=40
(n-1)/2-√(n-1) ≤p≤ (n-1)/2+√(n-1)
Is 13.3≤21≤ 25.7? Yes!
y vs x fit and residuals
n=40
(n-1)/2-√(n-1) ≤p≤ (n-1)/2+√(n-1)
Is 13.3≤2≤ 25.7? No!
END
What polynomial model to choose
if one needs to be chosen?
First Order of Polynomial
-6 Polynomial Regression of order 1
x 10
7
6.5
6
y = a +a *x+a *x 2+.....+a *x m
5.5
m
4.5
2
4
1
0
3.5
2.5
2
-350 -300 -250 -200 -150 -100 -50 0 50 100
Second Order Polynomial
-6 Polynomial Regression of order 2
x 10
7
6.5
6
y = a +a *x+a *x 2+.....+a *x m
5.5
m
4.5
2
4
1
0
3.5
2.5
2
-350 -300 -250 -200 -150 -100 -50 0 50 100
x
Which model to choose?
y vs x
7
6.5
5.5
5
y
4.5
3.5
2.5
2
-350 -300 -250 -200 -150 -100 -50 0 50 100
x
-14
Optimum Polynomial
x 10 Optimum Order of Polynomial
4
Sr÷[n-(m+1)]
0
0 1 2 3 4 5 6
Order of Polynomial, m
THE END
Effect of an Outlier
Effect of Outlier
25
y = 2x
20
R2 = 1
15
10
0
0 2 4 6 8 10 12
Effect of Outlier
60
50 y = 3.2727x - 5.0909
R2 = 0.6879
40
30
20
10
0
0 2 4 6 8 10 12
-10
Nonlinear Regression
http://numericalmethods.eng.usf.edu
Transforming Numerical Methods Education for STEM
Undergraduates
3/19/2015 http://numericalmethods.eng.usf.edu 1
Nonlinear Regression
http://numericalmethods.eng.usf.edu
Nonlinear Regression
Some popular nonlinear regression models:
3 http://numericalmethods.eng.usf.edu
Nonlinear Regression
Given n data points ( x1, y1), ( x 2, y 2), ... , ( xn, yn ) best fit y = f (x)
to the data, where f (x) is a nonlinear function of x .
( xn , y n )
( x2 , y 2 )
y = f (x)
( xi , yi )
y − f (x )
i i
( x1 , y1 )
4 http://numericalmethods.eng.usf.edu
Regression
Exponential Model
5 http://numericalmethods.eng.usf.edu
Exponential Model
Given ( x1 , y1 ), ( x 2 , y 2 ), ... , ( x n , y n ) best fit y = ae to the data.
bx
( x1 , y1 )
y = aebx
yi − aebxi
(x , y )
i i
( x2 , y 2 )
( xn , y n )
6 http://numericalmethods.eng.usf.edu
Finding Constants of Exponential Model
The sum of the square of the residuals is defined as
( )
n
Sr = ∑ yi − ae
bx 2
i
i =1
Differentiate with respect to a and b
∂S r
( )( )
n
= ∑ 2 y i − ae bxi − e bxi = 0
∂a i =1
∂S r
( )( )
n
= ∑ 2 y i − ae bxi
− axi e = 0
bxi
∂b i =1
7 http://numericalmethods.eng.usf.edu
Finding Constants of Exponential Model
Rewriting the equations, we obtain
n n
− ∑ yi e bxi
+ a∑e 2bxi
=0
i =1 i =1
n n
∑ y i xi e
bxi
− a ∑ xi e 2bxi
=0
i =1 i =1
8 http://numericalmethods.eng.usf.edu
Finding constants of Exponential Model
Solving the first equation for a yields
n
bxi
∑ yi e
i =1
a= n
2bxi
∑ e
i =1
t(hrs) 0 1 3 5 7 9
γ 1.000 0.891 0.708 0.562 0.447 0.355
10 http://numericalmethods.eng.usf.edu
Example 1-Exponential Model cont.
The relative intensity is related to time by the equation
λt
γ = Ae
Find:
a) The value of the regression constants A and λ
b) The half-life of Technetium-99m
c) Radiation intensity after 24 hours
11 http://numericalmethods.eng.usf.edu
Plot of data
12 http://numericalmethods.eng.usf.edu
Constants of the Model
γ = Ae λt
∑ i
γ e λt i
A= i =1
n
∑ e 2 λt i
i =1
13 http://numericalmethods.eng.usf.edu
Setting up the Equation in MATLAB
n
λti
n
∑γ ie n
f (λ ) = ∑ γ i t i e λti
− i =1
n
∑ ti e
2λti
=0
i =1 2λti i =1
∑e
i =1
t (hrs) 0 1 3 5 7 9
γ 1.000 0.891 0.708 0.562 0.447 0.355
14 http://numericalmethods.eng.usf.edu
Setting up the Equation in MATLAB
n
λti
n
∑γ ie n
f (λ ) = ∑ γ i t i e λti
− i =1
n
∑ i
t e 2λti
=0
i =1 2λti i =1
∑e
i =1
λ = −0.1151
t=[0 1 3 5 7 9]
gamma=[1 0.891 0.708 0.562 0.447 0.355]
syms lamda
sum1=sum(gamma.*t.*exp(lamda*t));
sum2=sum(gamma.*exp(lamda*t));
sum3=sum(exp(2*lamda*t));
sum4=sum(t.*exp(2*lamda*t));
f=sum1-sum2/sum3*sum4;
15 http://numericalmethods.eng.usf.edu
Calculating the Other Constant
The value of A can now be calculated
6
∑γ e i
λti
A= i =1
6 = 0.9998
∑ e 2 λti
i =1
γ = 0.9998 e −0.1151t
16 http://numericalmethods.eng.usf.edu
Plot of data and regression curve
γ = 0.9998 e −0.1151t
17 http://numericalmethods.eng.usf.edu
Relative Intensity After 24 hrs
The relative intensity of radiation after 24 hours
−0.1151( 24 )
γ = 0.9998 × e
−2
= 6.3160 × 10
This result implies that only
6.316 × 10−2
× 100 = 6.317%
0.9998
radioactive intensity is left after 24 hours.
18 http://numericalmethods.eng.usf.edu
Homework
• What is the half-life of Technetium-99m
isotope?
• Write a program in the language of your
choice to find the constants of the
model.
• Compare the constants of this regression
model with the one where the data is
transformed.
λt
• What if the model was γ = e ?
19 http://numericalmethods.eng.usf.edu
THE END
http://numericalmethods.eng.usf.edu
20 http://numericalmethods.eng.usf.edu
Polynomial Model
best fit y = a0 + a1 x + ... + am x
m
Given ( x1, y1), ( x 2, y 2), ... , ( xn, yn)
(m ≤ n − 2) to a given data set.
( xn , y n )
( x2 , y 2 )
( xi , yi ) y = a + a x + + am x m
0 1
yi − f ( xi )
( x1 , y1 )
21 http://numericalmethods.eng.usf.edu
Polynomial Model cont.
The residual at each data point is given by
Ei = y i − a 0 − a1 xi − . . . − a m xim
The sum of the square of the residuals then is
n
S r = ∑ Ei2
i =1
( )
n
= ∑ y i − a 0 − a1 xi − . . . − a m xim
2
i =1
22 http://numericalmethods.eng.usf.edu
Polynomial Model cont.
To find the constants of the polynomial model, we set the derivatives
with respect to ai where i = 1, m, equal to zero.
∂S r
( )
n
= ∑ 2. yi − a0 − a1 xi − . . . − am xim (−1) = 0
∂a0 i =1
∂S r
( )
n
= ∑ 2. yi − a0 − a1 xi − . . . − am xim (− xi ) = 0
∂a1 i =1
∂S r
( )
n
= ∑ 2. yi − a0 − a1 xi − . . . − am xim (− xim ) = 0
∂am i =1
23 http://numericalmethods.eng.usf.edu
Polynomial Model cont.
These equations in matrix form are given by
n
n n n m
∑ xi . ∑ xi a
∑ yi
. .
i =1 i =1 0
ni =1
n
∑ xi n 2 n m+1 a1
∑ xi . . . ∑ xi = ∑x y
i =1 . . . i =1
i i
i =1 i =1
. . . . . . . . . . . a . . .
m
n m n m+1
n
∑ xim yi
n
∑ xi ∑ xi . . . ∑ xi2 m
i =1
i =1 i =1 i =1
24 http://numericalmethods.eng.usf.edu
Example 2-Polynomial Model
Regress the thermal expansion coefficient vs. temperature data to
a second order polynomial.
40 6.24×10−6
3.00E-06
−40 5.72×10−6
−120 5.09×10−6 2.00E-06
n n 2 n
n ∑ Ti ∑ Ti ∑ αi
i =1 i =1 a i =1
0
n n 2 n 3 n
∑ i
T ∑ Ti ∑ Ti a1 = ∑ Ti α i
i =n1 i =1 i =1 i =1
n
n 4 2 T 2α
a
T 2 n 3
∑ i ∑ Ti ∑ Ti
∑ i i
i =1 i =1 i =1 i =1
26 http://numericalmethods.eng.usf.edu
Example 2-Polynomial Model cont.
The necessary summations are as follows
7
α
Table. Data points for temperature vs.
Temperature, T Coefficient of
∑T
i =1
i
2
=2.5580 ×105
(oF) thermal expansion,
7
∑T
α (in/in/oF)
i
3
= − 7.0472 × 10 7
80 6.47×10−6
i =1
40 6.24×10−6 7
−40 5.72×10−6 ∑T
i =1
i
4
= 2.1363 ×1010
−120 5.09×10−6
7
∑α
−200 4.30×10−6
i = 3.3600 × 10 −5
−280 3.33×10−6
i =1
−340 2.45×10−6 7
∑T α
i =1
i i = − 2.6978 × 10 −3
7
∑T
i =1
i
2
α i =8.5013 × 10 −1
27 http://numericalmethods.eng.usf.edu
Example 2-Polynomial Model cont.
Using these summations, we can now calculate a0 ,a1 , a2
7.0000 − 8.6000 × 10 2 2.5800 × 10 5 a 0 3.3600 × 10 −5
− 8. 600 × 10 2
2.5800 × 10 5 − 7.0472 × 10 7 a1 = − 2.6978 × 10 −3
2.5800 × 10 5
− 7.0472 × 10 7 2.1363 × 1010 a 2 8.5013 × 10 −1
Solving the above system of simultaneous linear equations we have
a 0 6.0217 × 10
−6
a = 6.2782 × 10 −9
1
a 2 − 1.2218 × 10
−11
28 http://numericalmethods.eng.usf.edu
Transformation of Data
To find the constants of many nonlinear models, it results in solving
simultaneous nonlinear equations. For mathematical convenience,
some of the data for such models can be transformed. For example,
the data for an exponential model can be transformed.
As shown in the previous example, many chemical and physical processes
are governed by the equation,
y = aebx
Taking the natural log of both sides yields,
ln y = ln a + bx
Let z = ln y and a 0 = ln a
We now have a linear regression model where z = a 0 + a1 x
(implying) a = e ao with a1 = b
29 http://numericalmethods.eng.usf.edu
Transformation of data cont.
Using linear model regression methods,
n n n
n∑ xi z i − ∑ xi ∑ z i
a1 = i =1 i =1 i =1
2
n
n
n∑ xi2 − ∑ xi
i =1 i =1
_ _
a 0 = z − a1 x
Once ao , a1 are found, the original constants of the model are found as
b = a1
a = e a0
30 http://numericalmethods.eng.usf.edu
THE END
http://numericalmethods.eng.usf.edu
31 http://numericalmethods.eng.usf.edu
Example 3-Transformation of
data
Many patients get concerned when a test involves injection of a radioactive
material. For example for scanning a gallbladder, a few drops of Technetium-
99m isotope is used. Half of the Technetium-99m would be gone in about 6
hours. It, however, takes about 24 hours for the radiation levels to reach what
we are exposed to in day-to-day activities. Below is given the relative intensity
of radiation as a function of time.
1
Table. Relative intensity of radiation as a function
0
0 5 10
Time t, (hours)
33 http://numericalmethods.eng.usf.edu
Example 3-Transformation of data
cont.
Exponential model given as,
γ = Ae λt
ln (γ ) = ln( A) + λt
Assuming z = ln γ , ao = ln ( A) and a1 = λ we obtain
z =a +at
0 1
This is a linear relationship between z and t
34 http://numericalmethods.eng.usf.edu
Example 3-Transformation of data cont.
Using this linear relationship, we can calculate a0 , a1 where
n n n
n ∑ ti zi − ∑ ti ∑ zi
a1 = i =1 i =1 i =1
2
n
n
n ∑ t 2 − ∑ ti
i =1
1
i =1
and
a0 = z − a1t
λ = a1
a
A=e 0
35 http://numericalmethods.eng.usf.edu
Example 3-Transformation of Data
cont.
Summations for data transformation are as follows
i ti γi
model
z = ln γ ti zi t 2 ∑t
i =1
i = 25.000
i i i
6
∑z
1 0 1 0.00000 0.0000 0.0000
2 1 0.891 −0.11541 −0.11541 1.0000 = −2.8778
i
3 3 0.708 −0.34531 −1.0359 9.0000 i =1
4 5 0.562 −0.57625 −2.8813 25.000 6
5
6
7
9
0.447
0.355
−0.80520
−1.0356
−5.6364
−9.3207
49.000
81.000 ∑t z
i =1
i i
= −18.990
∑
6
−2.8778 −18.990
∑t
25.000 165.00
i
2
= 165.00
i =1
36 http://numericalmethods.eng.usf.edu
Example 3-Transformation of Data
cont.
Calculating a0 , a1
6(− 18.990) − (25)(− 2.8778)
a1 = = −0.11505
6(165.00) − (25)
2
− 2.8778
− (− 0.11505)
25 = −2.6150 × 10 −4
a0 =
6 6
Since
a0 = ln ( A)
A = e a0
− 2.6150×10−4
=e = 0.99974
also
λ = a1 = −0.11505
37 http://numericalmethods.eng.usf.edu
Example 3-Transformation of Data
cont.
Resulting model is γ = 0.99974 × e
−0.11505t
1
γ = 0.99974 × e −0.11505t
Relative
Intensity
0.5
of
Radiation,
0
0 5 10
Time, t (hrs)
38 http://numericalmethods.eng.usf.edu
Example 3-Transformation of Data
cont.
The regression formula is then
γ = 0.99974 × e −0.11505t
1
b) Half life of Technetium-99m is when γ = γ
2 t =0
39 http://numericalmethods.eng.usf.edu
Example 3-Transformation of Data
cont.
c) The relative intensity of radiation after 24 hours is then
γ = 0.99974e −0.11505(24 )
= 0.063200
6.3200 ×10 −2
This implies that only ×100 = 6.3216% of the radioactive
0.99983
material is left after 24 hours.
40 http://numericalmethods.eng.usf.edu
Comparison
Comparison of exponential model with and without data
Transformation:
Table. Comparison for exponential model with and without data
Transformation.
With data Without data
Transformation Transformation
(Example 3) (Example 1)
A 0.99974 0.99983
λ −0.11505 −0.11508
Half-Life (hrs) 6.0248 6.0232
Relative intensity
6.3200×10−2 6.3160×10−2
after 24 hrs.
41 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/nonlinear_r
egression.html
THE END
http://numericalmethods.eng.usf.edu