Fourier integral/ Fourier transformation of an oscillatory function with FFT
-
07-06-2021 - |
Question
f(x) = cos(x^2)
and g(k) = pi^0.5 cos((pi*k)^2 - pi/4)
are a Fourier pair.
I want to reproduce g(k)
by Fourier integrating f(x)
using FFT, i.e.
approximating Integrate[ f(x) * exp(2 pi * ikx), {x, -inf, inf} ]
with Sum[ fn * exp(2 pi * ik x_n), {n, 0, N-1} ] * Delta_x
However the result agrees with g(k)
only on very small k
ranges if it agrees at all (the same code works well for smooth Fourier pairs e.g. the Gaussian functions). I guess the problem is choosing appropriate values for N
and Delta_x
. Are there any established rules for how to choose them? Where can I find related topics in literature (I've read Numerical Recipe section 13.9 but it does not seem to solve my problem)?
Solution
An FFT inherently windows f(x) with a rectangular window of length N. This will produce different g(k) results for any k that is not exactly periodic within that window. You can try picking Delta_X and N so that their result is an exact integer multiple of your desired k.