0
$\begingroup$

I am trying to do Fourier Transformation on the following function Izzn, which is essentially just a lot of trigonometric function, whose Fourier transformation are all well defined. However, when I type FourierTransform[Izzn,t,f], mathematica takes an unreasonably long time to evaluate. By unreasonable, I mean that it never gives the result but keeps evaluating. Some typical terms of Izz are posted below enter image description here

 0.272441 Cos[1519.09 t]^2 + 2.69272 Cos[1519.22 t]^2 + 
 0.383058 Cos[1519.22 t]^2 - 
 0.0419625 Cos[1519.22 t] Cos[1519.22 t] + 
 0.0494935 Cos[1519.22 t]^2 + 
 0.910475 Cos[1519.22 t] Cos[1519.24 t] + 
 0.407475 Cos[1519.22 t] Cos[1519.24 t] + 2.42896 Cos[1519.24 t]^2 + 
 0.127629 Cos[1519.22 t] Cos[1519.25 t] - 
 0.0659875 Cos[1519.22 t] Cos[1519.25 t] - 
 0.351161 Cos[1519.24 t] Cos[1519.25 t] + 1.05013 Cos[1519.25 t]^2 - 
 0.5246 Cos[1519.22 t] Cos[1519.25 t] + 
 0.0886742 Cos[1519.22 t] Cos[1519.25 t] + 
 2.17117 Cos[1519.24 t] Cos[1519.25 t] - 
 2.97282 Cos[1519.25 t] Cos[1519.25 t] + 5.7118 Cos[1519.25 t]^2 - 
 1.68453 Cos[1519.22 t] Cos[1519.26 t] - 
 0.181303 Cos[1519.22 t] Cos[1519.26 t] - 
 5.27604 Cos[1519.24 t] Cos[1519.26 t] + 
 0.928094 Cos[1519.25 t] Cos[1519.26 t]
$\endgroup$
4
  • 2
    $\begingroup$ Please can you post something we can work with in Mathematica? Make it so that I can copy and paste. A minimum working example is the usual format. I think you may have a list of numbers, but I can't see properly, if so, you need Fourier not FourierTransform. $\endgroup$
    – Hugh
    Nov 17, 2021 at 10:52
  • $\begingroup$ Hi, I tried to post Izzn for people's use, but the website tell me that most of my post is code so it's not possible to add it. But as I said, and you can look in the picture, Izzn is just a large bunch of trigonometric functions of argument t. $\endgroup$
    – Tan Tixuan
    Nov 17, 2021 at 11:07
  • $\begingroup$ Can you just post as few of the typical terms? Then I can see what happens. $\endgroup$
    – Hugh
    Nov 17, 2021 at 11:13
  • $\begingroup$ Hi, I copied about one fifth of the terms here $\endgroup$
    – Tan Tixuan
    Nov 17, 2021 at 11:24

2 Answers 2

2
$\begingroup$

I have had a play with your data. I don't know what your data means but, as Daniel Huber points out, you can take the FourierTransform.

  ex = 0.272441 Cos[1519.09 t]^2 + 2.69272 Cos[1519.22 t]^2 + 
   0.383058 Cos[1519.22 t]^2 - 
   0.0419625 Cos[1519.22 t] Cos[1519.22 t] + 
   0.0494935 Cos[1519.22 t]^2 + 
   0.910475 Cos[1519.22 t] Cos[1519.24 t] + 
   0.407475 Cos[1519.22 t] Cos[1519.24 t] + 
   2.42896 Cos[1519.24 t]^2 + 
   0.127629 Cos[1519.22 t] Cos[1519.25 t] - 
   0.0659875 Cos[1519.22 t] Cos[1519.25 t] - 
   0.351161 Cos[1519.24 t] Cos[1519.25 t] + 
   1.05013 Cos[1519.25 t]^2 - 0.5246 Cos[1519.22 t] Cos[1519.25 t] + 
   0.0886742 Cos[1519.22 t] Cos[1519.25 t] + 
   2.17117 Cos[1519.24 t] Cos[1519.25 t] - 
   2.97282 Cos[1519.25 t] Cos[1519.25 t] + 5.7118 Cos[1519.25 t]^2 - 
   1.68453 Cos[1519.22 t] Cos[1519.26 t] - 
   0.181303 Cos[1519.22 t] Cos[1519.26 t] - 
   5.27604 Cos[1519.24 t] Cos[1519.26 t] + 
   0.928094 Cos[1519.25 t] Cos[1519.26 t];
FourierTransform[ex, t, f]

enter image description here

As you can see it is full of delta functions which you may not want (or you may). There is a post somewhere that explains why FourierTransform does this.

If this is a time series analysis I suggest you use LaplaceTransform and then convert to Fourier. Thus

lt = LaplaceTransform[ex, t, s];
ft = lt /. s -> I ω // Chop

enter image description here

I don't know if this helps. I had some fun working out the poles of your expression thus

b = List @@ ft;
den = Denominator[#] & /@ b;
Solve[# == 0, ω] & /@ den

enter image description here

So you have lots of poles at high frequencies and low.

Hope that helps.

$\endgroup$
1
  • $\begingroup$ Hi, thanks a lot. Actually I guess the problem is about the length of the function. I posted the full Izzn just above your answer. Could you try it? I think for a small series, FourierTransform works fine, but when the function gets longer, it fails. $\endgroup$
    – Tan Tixuan
    Nov 17, 2021 at 11:49
2
$\begingroup$
f[t_] = .272441 Cos[1519.09 t]^2 + 2.69272 Cos[1519.22 t]^2 + 
   0.383058 Cos[1519.22 t]^2 - 
   0.0419625 Cos[1519.22 t] Cos[1519.22 t] + 
   0.0494935 Cos[1519.22 t]^2 + 
   0.910475 Cos[1519.22 t] Cos[1519.24 t] + 
   0.407475 Cos[1519.22 t] Cos[1519.24 t] + 
   2.42896 Cos[1519.24 t]^2 + 
   0.127629 Cos[1519.22 t] Cos[1519.25 t] - 
   0.0659875 Cos[1519.22 t] Cos[1519.25 t] - 
   0.351161 Cos[1519.24 t] Cos[1519.25 t] + 
   1.05013 Cos[1519.25 t]^2 - 0.5246 Cos[1519.22 t] Cos[1519.25 t] + 
   0.0886742 Cos[1519.22 t] Cos[1519.25 t] + 
   2.17117 Cos[1519.24 t] Cos[1519.25 t] - 
   2.97282 Cos[1519.25 t] Cos[1519.25 t] + 5.7118 Cos[1519.25 t]^2 - 
   1.68453 Cos[1519.22 t] Cos[1519.26 t] - 
   0.181303 Cos[1519.22 t] Cos[1519.26 t] - 
   5.27604 Cos[1519.24 t] Cos[1519.26 t] + 
   0.928094 Cos[1519.25 t] Cos[1519.26 t];

FourierTransform[f[t], t, w]

enter image description here

Is this the result you expect? And it is lightning fast.

However, you do not actually need a Fourier Transform. Every Cos term will give 2 Delta functions and every Cos^2 term 3 Delta Functions and Cos Cos 4 Delta FunctionsE.g.:

FourierTransform[ Cos[a  t], t, w]
FourierTransform[Cos[a  t]^2, t, w]
FourierTransform[Cos[a  t] Cos[b t], t, w]

enter image description here

Therefore, as the Fourier Transform is linear, you can get the result by replacing

enter image description here

Note, due to numerical accuracy with machine numbers, you do not get exactly the same result as from Fourier Transform. For this you would need to use accurate numbers.

$\endgroup$
3
  • $\begingroup$ Did you try InverseFourierTransform[%, w, t] to verify it? $\endgroup$
    – user64494
    Nov 17, 2021 at 11:38
  • $\begingroup$ Hi, for this it is probably fast as there are only a few terms. But my problem is that for the full series (which you can see the picture), it seems very slow. $\endgroup$
    – Tan Tixuan
    Nov 17, 2021 at 11:44
  • $\begingroup$ You do not actually need a Fourier Transform as your input consist only of Cos terms. Therefore you can get the solution by replacement. I added this possibility to my answer. $\endgroup$ Nov 17, 2021 at 12:40

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.