Download presentation
Presentation is loading. Please wait.
Published byArthur Holland Modified over 9 years ago
1
Numerical Differentiation UC Berkeley Fall 2004, E77 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. http://jagger.me.berkeley.edu/~pack/e77http://creativecommons.org/licenses/by-sa/2.0/
2
Differentiation For a function f, the derivative of f at x is defined as the limit The “derivative of f at x” is the slope of the graph of the function at x.
3
Numerical Differentiation A common manner to numerically estimate of the derivative is a “finite-difference” of the quotient The forward difference at x with stepsize h (h>0) is The backward difference at x with stepsize h (h>0) is The centered difference at x with stepsize h (h>0) is No limit, just a “ fixed ”, nonzero h
4
Numerical Differentiation If the function values are only available as data pairs With each y i = f(x i ), then the finite differences are computed with the data (assuming the x i are sorted)
5
What are we actually computing? Average values: If g is integrable, then the average value of g over the interval [a,b] is defined as In other words, is the constant which satisfies ie., the only constant function which has the same integral over [a,b] as does g is the constant function whose value is
6
What are we actually computing? If f is differentiable, then If a≠b, then Average value of f ’ over the interval (a,b)
7
What are we computing? (cont’d) Mean-Value Theorem: If f is –differentiable on (a,b) –continuous on [a,b] then there is an y (a,b) such that
8
What are we computing? (cont’d) This gives two interpretations of the finite-difference Average value of f ’ over the interval (a,b) exact value of f ’ at some point in interval (a,b)
9
What are we computing? (cont’d) So, two interpretations of the finite-difference Average value of f ’ over the interval (x,x+h)
10
Bounding the Errors The second derivative of f gives how “quickly” the first derivative is changing. Bound the error between the finite difference estimate and the actual derivative using –finite difference is the exact answer for some intermediate value –intermediate first-derivative values differ because of 2 nd derivative. –use Taylor series to bound the error as Error between finite difference and actual derivative
11
Higher Order derivatives Use the finite difference estimates of the 1 st derivative to “compute” the 2 nd derivative, based on Example: Use backward formula, with forward derivatives
12
Matlab functions There’s 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) Z = diff(Ydata)./diff(Xdata) Z is 1-by-(N-1). Element Z(i) is the forward derivative at X(i)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.