Chapter 02.03 Differentiation of Discrete Functions

  1. find approximate values of the first derivative of functions that are given at

  discrete data points, and 2. use Lagrange polynomial interpolation to find derivatives of discrete functions.

  To find the derivatives of functions that are given at discrete points, several methods are available. Although these methods are mainly used when the data is spaced unequally, they can be used for data that is spaced equally as well.

  Forward Difference Approximation of the First Derivative

  We know

  fx   x     f x f    x  lim  xx

   For a finite x ,

   fx   x     f x fx

    

   x

  f (x ) x x x   x Figure 1 Graphical representation of forward difference approximation of first derivative.

  So given n

  1 data points x , y , x , y , x , y , , x , y , the value of f  (x ) for

       

1 1 2 2  n n xxx , i  ,..., ni i 1 1 , is given by f xf x

      i 1 i fx

    i xx i 1 i

   Example 1 The upward velocity of a rocket is given as a function of time in Table 1.

  Velocity as a function of time.

  Table 1

t (s) v (t ) ( m/s )

  0 0 10 227.04 15 362.78 20 517.35

  22.5 602.97 30 901.67 Using forward divided difference, find the acceleration of the rocket at t 16 s .

  

  Solution

  To find the acceleration at t 16 s , we need to choose the two values of velocity closest to 

  t

  16 s , that also bracket t  16 s to evaluate it. The two points are t  15 s and t  20 s

  v t t i 1 i    a       ti

   t 15 ti 20 ti 1

   t t t

     i 1 i

  

   20 

  15 

  5 20 

  15      

  a  

  16 

  5 517 . 35  362 .

  78 

  5 2 = 30.914 m/s

  Direct Fit Polynomials th

  In this method, given n

  1 data points x , y , x , y , x , y , , x , y , one can fit a n

        

1 1 2 2  n n

  order polynomial given by n 1 n

   P   xaa x   a xa x n 1   n 1 n

  To find the first derivative,

  dP ( x ) n n 2 n 1  

   P   x   an 1 2 a x    n2 n 1  a xna x 1 n    dx Similarly, other derivatives can also be found.

  Example 2 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) v (t ) ( m/s )

  0 0 10 227.04 15 362.78 20 517.35

  22.5 602.97 30 901.67 Using a third order polynomial interpolant for velocity, find the acceleration of the rocket at

  t  16 s .

  Solution

  For the third order polynomial (also called cubic interpolation), we choose the velocity given by 2 3

  v   taa ta ta t 1 2 3 Since we want to find the velocity at t 16 s , and we are using a third order polynomial, we  need to choose the four points closest to t

  16 and that also bracket t 16 to evaluate it.  

  The four points are t 10 , t 15 , and t 22 . 5 .

    t1 2 20  3

  t 10 , v t 227 .

  04    

  t1 15 , v   t  362 . 1

  78 t 20 , v t 517 .

  35 2     2 t 22 .

  5 , v t 602 .

  97 3     3 such that 2 3

  v   10  227 . 04  aa   1 10  a   2

10  a  

2 3

  10 3 v   15  362 . 78  aa   1 15  a   2

15  a  

2 3

  15 3 v   20  517 . 35  aa   1 20  a   2

20  a  

3 2

  20 3 v  22 . 5   602 . 97  aa1 22 . 5   a2

22 .

5   a3 22 . 5 

  Writing the four equations in matrix form, we have

  1 10 100 1000 a 227 .

  04            

  1 15 225 3375 a 362 . 1

  78        

  1 20 400 8000   a   517 . 2 35        1 22 . 5 506 . 25 11391 a 602 . 3

  97       Solving the above four equations gives 3810 a 4 .  

  a 21 . 289 1a . 13065 2  0054606 a . 3

  Hence 2 3

  v   taa ta ta t 1 2 3 2 3

    4 . 3810  21 . 289 t  . 13065 t  . 0054606 t , 10  t  22 .

  5 The acceleration at t

  16 is given by  d a

  16 v t

       t 16 dt 2 3 Given that v t

  4 . 3810 21 . 289 t . 13065 t . 0054606 t , 10 t 22 . 5 ,

           d a t v t

       dt d

2

3

    4 . 3810  21 . 289 t  . 13065 t  . 0054606 t

    dt 2

  21 . 289 . 26130 t . 016382 t , 10 t 22 .

  5      2

  a

  16 21 . 289 . 26130 16 . 016382

  16

           2

  29 . 664 m/s 

  Lagrange Polynomial th

  In this method, given  x , y  , ,  x , y  , one can fit a n order Lagrangian polynomial n n  given by n

  f ( x )  L ( x ) f ( x ) n i ii th

  where n in f (x ) stands for the n order polynomial that approximates the function n

  yf (x ) and n xx j L ( x )  i

   j x x j ii j

  L (x ) is a weighting function that includes a product of ni 1 terms with terms of ji omitted.

  Then to find the first derivative, one can differentiate f   x once, and so on for other n derivatives. For example, the second order Lagrange polynomial passing through

  x , y , x , y , and x , y is       1 1 2 2

  xx xxxx  xx   xx  xx1   2 2 1

f    xf xf xf x

2 1 2 x x x x x x x x x x x x

                       1 2 1 1 2 2 2 1 Differentiating the above equation gives 2 x   xx1 2 2 x   xx2 2 x   xx1f   xf xf xf x 2 1 2

   xx  xx     xx  xx     xx  xx    1 2 1 1 2 2 2 1 Differentiating again would give the second derivative as

  2

  2

  2 

  

f xf xf xf x

2 1 2 x x x x x x x x x x x x                        1 2 1 1 2 2 2 1 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) v (t ) ( m/s )

  0 0 10 227.04 15 362.78 20 517.35

  22.5 602.97 30 901.67 Determine the value of the acceleration at t  16 s using second order Lagrangian polynomial interpolation for velocity.

  Solution

     t t     t t   

tt tttttt

1 2 2 1

v ( t ) v ( t ) v ( t ) v ( t )

     1 2            

tt tt tt tt tt tt

1 2 1 1 2 2 2 1

  

           

2 t t t 2 t   tt1 2 2 t   tt      2 1 a t t t t

          1 2

tt  tt     tt  tt     tt  tt   

1 2 1

1

2 2 2 1

  2    16  15  20  2    16  10  20 

  a 16  227 .

  04 362 .

  78

       

  10  15  10  20   15  10  15  20  2    16  10  15   517 .

  35

  

  20  10  20  15  .

  06 227 . 04 . 08 362 . 78 . 14 517 .

  35           2

   29 . 784 m/s DIFFERENTIATION Topic Differentiation of Discrete Functions Summary These are textbook notes differentiation of discrete functions Major General Engineering Authors Autar Kaw, Luke Snyder Date December 23, 2009 Web Site http://numericalmethods.eng.usf.edu