I wrote this function NFourierTransform, which takes a function $f(k)$ and numerically calculates the fourier transform integral for discrete values of $k \in [k_{\text{min}},k_{\text{max}}]$, finally returning an InterpolatingFunction object.
NFourierTransform[f_Function, {kmin_, kmax_}] :=
Interpolation@
Table[{k, Chop@NIntegrate[f@x E^(-I k x), {x, -Infinity, Infinity}]},
{k, kmin, kmax, (kmax - kmin)/100}]
In my application (calculating the time propagation of wave functions) I need to evaluate NFourierTransform for a function $\psi(k,t)$, where $t$ assumes discrete values in some interval $[t_{\text{min}},t_{\text{max}}]$. So effectively I create a table of NFourierTransform.
TimePropagate[f_Function, kl : {kmin_, kmax_}, {tl__}] :=
Quiet@Table[
NFourierTransform[f[#] Exp[-(#^2/2) t] &, kl], {t, tl}]
Calculating a very simple example with only 2 time values, e.g. TimePropagate[Exp[-Abs@#] &, {-3, 3}, {0, 0.1, 0.1}] takes about 20 seconds to evaluate.
Is there any way to use Compile to speed up the calculations? As far as I know that's only possible for numeric function arguments. What are, in your experience, suitable setings for NIntegrate options such as MaxRecursion or AccuracyGoal, and how do they effect evaluation time?
t. Each value fortis inserted, and the integration is over some variablex, wherekranges fromkmintokmax. – einbandi Nov 23 '12 at 14:28Fourier). I'm much more comfortable with continuous FT. – einbandi Nov 23 '12 at 14:34Fourieris surely a fast way. Meaning, a maximum frequency in which the function has a not too small fourier transform, and a maximum time in which the function is not too small. – Rojo Nov 23 '12 at 14:43k/(2 Pi)I think. Also, as is it assumes that your function is near 0 for negative arguments – Rojo Nov 23 '12 at 14:46fis slow to evaluate and you are evaluating it in the same places for eachtintl, you can implementmemoizationwhich means to cache the previous results. Look for that word in this site and you'll find lots of examples – Rojo Nov 23 '12 at 15:14Methodoption ofNIntegrate[]to something that's equipped to handle oscillatory integrals, like"DoubleExponentialOscillatory"or"ExtrapolatingOscillatory". – J. M.'s missing motivation Nov 23 '12 at 15:46