1
$\begingroup$

I have a table of list of complex numbers. I constructed the table in the following way: the table contains odd number $N$ of elements. The $N/2+1$ element of table is real. $N/2+2$ element is complex conjugate of $N/2$ element, and this symmetry goes all the way to $N$th element being complex conjugate of 1st element. Now, I write the command Fourier to this list, but it returns me complex numbers. The whole point of the above symmetry was to return real list. How do I deal with this issue?

$\endgroup$
  • 4
    $\begingroup$ If your data is such that the Fourier transform should be real, the imaginary components are probably due to numerical inaccuracies and should be very small. Then you can use Chop to remove them. Re is of course an alternative, but the imaginary components are large and not removed by Chop, chance is you made a mistake. $\endgroup$ – C. E. Aug 27 '16 at 8:03
  • $\begingroup$ I wonder if what you want is equivalent to one of the FourierDCT variants? $\endgroup$ – Daniel Lichtblau Aug 27 '16 at 19:30
1
$\begingroup$

The pattern that you need to get a real output from Fourier can be found by applying InverseFourier to a real sequence. For example

2 InverseFourier[{0, 1, 0, 0}] // Rationalize
(* {1, -I, -1, I} *)

With zero-based indexing of an n point transform, 0 and n/2 (if n even) should be real and elements k and n-k should be complex conjugate pairs.

$\endgroup$
1
$\begingroup$

First, make sure your symmetry is correct. fourierreals is a list of complex numbers with the correct symmetry. When you take InverseFourier of that, you can see you get the original sequence back, but with roundoff error (because all the FFT calculations are done in floating point).

reals = RandomInteger[{-5, 5}, 16];
fourierreals = Fourier[reals]
InverseFourier[fourierreals]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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