hobz Posted March 9, 2008 Posted March 9, 2008 I have written the following MATLAB code h = 10e-12; f = @(x)cos(2*pi*x); x = 0:.01:pi; fd = (f(x+h)-f(x-h))/(2*h); hold on plot(x,f(x)) plot(x,fd, 'r') The result is quite surprising. fd, which is the derivative of f evaluated numerically, has an amplitude roughly 6 times larger than what the real derivative is. Can anyone explain how this comes to happen?
D H Posted March 9, 2008 Posted March 9, 2008 The "real derivative" of [math]f(x)=cos(2\pi x)[/math] with respect to x is [math]-2\pi \sin(2\pi x)[/math]. 2*pi is a bit over six ...
hobz Posted March 9, 2008 Author Posted March 9, 2008 Yeah ok, that was kinda stupid. Reused a function from a sampled function, didn't notice the 2*pi. Thanks for clearing it up!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now