You are on page 1of 7

Numerical Differentiation of

Discrete Functions

After reading this chapter, you should be able to:

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
f  x  x   f x 
f  x   lim
x 0 x
For a finite x ,
f x  x   f  x 
f  x  
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 0 , y 0 ,  x1 , y1 ,  x 2 , y 2 , ,  x n , y n  , the value of f (x) for


xi  x  xi 1 , i  0,..., n  1 , is given by
f  xi 1   f  xi 
f  xi  
xi 1  xi

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) 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
Differentiation of Discrete Functions

vti 1    ti 
ati  
t
t i  15
t i 1  20
t  ti 1  ti
 20  15
5
 20   15
a 16 
5
517.35  362.78

5
= 30.914 m/s 2

Direct Fit Polynomials


In this method, given n  1 data points x 0 , y 0 ,  x1 , y1 ,  x 2 , y 2 , ,  x n , y n  , one can fit a n th
order polynomial given by
Pn  x   a0  a1 x    a n 1 x n 1  a n x n
To find the first derivative,
dP ( x)
Pn  x   n  a1  2a 2 x    n  1a n 1 x n  2  na n x n 1
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
vt   a 0  a1t  a 2 t 2  a3t 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 t0  10, t1  15, t 2  20 and t 3  22.5 .
t 0  10, vt 0   227.04
t1  15, vt1   362.78
t 2  20, vt 2   517.35
t 3  22.5, vt 3   602.97

such that
v10   227.04  a 0  a1 10   a 2 10   a 3 10 
2 3

v15  362.78  a 0  a1 15  a 2 15  a 3 15


2 3

v20   517.35  a 0  a1 20   a 2 20   a 3 20 


2 3

v22.5  602.97  a 0  a1 22.5  a 2 22.5  a3 22.5


2 3

Writing the four equations in matrix form, we have


1 10 100 1000  a 0  227.04
1 15
 225 3375   a1  362.78

1 20 400 8000  a 2  517.35
    
1 22.5 506.25 11391  a 3  602.97 

Figure 2 Graph of upward velocity of the rocket vs. time.


Differentiation of Discrete Functions

Solving the above four equations gives


a 0  4.3810
a1  21.289
a 2  0.13065
a3  0.0054606
Hence
vt   a 0  a1t  a 2 t 2  a3t 3
 4.3810  21.289t  0.13065t 2  0.0054606t 3 , 10  t  22.5
The acceleration at t  16 is given by
d
a16  vt  t 16
dt
Given that vt   4.3810  21.289t  0.13065t 2  0.0054606t 3 , 10  t  22.5 ,
d
at   vt 
dt
  4.3810  21.289t  0.13065t 2  0.0054606t 3 
d
dt
 21.289  0.26130t  0.016382t 2 , 10  t  22.5
a16   21.289  0.2613016   0.01638216
2

 29.664 m/s2

Lagrange Polynomial
In this method, given x0 , y 0 , ,  xn , y n  , one can fit a n th order Lagrangian polynomial
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) and
n x  xj
Li ( x)  
j 0 xi  x j
j i

Li (x) is a weighting function that includes a product of n  1 terms with terms of j  i


omitted.
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 , y 0 , x1 , y1 , and x 2 , y 2  is
x  x1 x  x2    x  x0 x  x 2    x  x0 x  x1   
f 2 x   f x  f x  f x
x0  x1 x0  x 2  0 x1  x0 x1  x2  1 x2  x0 x 2  x1  2
Differentiating the above equation gives

 2 x   x1  x 2  2 x  x0  x 2  2 x   x 0  x1 
f 2 x   f x0   f  x1   f x 
x0  x1 x0  x 2  x1  x0 x1  x 2  x2  x0 x 2  x1  2
Differentiating again would give the second derivative as

2 2 2
f 2 x   f x0   f  x1   f x2 
x0  x1 x0  x2  x1  x0 x1  x2  x2  x0 x 2  x1 

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  t1  t  t 2   t  t 0  t  t 2   t  t 0  t  t1 
v(t )    v(t 0 )    v(t1 )    v(t 2 )
 t 0  t1  t 0  t 2   t1  t 0  t1  t 2   t 2  t 0  t 2  t1 
2t  t1  t 2  2t  t 0  t 2  2t  t 0  t1 
at    t 0    t1    t 
t 0  t1 t 0  t 2  t1  t 0 t1  t 2  t 2  t 0 t 2  t1  2
216  15  20
a 16  227.04  216  10  20 362.78
10  1510  20 15  1015  20
216  10  15
 517.35
20  1020  15
 0.06227.04  0.08362.78  0.14517.35
 29.784 m/s 2

You might also like