Differentiation-Discrete Functions Industrial 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 –Discrete 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 The failure rate ht of a direct methanol fuel cell (DMFC) is given by the formula R' t ht Rt Where Rt is the reliability at a certain time t , and the values of the reliability are given in Table 1. Table 1 Reliability of DMFC system. t hrs 0 1 Rt 10 100 1000 2000 3000 4000 5000 1 0.9999 0.9998 0.9980 0.9802 0.9609 0.9419 0.9233 0.9050 Using the forward divided difference method, find the failure rate of the DMFC system at t 50 hours. 5 http://numericalmethods.eng.usf.edu Example 1 Cont. Solution Rti 1 Rti t ti 10 R ' ti ti 1 100 t ti 1 ti 100 10 90 R100 R10 90 0.9980 0.9998 90 2.0000105 R' 50 6 http://numericalmethods.eng.usf.edu Example 1 Cont. The reliability Rt at hours t 50 is R100 R10 50 10 R10 100 10 2.0000105 40 0.9998 0.999 R50 The failure rate ht at t 50 hours is then R' 50 h50 R50 2.0000105 0.999 2.0020105 7 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, Pnx dPn ( x ) a1 2a 2 x n 1a n 1 x n 2 na n x n 1 dx Similarly other derivatives can be found. 8 http://numericalmethods.eng.usf.edu Example 2-Direct Fit Polynomials The failure rate ht of a direct methanol fuel cell (DMFC) is given by the formula R' t ht Rt Where Rt is the reliability at a certain time t , and the values of the reliability are given in Table 2. Table 2 Reliability of DMFC system. t hrs 0 1 Rt 10 100 1000 2000 3000 4000 5000 1 0.9999 0.9998 0.9980 0.9802 0.9609 0.9419 0.9233 0.9050 Using a third order polynomial interpolant for reliability Rt , find the failure rate of the DMFC system at t 50 hours. 9 http://numericalmethods.eng.usf.edu Example 2-Direct Fit Polynomials cont. Solution For the third order polynomial (also called cubic interpolation), we choose the reliability given by 2 3 Rt a0 a1t a2t a3t Since we want to find the reliability at t 50 , and we are using third order polynomial, we need to choose the four points closest to t 50 and that also bracket t 50 to evaluate it. The four points are t0 1, t1 10 , t2 100 and t3 1000 hours. to 1, Rto 0.9999 t1 10, Rt1 0.9998 t 2 100, Rt 2 0.9980 t3 1000, Rt3 0.9802 10 http://numericalmethods.eng.usf.edu Example 2-Direct Fit Polynomials cont. such that R1 0.9999 a0 a1 1 a2 1 a3 1 2 3 R10 0.9998 a0 a1 10 a2 10 2 a3 10 3 R100 0.9980 a0 a1 100 a2 100 a3 100 2 3 R1000 0.9802 a0 a1 1000 a2 1000 a3 1000 2 3 Writing the four equations in matrix form, we have 1 1 1 a0 0.9999 1 1 10 a 0.9998 100 1000 1 6 1 100 10000 110 a2 0.9980 6 9 a 1 1000 1 10 1 10 0 . 9802 3 11 http://numericalmethods.eng.usf.edu Example 2-Direct Fit Polynomials cont. Solving the above four equations gives a0 0.9991 a1 1.0023 105 a2 9.9788 108 a3 9.01011011 Hence Rt a0 a1t a2t 2 a3t 3 0.99991 1.0023105 t 9.9788108 t 2 9.01011011 t 3 , 1 t 1000 12 http://numericalmethods.eng.usf.edu Example 2-Direct Fit Polynomials cont. Figure 2 Graph of reliability as a function of time. 13 http://numericalmethods.eng.usf.edu , Example 2-Direct Fit Polynomials cont. The reliability at t 50 is given by, R ' 50 d Rt t 50 dt Given that Rt 0.999911.0023105 t 9.9788108 t 2 9.01011011 t 3 , 1 t 1000 R' t d Rt dt d 0.99991 1.0023105 t 9.9788108 t 2 9.01011011 t 3 dt 1.0023105 1.9958107 t 2.70301010 t 2 , 1 t 1000 14 http://numericalmethods.eng.usf.edu Example 2-Direct Fit Polynomials cont. R' 50 1.0023105 1.9958107 50 2.70301010 50 2 1.9326105 Using the same function, we can also calculate the value of Rt at t 50 . Rt 0.99991 1.0023105 t 9.9788108 t 2 9.01011011 t 3 , 1 t 1000 R50 0.99991 1.0023105 50 9.9788108 50 9.01011011 50 0.99917 2 The failure rate is then ht 3 R' t Rt 1.932610 5 0.99917 1.9343 105 15 http://numericalmethods.eng.usf.edu Lagrange Polynomial In this method, given x1, y1 ,, xn , yn , one can fit a n 1th 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 ,......,xn1 , yn1 , 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 ji 16 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 17 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 2x 18 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 The failure rate ht of a direct methanol fuel cell (DMFC) is given by the formula R' t ht Rt Where Rt is the reliability at a certain time t , and the values of the reliability are given in Table 3. Table 3 Reliability of DMFC system. t hrs 0 1 Rt 10 100 1000 2000 3000 4000 5000 1 0.9999 0.9998 0.9980 0.9802 0.9609 0.9419 0.9233 0.9050 Determine the value of the failure rate at t 50 hours using the second order Lagrangian polynomial interpolation for reliability. 19 http://numericalmethods.eng.usf.edu Example 3 Cont. Solution For second order Lagrangian polynomial interpolation, we choose the reliability given by t t1 t t2 t t0 t t2 t t0 t t1 R(t0 ) R(t1 ) R(t2 ) R(t ) t0 t1 t0 t2 t1 t0 t1 t2 t2 t0 t2 t1 Since we want to find the reliability at t 50 , and we are using a second order Lagrangian polynomial, we need to choose the three points closest to t 50 that also bracket t 50 to evaluate it. The three points are t0 1 , t1 10 , and t2 100. Differentiation the above equation gives. 2t t0 t2 2t t0 t1 2t t1 t2 R' t Rt0 Rt1 Rt2 t0 t1 t0 t2 t1 t0 t1 t2 t2 t0 t2 t1 20 http://numericalmethods.eng.usf.edu Example 3 Cont. Hence R' 50 250 10 100 0.9999 250 1 100 0.9998 250 1 10 0.9980 1 101 100 10 110 100 100 1100 10 1.9102105 We must also find the value of Rt at t 50 . 50 10 50 100 50 1 50 100 R50 0.9999 0.9998 1 10 1 100 10 1 10 100 50 1 50 10 0.9980 100 1 100 10 0.99918 21 http://numericalmethods.eng.usf.edu Example 3 Cont. The failure rate is then ht R' t Rt 1.910210 5 0.99918 1.9118105 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/discrete_02 dif.html THE END http://numericalmethods.eng.usf.edu