Fourier integral/ Fourier transformation of an oscillatory function with FFT

$f(x) = \cos(x^2)$ and $g(k) = \sqrt\pi \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)?

-
What is a 'Fourier pair'? –  copper.hat May 9 '12 at 16:32
@copper: one's a Fourier transform of the other, apparently... –  Ｊ. Ｍ. May 9 '12 at 16:36

I'd be surprised if you can make this work well. The smooth pairs are not only smooth; the smoothness of one function implies the rapid decay of the other, whereas these functions don't decay at all. You need a bit of sophisticated theory to even make these Fourier transforms well-defined because the naive integrals don't converge, so it's unlikely that you can approximate them well by a finite sum.

-
I am still wondering that, since these Fourier transforms are still "well defined" in some sense, shouldn't a dense sampling of N>>1 cycles of f(x) give a good approximation of g(k) for k<klim, with klim determined by the density of the sampling? Naively I expect klim ~ 1/delta_x, but in reality klim is much smaller than that... You are right that the actual klim should have to do with the converging property of the Fourier integral. Is there perhaps a way to quantify this? –  user1342516 May 10 '12 at 11:51