2
$\begingroup$

Can anyone suggest a method of speeding up the evaluation of the following Fourier transform?

FourierTransform[UnitStep[t] Exp[-t/τ] Cos[(m t + ω0 ) t], t, ω]

I'm surprised by the amount of time this takes to evaluate, I have added in a linear chirp to the frequency so the variable $t$ in the argument of the $\cos$ now enters quadratically; so I suppose this is the culprit.

This takes quite some time to evaluate and when it does I am left with

    (1/(24 (m^2)^(7/4) Sqrt[
 2 π] τ^3))(6 m (m^2)^(
   3/4) τ^2 (I + τ ω - τ ω0) \
HypergeometricPFQ[{1}, {3/4, 5/
     4}, -((I + τ ω - τ ω0)^4/(
     64 m^2 τ^4))] - 
  6 m (m^2)^(
   3/4) τ^2 (I + τ ω + τ ω0) \
HypergeometricPFQ[{1}, {3/4, 5/
     4}, -((I + τ ω + τ ω0)^4/(
     64 m^2 τ^4))] + 
  I (m^2)^(3/
    4) (I + τ ω - τ ω0)^3 \
HypergeometricPFQ[{1}, {5/4, 7/
     4}, -((I + τ ω - τ ω0)^4/(
     64 m^2 τ^4))] + 
  I (m^2)^(3/
    4) (I + τ ω + τ ω0)^3 \
HypergeometricPFQ[{1}, {5/4, 7/
     4}, -((I + τ ω + τ ω0)^4/(
     64 m^2 τ^4))] + 
  3 (-I m^3 + (m^2)^(3/2)) Sqrt[
   2 π] τ^3 (Cos[(I + τ ω - τ ω0)^2/(
      4 m τ^2)] + 
     I Sin[(I + τ ω - τ ω0)^2/(
       4 m τ^2)]) + 
  3 (I m^3 + (m^2)^(3/2)) Sqrt[
   2 π] τ^3 (Cos[(I + τ ω + τ ω0)^2/(
      4 m τ^2)] - 
     I Sin[(I + τ ω + τ ω0)^2/(
       4 m τ^2)]))

This I wouldn't mind, but I don't know how to deal with the HypergeometricPFQ in the answers.

My goal is to eventually have a lovely peak-like lineshape at the end I can play with.


By adding some assumptions I can get something a little nicer

FT1 = FourierTransform[UnitStep[t] Exp[-t/τ] Cos[(m t + ω0 ) t], t, ω, Assumptions-> t > 0 && τ > 0 && ω > 0 && ω0 > 0]

However when I take the absolute value using ComplexExpand[Abs[FT1]]

I get a similarly as ugly

    √((-(((m^2)^(1/4)
        Cos[(-1 + (τ ω - τ ω0)^2)/(
        4 m τ^2)] Cos[
        1/2 Arg[I m]] Cosh[(τ ω - τ ω0)/(
        2 m τ^2)])/(2 Sqrt[2] m)) + ((m^2)^(1/4)
       Cos[(-1 + (τ ω + τ ω0)^2)/(
       4 m τ^2)] Cosh[(τ ω + τ ω0)/(
       2 m τ^2)])/(4 m) - (
     Cosh[(τ ω + τ ω0)/(
       2 m τ^2)] Sin[(-1 + (τ ω + τ \
ω0)^2)/(4 m τ^2)])/(
     4 (m^2)^(1/4)) + ((m^2)^(1/4)
       Cosh[(τ ω - τ ω0)/(
       2 m τ^2)] Sin[(-1 + (τ ω - τ \
ω0)^2)/(4 m τ^2)] Sin[1/2 Arg[I m]])/(
     2 Sqrt[2] m) + ((m^2)^(1/4)
       Cos[(-1 + (τ ω - τ ω0)^2)/(
       4 m τ^2)] Cos[
       1/2 Arg[I m]] Sinh[(τ ω - τ ω0)/(
       2 m τ^2)])/(
     2 Sqrt[2] m) - ((m^2)^(1/4)
       Sin[(-1 + (τ ω - τ ω0)^2)/(
       4 m τ^2)] Sin[
       1/2 Arg[I m]] Sinh[(τ ω - τ ω0)/(
       2 m τ^2)])/(
     2 Sqrt[2] m) + ((m^2)^(1/4)
       Cos[(-1 + (τ ω + τ ω0)^2)/(
       4 m τ^2)] Sinh[(τ ω + τ ω0)/(
       2 m τ^2)])/(4 m) - (
     Sin[(-1 + (τ ω + τ ω0)^2)/(
       4 m τ^2)] Sinh[(τ ω + τ ω0)/(
       2 m τ^2)])/(4 (m^2)^(1/4)))^2 + ((
     Cos[(-1 + (τ ω + τ ω0)^2)/(
       4 m τ^2)] Cosh[(τ ω + τ ω0)/(
       2 m τ^2)])/(
     4 (m^2)^(1/4)) + ((m^2)^(1/4)
       Cos[1/2 Arg[I m]] Cosh[(τ ω - τ ω0)/(
       2 m τ^2)] Sin[(-1 + (τ ω - τ \
ω0)^2)/(4 m τ^2)])/(
     2 Sqrt[2] m) + ((m^2)^(1/4)
       Cosh[(τ ω + τ ω0)/(
       2 m τ^2)] Sin[(-1 + (τ ω + τ \
ω0)^2)/(4 m τ^2)])/(
     4 m) + ((m^2)^(1/4)
       Cos[(-1 + (τ ω - τ ω0)^2)/(
       4 m τ^2)] Cosh[(τ ω - τ ω0)/(
       2 m τ^2)] Sin[1/2 Arg[I m]])/(
     2 Sqrt[2] m) - ((m^2)^(1/4)
       Cos[1/2 Arg[
         I m]] Sin[(-1 + (τ ω - τ ω0)^2)/(
       4 m τ^2)] Sinh[(τ ω - τ ω0)/(
       2 m τ^2)])/(
     2 Sqrt[2] m) - ((m^2)^(1/4)
       Cos[(-1 + (τ ω - τ ω0)^2)/(
       4 m τ^2)] Sin[
       1/2 Arg[I m]] Sinh[(τ ω - τ ω0)/(
       2 m τ^2)])/(2 Sqrt[2] m) + (
     Cos[(-1 + (τ ω + τ ω0)^2)/(
       4 m τ^2)] Sinh[(τ ω + τ ω0)/(
       2 m τ^2)])/(
     4 (m^2)^(1/4)) + ((m^2)^(1/4)
       Sin[(-1 + (τ ω + τ ω0)^2)/(
       4 m τ^2)] Sinh[(τ ω + τ ω0)/(
       2 m τ^2)])/(4 m))^2)

Seeing as I am posting a bounty on this question I think it is prudent to state what I am looking for. I am looking for a way to perform Fourier transforms of this form, what would be helpful is not only an answer to this problem, but also a more general guide when dealing with complicated time transients that one wants to transform. This is a damped wave with a linear frequency chirp, which is well understood.

I'd like to be able to figure out how I can get Mathematica to perform such computations so I can play around a look at my resultant line-shapes.

$\endgroup$
7
  • $\begingroup$ I've added some additional working to help constrain the problem. $\endgroup$
    – user27119
    Commented Jul 25, 2019 at 14:43
  • $\begingroup$ For $m=1$ Maple 2019.1 performs a simpler result in terms of the erf function. $\endgroup$
    – user64494
    Commented Jul 25, 2019 at 15:12
  • $\begingroup$ @user64494 thanks. Unfortunately I don't have Maple! $\endgroup$
    – user27119
    Commented Jul 25, 2019 at 15:13
  • $\begingroup$ May present the Maple result through Dropbox on demand. $\endgroup$
    – user64494
    Commented Jul 25, 2019 at 15:39
  • 1
    $\begingroup$ Here dropbox.com/s/8m89hyzmf05uddg/FT.pdf?dl=0 it is. It should be noticed that the definition of Fourier transform in Maple (see maplesoft.com/support/help/Maple/view.aspx?path=examples/… ) differs from the Mathematica one by a constant multiplier. $\endgroup$
    – user64494
    Commented Jul 25, 2019 at 16:13

3 Answers 3

4
+100
$\begingroup$

The explicit integral doesn't take long and is quite simple (compared to what you have):

Assuming[τ > 0 && m > 0 && Element[ω0, Reals] && Element[ω, Reals],
  1/Sqrt[2 π] Integrate[Exp[-t/τ] Cos[(m t + ω0) t] E^(I ω t),
  {t, 0, ∞}] // FullSimplify]

$$ \frac{(-1)^{1/4} \left(e^{\frac{2 \tau \omega +i}{2 m \tau ^2}} \left(1+\text{erf}\left(\frac{(-1)^{3/4} (\tau (\omega +\omega_0)+i)}{2 \sqrt{m} \tau }\right)\right)-i e^{\frac{i \left(\omega ^2+\omega_0^2\right)}{2 m}} \left(1+\text{erf}\left(\frac{(-1)^{1/4} (\tau (\omega -\omega_0)+i)}{2 \sqrt{m} \tau }\right)\right)\right) \exp \left(-\frac{i \tau ^2 (\omega +\omega_0)^2+2 \tau (\omega -\omega_0)+i}{4 m \tau ^2}\right)}{4 \sqrt{2m}} $$

In case it's not correct to assume $m>0$ as I did, then you can replace that assumption by $m\in\mathbb{R}$ and get a slightly different answer.

Make a plot:

With[{ω0 = 1, τ = 100, m = 0.001},
  Plot[Abs[((-1)^(1/4) E^(-((I + 2 τ (ω - ω0) + I τ^2 (ω + ω0)^2)/(4 m τ^2))) (-I E^((I (ω^2 + ω0^2))/(2 m)) (1 + Erf[((-1)^(1/4) (I + τ (ω - ω0)))/(2 Sqrt[m] τ)]) + E^((I + 2 τ ω)/(2 m τ^2)) (1 + Erf[((-1)^(3/4) (I + τ (ω + ω0)))/(2 Sqrt[m] τ)])))/(4 Sqrt[2] Sqrt[m])]^2,
    {ω, 0, 2}, PlotRange -> All]]

enter image description here

$\endgroup$
4
  • $\begingroup$ really thanks a lot for this. One additional question, if I further complicate this integral by adding say a Hanning Window, do you have any hint as to how to make this execute more efficiently? I'm playing with your example and adding HannWindow[t] significantly increases computation time. At the time of writng it is still running... $\endgroup$
    – user27119
    Commented Jul 27, 2019 at 19:11
  • $\begingroup$ Usually you would convolve with a window function, which would be a multiplication in Fourier space: just multiply the already found Fourier transform with the Fourier transform of the Hann function. Or did I misunderstand and you want to use the Hann function in time instead of the UnitStep[t] factor in the original problem? $\endgroup$
    – Roman
    Commented Jul 27, 2019 at 20:41
  • $\begingroup$ For a Hann window of duration $\tau$, maybe this could work: Assuming[τ > 0 && m > 0 && ω0 > 0, 1/Sqrt[2 π] Integrate[Sin[(π t)/τ]^2 Cos[(m t + ω0) t] E^(I ω t), {t, 0, τ}]]. Maybe add a FullSimplify inside the Assuming if you can bear the slowness. $\endgroup$
    – Roman
    Commented Jul 27, 2019 at 22:22
  • $\begingroup$ I'm trying to get a line shape analytically, that resembles the FFT of some data. And as I understand it the windows should always be multiplied in, in the time domain. So yeah a straight swap of UnitStep. I only ever add unit step, as I usually use FourierTransform rather than the direct integration, as without UnitStep FourierTransform returns strange results even for simple transforms. $\endgroup$
    – user27119
    Commented Jul 28, 2019 at 8:43
0
$\begingroup$

What version of Mathematica were you using? Using MMA Version 11.2.0 for Linux I get, using

 ft=FourierTransform[UnitStep[t] Exp[-t/\[Tau]] Cos[(m t + \[Omega]0) t], t, \[Omega]] ,

the result

 (((1 + I*Erfi[(I + \[Tau]*\[Omega] - \[Tau]*\[Omega]0)/(2*Sqrt[I*m]*\[Tau])])*(Cos[(I + \[Tau]*\[Omega] - \[Tau]*\[Omega]0)^2/(4*m*\[Tau]^2)] + I*Sin[(I + \[Tau]*\[Omega] - \[Tau]*\[Omega]0)^2/(4*m*\[Tau]^2)]))/Sqrt[I*m] + ((1 + Erf[(m*(I + \[Tau]*\[Omega] + \[Tau]*\[Omega]0))/(2*((-I)*m)^(3/2)*\[Tau])])*(Cos[(I + \[Tau]*\[Omega] + \[Tau]*\[Omega]0)^2/(4*m*\[Tau]^2)] - I*Sin[(I + \[Tau]*\[Omega] + \[Tau]*\[Omega]0)^2/(4*m*\[Tau]^2)]))/Sqrt[(-I)*m])/(4*Sqrt[2])

which, displayed in TeXForm, is $\frac{\frac{\left(1+\text{erf}\left(\frac{m (\tau \omega +\tau \text{$\omega $0}+i)}{2 (-i m)^{3/2} \tau }\right)\right) \left(\cos \left(\frac{(\tau \omega +\tau \text{$\omega $0}+i)^2}{4 m \tau ^2}\right)-i \sin \left(\frac{(\tau \omega +\tau \text{$\omega $0}+i)^2}{4 m \tau ^2}\right)\right)}{\sqrt{-i m}}+\frac{\left(1+i \text{erfi}\left(\frac{\tau \omega -\tau \text{$\omega $0}+i}{2 \sqrt{i m} \tau }\right)\right) \left(i \sin \left(\frac{(\tau \omega -\tau \text{$\omega $0}+i)^2}{4 m \tau ^2}\right)+\cos \left(\frac{(\tau \omega -\tau \text{$\omega $0}+i)^2}{4 m \tau ^2}\right)\right)}{\sqrt{i m}}}{4 \sqrt{2}}$.

I'm not sure what a sensible range of parameters is, but I tried a plotting a few cases, e.g., Plot[Abs[ft/.{m->2,\[Tau]->4/3,\[Omega]0->1/5}],{\[Omega],-20,20}], and obtained, I guess, plausible looking results. (But forgot how to include graphics here.)

$\endgroup$
4
  • $\begingroup$ Interesting, I'm using Mathematica 11.0....Perhaps time for an upgrade! $\endgroup$
    – user27119
    Commented Jul 25, 2019 at 20:15
  • $\begingroup$ Can't reproduce it in version 12.0 on Windows 10 32-bit. I obtain the same result as in the question. $\endgroup$
    – user64494
    Commented Jul 26, 2019 at 3:56
  • $\begingroup$ @user64494 Does it agree with your Maple results? Now, I don’t have Maple, nor have I installed MMA version 12. $\endgroup$
    – user15994
    Commented Jul 26, 2019 at 4:02
  • 1
    $\begingroup$ @QuantumPenguin if you only care about additional stuff like this, the online version of Mathematica (in the Wolfram Cloud) can do stuff like this and doesn't cost you anything more. $\endgroup$
    – b3m2a1
    Commented Jul 28, 2019 at 17:21
0
$\begingroup$

Using MMA Version 12.0 for Windows I get:

FT1 = Assuming[{m > 0, τ > 0, ω0 > 0}, FourierTransform[
UnitStep[t] Exp[-t/τ] Cos[(m t + ω0) t], t, ω]] // FullSimplify;
ComplexExpand[Abs[FT1], TargetFunctions -> {Abs, Arg}] // FullSimplify

(* ((E^((2 (ω + ω0))/(m τ)))^(1/4)
Abs[1 + Erf[((-1)^(3/4) (I + τ (ω + ω0)))/(
2 Sqrt[m] τ)] - 
I E^((I ((I + τ ω)^2/τ^2 + ω0^2))/(2 m))
 Erfc[-(((-1)^(1/4) (I + τ (ω - ω0)))/(
  2 Sqrt[m] τ))]])/(4 Sqrt[2] (m^2)^(1/4)) *)

which, displayed in TeXForm, is:

$$\frac{\sqrt[4]{e^{\frac{2 (\omega +\text{$\omega $0})}{m \tau }}} \left|\text{erf}\left(\frac{(-1)^{3/4} (\tau (\omega +\text{$\omega $0})+i)}{2 \sqrt{m} \tau }\right)-i e^{\frac{i \left(\frac{(\tau \omega +i)^2}{\tau ^2}+\text{$\omega $0}^2\right)}{2 m}} \text{erfc}\left(-\frac{\sqrt[4]{-1} (\tau (\omega -\text{$\omega $0})+i)}{2 \sqrt{m} \tau }\right)+1\right|}{4 \sqrt{2} \sqrt[4]{m^2}}$$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.