2
$\begingroup$

I am getting completely different values of FFT([1,2]) in scilab and Wolfram. I wondering what is going on and who is right.

Wolfram alpha: fft([1,2]):
{2.12132, -0.707107}

Wolfram alpha output image

Scilab fft([1,2]):
3.  -1.

Scilab output image

$\endgroup$

closed as off-topic by Xander Henderson, Alexander Gruber May 21 at 1:47

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question is not about mathematics, within the scope defined in the help center." – Xander Henderson, Alexander Gruber
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ There are different definitions of the discrete Fourier transform that are normalized differently. Within a consistent definition, a change to the forward transform causes the opposite change to the inverse transform, so they still invert one another. $\endgroup$ – Ian May 20 at 13:33
  • 1
    $\begingroup$ @someuser The ratio is the same. $\endgroup$ – PierreCarre May 20 at 13:33
  • $\begingroup$ I doubt that both numbers are exactly integers. Does Scilab round the result somehow (then it might be the same result, before the rounding)? $\endgroup$ – Dirk May 20 at 13:43
  • $\begingroup$ @PierreCarre You are right, didn't noticed that. When I compute in Wolfram fft([1,2])*sqrt(2) it's exactly the same as Scilab. But still do not understand why. $\endgroup$ – someuser1 May 20 at 13:45
  • $\begingroup$ @Dirk No, they're integers in this convention; the first one is $1 \cdot e^0 + 2 \cdot e^0=3$ and the second one is $1 \cdot e^0+2 \cdot e^{\pi i}=-1$. $\endgroup$ – Ian May 20 at 13:58
1
$\begingroup$

It really depends on the definition... Scilab is using $$ X_k = \sum_{n=0}^{N-1}x_ n e^{-i 2 \pi k n/N}, \quad k = 0, \cdots, N-1 $$

While Wolfram's default definition is

$$ X_k = \frac{1}{\sqrt{N}}\sum_{n=0}^{N-1}x_ n e^{-i 2 \pi k n/N}, \quad k = 0, \cdots, N-1 $$

If you want Wolfram to use the same definition, you must use the parameter "FourierParameters->{1,-1}". The general case in Wolfram ({a,b}) is

$$ X_k = \frac{1}{n^{(1-a)/2}}\sum_{n=0}^{N-1}x_ n e^{i 2 b \pi k n/N}, \quad k = 0, \cdots, N-1 $$

$\endgroup$
  • $\begingroup$ Now, it's more clear :) 1/sqrt(N) is about normalization? $\endgroup$ – someuser1 May 20 at 14:03
  • $\begingroup$ @someuser1 Yes, as it was mentioned in a comment, the important thing is to define the inverse discrete Fourier transform in a compatible way. $\endgroup$ – PierreCarre May 20 at 14:05
  • $\begingroup$ @someuser1 In Wolfram's documentation they mention that {1,-1} is the usual convention in signal processing, while {1,-1} is the usual convention in data analysis. Their default is {0,1}. $\endgroup$ – PierreCarre May 20 at 14:09
  • 1
    $\begingroup$ @PierreCarre Sign error in your last comment. $\endgroup$ – Jean-Claude Arbaut May 20 at 14:11
  • $\begingroup$ @someuser1 See also reference.wolfram.com/language/tutorial/FourierTransforms.html $\endgroup$ – Jean-Claude Arbaut May 20 at 14:12

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