You are on page 1of 12

ELEC 4333/5333 University of Colorado Denver S.

Gedney
The Derivative


 Derivative f ( x) :
x
o The measure of the instantaneous rate of change of a function with
respect to a dependent variable.
o The derivative is equal to the slope of the curve at the point at which the
derivative is evaluated
o Fundamental law of calculus:
f ( x)

 f  xo  x   f  xo 
f  x  lim
x x  xo
x 0 x

xo xo  x x

Page 1 of 12
ELEC 4333/5333 University of Colorado Denver S. Gedney
Discrete Approximation of a Derivative
 Consider the Taylor series expansion of f(x) about the point x  x :
 f (x ) 1  2 f (x ) 2 1  3 f (x ) 3 1
f ( x  x )  f ( x )  x    x     x   ...
x 1!  x2 2!  x3 3!
f ( x)
 Move f ( x ) to the left and divide by x :
f ( x  x )  f ( x )  f ( x )  2 f ( x ) 1 2  f (x ) 1
3
  x  x  ...
x x  x2 2!  x3 6

 Solving:
 f ( x ) f ( x  x )  f ( x )  2 f ( x ) 1 2  f (x ) 1
3
  x  x  ... xo xo  x x
x x x 2
2! x 63

 Define the “Forward Difference operator”:


 f ( x ) f ( x  x )  f ( x )
  O  x 
x x
 where O  x  is the order of the residual error of the approximation.
1  2 f (x ) 2 1  f (x )
3
O  x   x  x  ...
2!  x 2
6 x 3

Page 2 of 12
ELEC 4333/5333 University of Colorado Denver S. Gedney
 We could also consider the Taylor series expansion of f(x) about x  x :
 f (x ) 1  2 f (x ) 2 1  3 f (x ) 3 1
f ( x  x )  f ( x )  x    x     x   ...
x 1! x 2
2! x 3
3!

 Backward Difference operator:


 f ( x ) f ( x )  f ( x  x )
  O  x 
x x

f ( x)

xo  x xo x

 Solution converges to the exact derivative as x  0 , provided f ( x) is differentiable


at xo .
 The solution converges linearly.
 E.g., reduce x by 0.1, error reduces by 0.1.
Page 3 of 12
ELEC 4333/5333 University of Colorado Denver S. Gedney
Central Difference Approximation

 Now, consider the Taylor series expansion about the points x  x / 2 :


2 3
x  f ( x ) x 1  2 f ( x )  x  1  3 f ( x )  x  1
f (x  )  f (x )         ...
2  x 2 1!  x 2  2  2!  x 3  2  3!
 Subtracting the two expansions about the central point x (even derivatives cancel!):
x x
f (x  )  f (x  )
2   f ( x )  x 2  f ( x ) 1  ...
3
2
x x  x 3 24
 Central Difference Approximation:
x x
f (x  )  f (x  )
 f (x ) 2 2  O  x 2  .

x x

 Approximation error:
 x x 
  
 
f ( x ) f ( x )
 f (x ) 
 2 2
  O x 2  f  x  .
x  x 
 

Page 4 of 12
ELEC 4333/5333 University of Colorado Denver S. Gedney

Central Difference Approximation

f ( x)

x x
f (x  )  f (x  )
 f (x ) 2 2  O  x 2  .

x x
xo
x x x
xo  xo 
2 2
 Due to cancelation of the odd-terms, the error converges as x 2
 “Second-order” convergence
 E.g., reduce x by 0.1, error reduces by 0.01 ( x 2 ).

Page 5 of 12
ELEC 4333/5333 University of Colorado Denver S. Gedney
Example

 Approximate the derivative using:


 f ( x ) f ( x  x )  f ( x )
 Forward difference approximation: 
x x
 f ( x ) f ( x )  f ( x  x )
 Backward difference approximation: 
x x
x x
f (x  )  f (x  )
 f (x ) 2 2
 Central Difference approximation: 
x x
Page 6 of 12
ELEC 4333/5333 University of Colorado Denver S. Gedney

Page 7 of 12
ELEC 4333/5333 University of Colorado Denver S. Gedney
Another Example

Page 8 of 12
ELEC 4333/5333 University of Colorado Denver S. Gedney

Page 9 of 12
ELEC 4333/5333 University of Colorado Denver S. Gedney
Higher-Order Finite Difference Approximations

 Again, consider the Taylor series expansion about the points x  x / 2 :


2 3
x  f ( x ) x 1  2 f ( x )  x  1  3 f ( x )  x  1
f (x  )  f (x )        
2  x 2 1!  x 2  2  2!  x 3  2  3!
4 5
 4 f ( x )  x  1  5 f ( x )  x  1
     ...
 x  2  4!
4
 x  2  5!
5

 Again, subtracting the two expansions about the central point x (even derivatives
cancel!):
x x
f (x  )  f (x  )
2   f ( x )  x 2 1  f ( x )  x 4 1  f ( x ) ...
3 5
2
x x 24  x 3 1920  x 5

 We can also derive:


3 x 3 x
f (x  )  f (x  )
2   f ( x )  x 2 3  f ( x )  x 4 27  f ( x ) ...
3 5
2
3 x x 8  x3 640  x 5

 Multiply the first expression by 9 and then subtracting:

Page 10 of 12
ELEC 4333/5333 University of Colorado Denver S. Gedney
x x 3 x 3 x
f (x  )  f (x  ) f (x  )  f (x  )
9 2 2  2 2
x 3 x
 f (x ) 2 9  f (x )
3
4 27  f ( x )
5
 9  x  x
x 24  x 3
1920  x 5
 f (x ) 2 3  f (x )
3
4 243  f ( x )
5
  x  x ...
x 8 x 3
640  x 5

 Simplifying:
3 x x x 3 x
 f (x  )  27 f ( x  )  27 f ( x  )  f (x  )
2  8   f ( x )  x 4 117  f ( x )  ...
5
2 2 2
3 x x 320  x 5

 Therefore, we can defined a 4th-order Central Difference approximation as:


3 x x x 3 x
 f (x  )  27 f ( x  )  27 f ( x  )  f (x  )
 f (x ) 2 2 2 2  O  x 4 

x 24 x

Page 11 of 12
ELEC 4333/5333 University of Colorado Denver S. Gedney

Page 12 of 12

You might also like