Transcript PPT
Differentiation-Discrete Functions Computer Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati http://numericalmethods.eng.usf.edu Transforming Numerical Methods Education for STEM Undergraduates 7/12/2016 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 upward velocity of a rocket is given as a function of time in Table 1. Table 1 Velocity as a function of time t s 0 10 15 20 22.5 30 v(t) m/s 0 227.04 362.78 517.35 602.97 901.67 Using forward divided difference, find the acceleration of the rocket at t 16 s . 5 http://numericalmethods.eng.usf.edu Example 1 Cont. Solution To find the acceleration at t 16s, we need to choose the two values closest to t 16s, that also bracket t 16s to evaluate it. The two points are t 15s and t 20s. ti 1 ti ati t ti 15 ti 1 20 t ti 1 ti 20 15 5 6 http://numericalmethods.eng.usf.edu Example 1 Cont. 20 15 5 517.35 362.78 5 30.914 m/s 2 a16 7 http://numericalmethods.eng.usf.edu Direct Fit Polynomials In this method, given ' n 1' data points x0 , y0 , x1 , y1 , x2 , y 2 ,, xn , y n one can fit a n th order polynomial given by Pn x a0 a1 x an 1 x n 1 an x n To find the first derivative, Pn x 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 upward velocity of a rocket is given as a function of time in Table 2. Table 2 Velocity as a function of time t s 0 10 15 20 22.5 30 v(t) m/s 0 227.04 362.78 517.35 602.97 901.67 Using the third order polynomial interpolant for velocity, find the acceleration of the rocket at t 16 s . 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 velocity given by vt a 0 a1t a 2 t 2 a3 t 3 Since we want to find the velocity at t 16 s , and we are using third order polynomial, we need to choose the four points closest to t 16 s and that also bracket t 16 s to evaluate it. The four points are to 10, t1 15, t2 20, and t3 22.5. to 10, vto 227.04 t1 15, vt1 362.78 t2 20, vt2 517.35 t3 22.5, vt3 602.97 10 http://numericalmethods.eng.usf.edu Example 2-Direct Fit Polynomials cont. such that v10 227.04 a0 a1 10 a2 10 a3 10 2 3 v15 362.78 a0 a1 15 a2 15 a3 15 2 3 v20 517.35 a0 a1 20 a2 20 a3 20 2 3 v22.5 602.97 a0 a1 22.5 a2 22.5 a3 22.5 2 3 Writing the four equations in matrix form, we have 100 1000 a0 227.04 1 10 1 15 a 362.78 225 3375 1 1 20 400 8000 a 2 517.35 a 1 22 . 5 506 . 25 11391 602 . 97 3 11 http://numericalmethods.eng.usf.edu Example 2-Direct Fit Polynomials cont. Solving the above four equations gives a0 4.3810 a1 21.289 a2 0.13065 a3 0.0054606 Hence vt a0 a1t a2t 2 a3t 3 4.3810 21.289t 0.13065t 2 0.0054606t 3 , 10 t 22.5 12 http://numericalmethods.eng.usf.edu Example 2-Direct Fit Polynomials cont. Figure 1 Graph of upward velocity of the rocket vs. time. 13 http://numericalmethods.eng.usf.edu , Example 2-Direct Fit Polynomials cont. The acceleration at t=16 is given by a16 Given that d vt t 16 dt t 4.3810 21.289t 0.13065t 2 0.0054606t 3 ,10 t 22.5 d a t vt dt d 4.3810 21.289t 0.13065t 2 0.0054606t 3 dt 21.289 0.26130t 0.016382t 2 , 10 t 22.5 a16 21.289 0.2613016 0.01638216 2 29.664m/s 2 14 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 , y n1 , xn , y n , 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 15 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 16 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 17 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 upward velocity of a rocket is given as a function of time in Table 3. Table 3 Velocity as a function of time t s 0 10 15 20 22.5 30 v(t) m/s 0 227.04 362.78 517.35 602.97 901.67 Determine the value of the acceleration at t 16 s using the second order Lagrangian polynomial interpolation for velocity. 18 http://numericalmethods.eng.usf.edu Example 3 Cont. Solution t t1 t t 2 t t 0 t t 2 t t 0 t t1 v(t 2 ) v(t ) v(t 0 ) v(t1 ) t 0 t1 t 0 t 2 t1 t 0 t1 t 2 t 2 t 0 t 2 t1 at 2t t1 t 2 2t t 0 t 2 t 0 t1 2t t0 t1 νt2 t 0 t1 t 0 t 2 t1 t 0 t1 t 2 t2 t0 t2 t1 216 15 20 227.04 216 10 20 362.78 216 10 15 517.35 a16 20 10 20 15 15 1015 20 10 1510 20 0.06227.04 0.08362.78 0.14517.35 29.784m/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/discrete_02 dif.html THE END http://numericalmethods.eng.usf.edu