http://jagger.me.berkeley.edu/~pack/e77
Copyright 2005, Andy Packard. This work is licensed under the Creative Commons Attribution-ShareAlike License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/2.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
Differentiation
For a function f, the derivative of f at x is defined as the limit
Numerical Differentiation
A common manner to numerically estimate of the derivative is a finite-difference of the quotient
No limit, just a fixed, nonzero h
Numerical Differentiation
If the function values are only available as data pairs
With each yi = f(xi), then the finite differences are computed with the data (assuming the xi are sorted)
In other words,
If ab, then
Matlab functions
Theres not much in the way of functions for numerical differentiation. Essentially, you employ the expressions we introduced today. If X is a row vector, then
diff(X) returns
[X(2)-X(1) X(3)-X(2) X(end)-X(end-1)] Given row vectors Xdata, Ydata (each 1-by-N)