Fazed by Fourier Transform Phases
Date: 11/14/2011 at 05:13:00 From: Richard Subject: Fourier manipulation of 'real' data I would like to use the discrete Fourier transform (DFT) to manipulate "real world" data -- for example, convolution and deconvolution of waveforms. I understand that the transform works on complex data, and the general technique seems to be to feed in the raw data as real values only, setting the imaginary inputs to zero. I also understand that after the forward transform, the outputs are complex and that complex maths must be used when, say, multiplying two spectra together. The part that confuses me is that after carrying out the inverse transform, the outputs are complex (at least, in my experiments). I can simply discard the imaginary part, but ... what, exactly, am I throwing away? What does a complex value in the time domain actually represent? It occurs to me that had I not wanted to stop the calculations there, but instead re-used the inverse DFT result without discarding the imaginary part, the subsequent results of calculations would be different, compared to saving only the real part in a file for later re-use. Then the direct equivalence between time domain convolution and frequency domain convolution would not be valid for at least one of the solutions. (It's also possible that my calculations are wrong, and that any calculations using DFT'ed "real" data should provide only "real" data when inverse-transformed.) I think I understand that when in the frequency domain, the complex values represent magnitude and phase of various sinusoids that, when summed, add up to the time domain waveform at the input. Presumably, these can be present in any permutation, even though the incoming waveform was purely "real." So it's not obvious that by mixing two arbitrary waveforms in a convolution operation, pure "real-ness" will be maintained at the output. I have taken two sets of data with ample zero padding, performed discrete (fast) Fourier transforms on them, divided one spectrum by the other using complex arithmetic, and then performed the inverse transform. All calculations were done with double precision floating point values. The result is clearly complex -- not just small imaginary values due to rounding errors, etc. Many thanks for looking at my question. I have the feeling that this is a relatively common question, but one which various web sites I have looked at "gloss over."
Date: 11/21/2011 at 14:21:05 From: Doctor Douglas Subject: Re: Fourier manipulation of 'real' data Hi Richard, I will try to answer your question from a general point of view, avoiding notational details that might obscure things. The short answer is that while the "raw" data in the time domain are purely real, the transformed data in general contain complex components because you have to account for the phase of each Fourier component. The in-phase component is generated from the cosine, and the out-of-phase component is generated from the sine. You might well have expected this, reasoning from the well-known relationship in Euler's formula: exp(i*theta) = cos(theta) + i*sin(theta) In the special case where the original function f(t) is even (and real-valued), only the cosine terms contribute in the Fourier Transform, and the resulting transform is purely real. If f(t) is odd (and real-valued), the Fourier Transform is purely imaginary. These results are also true in the FFT case, but it's important to get the function f(t) properly encoded in the input to ensure that it has the right symmetry properties for t < 0. There can sometimes be confusion about where the t = 0 point is, as well as the array ordering for t < 0 vs t >= 0. In the Fourier domain, you are of course welcome to do whatever you wish (filtering, convolution, etc.). You may end up with something in the frequency domain, carry out the inverse FFT, and get a complex function in the time domain. This isn't fatal, but it suggests that a different operation might preserve the right symmetry properties, which will produce a real-valued function in either the time or frequency domain (depending on your goal). For example, the power spectrum is the squared *magnitude* of the frequency components, and should therefore be a real-valued function in the frequency domain: (w_n) = |F(w_n)|^2 = Conj[F(w_n)] x F(w_n) Here, the complex conjugation forces P to be real-valued. And you can probably see now that those imaginary components are actually important: together with the real components, they provide information about phase and magnitude at each frequency. - Doctor Douglas, The Math Forum http://mathforum.org/dr.math/
Date: 11/29/2011 at 15:53:05 From: Richard Subject: Thank you (Fourier manipulation of 'real' data) Dear Dr. Douglas, Many thanks for taking the time to answer my question regarding the Fourier transform. I now realise that my problem was a poor implementation of the FFT that was resulting in numerical errors, revealed by a lack of perfect symmetry about the t = 0 point. I changed to a different FFT implementation, and this fixed the problem. I am sure I will also return to your notes as I experiment further! Many thanks, again. Richard
Search the Dr. Math Library:
Ask Dr. MathTM
© 1994-2013 The Math Forum