Differentiation of discrete Function

advertisement
Differentiation-Discrete
Functions
Mechanical Engineering Majors
Authors: Autar Kaw, Sri Harsha Garapati
http://numericalmethods.eng.usf.edu
Transforming Numerical Methods Education for STEM
Undergraduates
4/13/2015
http://numericalmethods.eng.usf.edu
1
Differentiation –
ContinuousDiscrete
Functions
http://numericalmethods.eng.usf.edu
Forward Difference
Approximation
lim f x  Δx   f x 
f x  
Δx  0
Δx
For a finite ' Δx'
f  x  x   f  x 
f  x  
x
3
http://numericalmethods.eng.usf.edu
Graphical Representation Of
Forward Difference
Approximation
f(x)
x
x+Δx
Figure 1 Graphical Representation of forward difference approximation of first derivative.
4
http://numericalmethods.eng.usf.edu
Example 1
To find contraction of a steel cylinder immersed in a bath of liquid nitrogen,
one needs to know the thermal expansion coefficient data as a function of
temperature. This data is given for steel in Table 1.
a) Is the rate of change of coefficient of thermal expansion with respect
to temperature more at T  80 F than at T  340 F ?
b) The data given in Table 1 can be regressed to α  a0  a1T  a2T2 to get
.α  6.0216106  6.2790109 T 1.22151011 T 2. Compare the results with
part (a) if you used the regression curve to find the rate of change of
the coefficient of thermal expansion with respect to temperature at
.T  80 F and at T  340 F .
5
http://numericalmethods.eng.usf.edu
Example 1 Cont.
Table 1 Coefficient of thermal expansion as a function of temperature.
6
Temperature, T
(oF)
Coefficient of
thermal expansion,
α (in/in/oF)
80
6.47 10
40
6.24 10
−40
5.72 10
−120
−200
−280
−340
5.09 106
6
4.30 10
3.33 106
6
2.45 10
6
6
6
http://numericalmethods.eng.usf.edu
Example 1 Cont.
Solution
a) Using the forward divided difference approximation method at T  800 F,
d (Ti )  Ti 1    Ti 

dT
T
Ti  80
T  40
Ti 1  Ti  T
 80   40
 40
7
http://numericalmethods.eng.usf.edu
Example 1 Cont.
d (80)  40   80

dT
 40
6.24106  6.47 106

40
 5.75109 in/in/F2
Using backwards divided difference approximation method at
T  3400 F,
d (Ti )  Ti    Ti 1 

dT
T
8
Ti  340
T  60
Ti 1  Ti  T
 340  60
 280
http://numericalmethods.eng.usf.edu
Example 1 Cont.
d (340)   340    280

dT
 60
2.45106  3.33106

 60
 0.14667107 in/in/F2
From the above two results it is clear that the rate of change of coefficient
0
0
of thermal expansion is more at T  80 F than at T  340 F .
b) Given
α  6.0216106  6.2790109 T  1.22151011T 2
dα
 6.279 10 9  2.443 10 11 T
dT
dα80
 6.279109  2.4431011 80
dT
 4.3246109 in/in/F2
9
http://numericalmethods.eng.usf.edu
Example 1 Cont.
dα 340
 6.279109  2.4431011 - 340
dT
 0.14585107 in/in/F2
Table 2 Summary of change in coefficient of thermal expansion using
different approximations.
Change in Coefficient of Thermal Expansion,
Temperature, Ti
10
d
Ti 
dT
Divided Difference
Approximation
2nd Order Polynomial
Regression
800F
5.75  109 in / in/ o F 2
4.3246109 in / in/ oF 2
 3400F
0.14667107 in / in/ oF 2
0.14585107 in / in/ oF 2
http://numericalmethods.eng.usf.edu
Direct Fit Polynomials
In this method, given ' n  1' data points x0 , y0 , x1 , y1 , x2 , y2 ,, xn , yn 
one can fit a
n th order polynomial given by
Pn x  a0  a1x    an 1xn 1  an xn
To find the first derivative,
Pnx  
dPn ( x )
 a1  2a 2 x    n  1a n 1 x n 2  na n x n 1
dx
Similarly other derivatives can be found.
11
http://numericalmethods.eng.usf.edu
Example 2-Direct Fit Polynomials
To find contraction of a steel cylinder immersed in a bath of liquid nitrogen,
one needs to know the thermal expansion coefficient data as a function of
temperature. This data is given for steel in Table 3.
a) Using the third order polynomial interpolant, find the change in
coefficient of thermal expansion at T  80F and T  340F.
b) The data given in Table 3 can be regressed to α  a0  a1T  a2T 2 to get
. α  6.0216106  6.2790109 T 1.22151011 T 2 . Compare the results
with part (a) if you used the regression curve to find the rate of
change of the coefficient of thermal expansion with respect to
temperature at T  80F and T  340F .
12
http://numericalmethods.eng.usf.edu
Example 2 Cont.
Table 3 Coefficient of thermal expansion as a function of temperature.
13
Temperature, T
(oF)
Coefficient of
thermal expansion,
α (in/in/oF)
80
6.47 10
40
6.24 10
−40
5.72 10
−120
−200
−280
−340
5.09 106
6
4.30 10
3.33 106
6
2.45 10
6
6
6
http://numericalmethods.eng.usf.edu
Example 2-Direct Fit Polynomials cont.
Solution
For the third order polynomial interpolation (also called cubic interpolation), we
choose the coefficient of thermal expansion given by
 t   a0  a1T  a2T 2  a3T 3
a)
Change in Thermal Expansion Coefficient at 800 F :
Since we want to find the rate of change in the thermal expansion
0
coefficient at T  80 F, and we are using a third order polynomial, we need
0
0
to choose the four points closest to T  80 F that also bracket T  80 F to
evaluate it.
The four points are T0  80 F, T1  40 F, T2  40 F, andT3  120F.
To  80,  To   6.47106
T1  40,  T1   6.24106
T2  40,  T2   5.72106
14
T3  120,  T3   5.09106
http://numericalmethods.eng.usf.edu
Example 2-Direct Fit Polynomials cont.
such that
 80  6.47  106  a0  a1 80  a2 802  a3 803
 40  6.24  106  a0  a1 40  a2 402  a3 403
  40  5.72  106  a0  a1  40  a2  402  a3  403
  120  5.09  106  a0  a1  120  a2  1202  a3  1203
Writing the four equations in matrix form, we have
1 80
1 40

1  40

1  120
15
512000  a 0  6.47  106 


1600
64000   a1  6.24  10 6 

1600  64000  a 2  5.72  10 6 

  
14400  1728000  a 3  5.09  10 6 
6400
http://numericalmethods.eng.usf.edu
Example 2-Direct Fit Polynomials cont.
Solving the above four equations gives
a0  0.59915105
a1  0.64813108
a2  0.71875 1011
Hence
a3  0.11719 1013
 T   a0  a1T  a2T 2  a3T 3
 0.59915105  0.64813108 T  0.718751011T 2  0.117191013 T 3 ,
 120  T  80
16
http://numericalmethods.eng.usf.edu
Example 2-Direct Fit Polynomials cont.
Figure 2 Graph of coefficient of thermal expansion vs. temperature.
17
http://numericalmethods.eng.usf.edu
Example 2-Direct Fit Polynomials cont.
The change in coefficient of thermal expansion at T  800F is given by
d 80  d
  (T ) T 80
dT
dt
Given that
 T   0.59915 10 5  0.64813 10 8 T  0.71875  10 11T 2  0.11719  10 13 T 3 ,
 120  T  80
d T 
d

 T 
dT
dT
d

0.59915105  0.64812108 T  0.718751011T 2  0.117191013 T 3
dt
 0.64813108  1.43751011T  0.351571013 T 2 ,  120  T  80

d 80
2
 0.64813108  1.43751011 80  0.351571013 T 80
dT
 5.5563109 in/in/F2
18
http://numericalmethods.eng.usf.edu

Example 2-Direct Fit Polynomials cont.
b)
Change in Thermal Expansion Coefficient at  3400F:
Since we want to find the rate of change in the thermal expansion
0
coefficient at T  340 F, and we are using a third order polynomial, we
need to choose the four points closest to T  3400F that also bracket
to T  3400F evaluate it.
The four points are T0  120F, T1  200F, T2  280F, andT3  340F.
To  120,  To   5.09106
T1  200,  T1   4.30106
T2  280,  T2   3.33106
T3  340,  T3   2.45106
19
http://numericalmethods.eng.usf.edu
Example 2-Direct Fit Polynomials cont.
Such that
  120  5.09  106  a0  a1  120  a2  1202  a3  1203
  200  4.30  106  a0  a1  200  a2  2002  a3  2003
  280  3.33 106  a0  a1  280  a2  2802  a3  2803
  340  2.45 106  a0  a1  340  a2  3402  a3  3403
Writing the four equations in matrix form, we have
1
1

1

1
20
 120 14400
 1728000 a 0  5.09  106 


 200 40000  8000000  a1  4.30  10 6 

 280 78400  21952000 a 2  3.33  10 6 
  
6 
 340 115600  39304000  a 3  2.45  10 
http://numericalmethods.eng.usf.edu
Example 2-Direct Fit Polynomials cont.
Solving the above four equations gives
a0  0.60625 105
a1  0.74881108
a2  0.29018 1011
a3  0.186011013
Hence
 T   a0  a1T  a2T 2  a3T 3
 0.60625105  0.74881108 T  0.290181011T 2  0.186011013 T 3 ,
 340  T  120
21
http://numericalmethods.eng.usf.edu
Example 2-Direct Fit Polynomials cont.
Figure 3 Graph of coefficient of thermal expansion vs. temperature.
22
http://numericalmethods.eng.usf.edu
Example 2-Direct Fit Polynomials cont.
0
The change in coefficient of thermal expansion at T  340 F is
given by
d  340  d
  (T ) T  340
dT
dt
Given that
 T   0.60625105  0.74881108 T  0.290181011T 2  0.186011013 T 3 ,
 340  T  120
d T  d
  T 
dt
dt
d

0.60625105  0.74881108 T  0.290181011T 2  0.186011013 T 3
dT
 0.74881108  0.580361011T  0.558041013 T 2 ,  340  t  120

23
http://numericalmethods.eng.usf.edu

Example 2-Direct Fit Polynomials cont.
d  340
2
 0.74881108  0.580361011  340  0.558041013  340
dt
 0.15905107 in/in/F2
Table 4 Summary of change in coefficient of thermal expansion using
different approximations.
Temperature, Ti
24
Change in Coefficient of Thermal Expansion, d Ti 
dT
3rd Order Interpolation
2nd Order Polynomial Regression
800F
5.5563109 in / in/ oF 2
4.3246109 in / in/ oF 2
 3400F
0.15905107 in / in/ oF 2
0.14585107 in / in/ oF 2
http://numericalmethods.eng.usf.edu
Lagrange Polynomial
In this method, given x1, y1 ,, xn , yn  , one can fit a n  1th order Lagrangian polynomial
given by
f n ( x) 
where ‘ n ’ in
n
 L ( x) f ( x )
i 0
i
i
f n (x) stands for the n th order polynomial that approximates the function
y  f (x) given at (n  1) data points as x0 , y0 , x1 , y1 ,......,xn1 , yn1 , xn , yn  , and
n
Li ( x)  
j 0
j i
x  xj
xi  x j
Li (x) a weighting function that includes a product of (n  1) terms with terms of
ji
25
omitted.
http://numericalmethods.eng.usf.edu
Lagrange Polynomial Cont.
Then to find the first derivative, one can differentiate f n x  once, and so on
for other derivatives.
For example, the second order Lagrange polynomial passing through
x0 , y0 , x1, y1 , x2 , y2 
f 2 x  
is
x  x1 x  x2  f x   x  x0 x  x2  f x   x  x0 x  x1  f x 
x0  x1 x0  x2  0 x1  x0 x1  x2  1 x2  x0 x2  x1  2
Differentiating equation (2) gives
26
http://numericalmethods.eng.usf.edu
Lagrange Polynomial Cont.
2 x  x0  x2 
2 x  x0  x1 
2 x  x1  x2 

f 2 x  
f x0  
f x1  
f x 
x0  x1 x0  x2 
x1  x0 x1  x2 
x2  x0 x2  x1  2
Differentiating again would give the second derivative as
f 2x  
27
2
x0  x1 x0  x2 
f x0  
2
x1  x0 x1  x2 
f x1  
2
x2  x0 x2  x1 
f x2 
http://numericalmethods.eng.usf.edu
Example 3
To find contraction of a steel cylinder immersed in a bath of liquid nitrogen,
one needs to know the thermal expansion coefficient data as a function of
temperature. This data is given for steel in Table 5.
a) Using the second order Lagrange polynomial interpolant, find the
change in coefficient of thermal expansion at T  80F and T  340F.
b) The data given in Table 5 can be regressed to α  a0  a1T  a2T 2 to get
. α  6.0216106  6.2790109 T 1.22151011 T 2 . Compare the results
with part (a) if you used the regression curve to find the rate of
change of the coefficient of thermal expansion with respect to
temperature at T  80F and T  340F .
28
http://numericalmethods.eng.usf.edu
Example 3 Cont.
Table 5 Coefficient of thermal expansion as a function of temperature.
29
Temperature, T
(oF)
Coefficient of
thermal expansion,
α (in/in/oF)
80
6.47 10
40
6.24 10
−40
5.72 10
−120
−200
−280
−340
5.09 106
6
4.30 10
3.33 106
6
2.45 10
6
6
6
http://numericalmethods.eng.usf.edu
Example 3 Cont.
Solution
For second order Lagrangian interpolation, we choose the coefficient of thermal
expansion given by
 T  T1  T  T2 
 T  T0  T  T2 
 T  T0  T  T1 

 (T0 )  


 (T1 )  
 (T2 )
 (T )  
T

T
T

T
T

T
T

T
T

T
T

T
2 
0  2
1 
 0 1  0
 1 0  1 2 
 2
a)
Change in the thermal expansion coefficient at 80 F :
Since we want to find the rate of change in the thermal expansion
coefficient at T  80 F and we are using second order Lagrangian
interpolation, we need to choose the three points closest to T  80 F
that also bracket to T  80 F evaluate it.
The three points are
T0  80 F, T1  40 F, and T2  40 F.
T0  80 F,  T0   6.47106
T1  40 F,  T1   6.24106
T2  40 F  T2   5.72106
30
http://numericalmethods.eng.usf.edu
Example 3 Cont.
The change in the coefficient of thermal expansion at T
given by
d 80  d

 (T ) T 80
dT
dT
Hence
 80F is
d
T   2T  T1  T2   T0   2T  T0  T2   T1   2T  T0  T1   T2 
T0  T1 T0  T2 
T1  T0 T1  T2 
T2  T0 T2  T1 
dT
d
80  280  40   40 6.47106  280  80   40 6.24106
80  4080   40
40  8040   40
dT
280  80  40

5.72106
 40  80 40  40






 2.1567107  2.34107  2.3833108
 5.5 109 in/in/F2
31
http://numericalmethods.eng.usf.edu
Example 3 Cont.
b) Change in the thermal expansion coefficient at  340 F :
Since we want to find the rate of change in the thermal expansion
coefficient at T  340 F and we are using second order
Lagrangian interpolation, we need to choose the three points closest
to T  340 F that also bracket to T  340 F evaluate it.
The three points are T0  200F, T1  280F, and T2  340F.
T0  200F,  T0   4.30106
T1  280F,  T1   3.33106
T2  340F  T2   2.45106
The change in the coefficient of thermal expansion at
given by
T  340F is
d  340  d

 (T ) T  340
dT
dT
32
http://numericalmethods.eng.usf.edu
Example 3 Cont.
Hence
d
T   2T  T1  T2   T0   2T  T0  T2   T1   2T  T0  T1   T2 
T0  T1 T0  T2 
T1  T0 T1  T2 
T2  T0 T2  T1 
dT
d
 340  2 340   280  340 4.30106
200  280 200  340
dT



2 340   200  280
3.33106
 280  200 280  340


2 340   200  280
2.45106
 340  200 340  280



 2.3036108  9.7125108  5.8333108
 0.15756107 in/in/F2
33
http://numericalmethods.eng.usf.edu
Example 3 Cont.
Table 6 Summary of change in coefficient of thermal expansion using
different approximations.
Temperature,
Ti
80
 340
34
Change in Coefficient of Thermal Expansion, d Ti 
dT
2nd Order Lagrange Interpolation
5.5 109 in/in/F2
0.15756107 in/in/F2
2nd Order Polynomial Regression
4.3246109 in/in/F2
0.14585107 in/in/F2
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/discrete_02
dif.html
THE END
http://numericalmethods.eng.usf.edu
Download