| |
 |
|
|
Science Forum Index » Mathematics Forum » Numeric, discrete differentiation using FFT
Page 1 of 1
|
| Author |
Message |
| Daniel Kraft |
Posted: Thu May 01, 2008 4:21 pm |
|
|
|
Guest
|
Hi,
I heard that a Discrete Fourier Transformation can be used to calculate
the derivative of a function given as discrete table of values because
the Fourier Transformation of d/dx f(x) is simply i*k times the Fourier
Transformation of f(x) itself where k is the table of frequencies or
something like this.
I tried this in GNU Octave (Matlab):
x = linspace(-pi, pi, 100);
f = sin(2*x);
k = linspace(-1, 1, 100);
d = ifft(-i*k.*fft(f));
plot(x, d, x, 2*cos(2*x));
But while this seems to be not far off (for f=sin(x) I get exactly
cos(x) as derivative d), it does not yet give the fully correct
result... This must be because of my choice of k which was simply a
guess (using linspace(-2, 2, 100) gives in this case the desired correct
derivative).
So here's my question, how can I use this method for general functions
just given by a table (i.e., I know virtually nothing about them, like
any "sampling/base frequencies" or the like) and a table containing the
corresponding x values? Where do I get the correct k from (if this is
what I need)?
What I want to get is the derivative of f stored as table (with same x
values), too, as I would get by simply using differences. And in fact I
do need the second derivative in my real application and heard using FFT
would make this more exact than differences, so I really want to use FFT
and no difference approximation.
Thanks a lot,
Daniel
--
Done: Bar-Sam-Val-Wiz, Dwa-Elf-Hum-Orc, Cha-Law, Fem-Mal
Underway: Ran-Gno-Neu-Fem
To go: Arc-Cav-Hea-Kni-Mon-Pri-Rog-Tou |
|
|
| Back to top |
|
| |
|
Page 1 of 1
All times are GMT - 5 Hours
The time now is Sun Jul 27, 2008 12:36 am
|
|