DSPRelated.com
Forums

Newbie Seeking Help: Question about the FFT -> Imaginary Part

Started by angusyoung1000 October 19, 2004
I've been reading up on how to perform an FFT. I do not understand why
I am to set the imaginary part of the calculation to zero, however.
Here is my resource:

http://www.relisoft.com/Science/Physics/fft.html

See step 3 about mid-way down the page.

Is this correct? If so, please explain to me why this is to be done.

Thanks,
AY
angusyoung1000@juno.com (angusyoung1000) writes:

> I've been reading up on how to perform an FFT. I do not understand why > I am to set the imaginary part of the calculation to zero, however. > Here is my resource: > > http://www.relisoft.com/Science/Physics/fft.html > > See step 3 about mid-way down the page. > > Is this correct? If so, please explain to me why this is to be done.
That step is correct, AY. The reason is the same reason one zeros the imaginary part of a complex number to represent a real numer: the FFT is a specific implementation of the DFT, and the domain of the DFT, in a mathematical sense, is the complex numbers, not the reals. Thus if the inputs are reals, the imaginary components of the complex input vectors must be zeroed. -- % Randy Yates % "I met someone who looks alot like you, %% Fuquay-Varina, NC % she does the things you do, %%% 919-577-9882 % but she is an IBM." %%%% <yates@ieee.org> % 'Yours Truly, 2095', *Time*, ELO http://home.earthlink.net/~yatescr
Angus,
Bless, I swear you students are getting worse every year. You're on a 
Highway to Hell, Mr. Young! I tried out of curiosity and it took me 10 
seconds to find the answer with Google. Search for the phrase "set the 
imaginary parts to zero" !
Cheers, Syms.
"angusyoung1000" <angusyoung1000@juno.com> wrote in message 
news:87995080.0410181917.4fcc39a8@posting.google.com...
> I've been reading up on how to perform an FFT. I do not understand why > I am to set the imaginary part of the calculation to zero, however. > Here is my resource: > > http://www.relisoft.com/Science/Physics/fft.html > > See step 3 about mid-way down the page. > > Is this correct? If so, please explain to me why this is to be done. > > Thanks, > AY
angusyoung1000@juno.com (angusyoung1000) writes:

> I've been reading up on how to perform an FFT. I do not understand why > I am to set the imaginary part of the calculation to zero, however. > Here is my resource: > > http://www.relisoft.com/Science/Physics/fft.html > > See step 3 about mid-way down the page. > > Is this correct? If so, please explain to me why this is to be done. > > Thanks, > AY
PS: AY try this: generate a complex sinusoid, x[n] = e^(j*2*pi*f*n*T), and input that into your FFT algorithm. For real inputs, the FFT output will be Hermitian symmetric (i.e., for a sine or cosine wave, the output will have two spikes, one on each side of zero), but for this complex input, it won't be (there will be only one spike in the whole output). -- % Randy Yates % "And all that I can do %% Fuquay-Varina, NC % is say I'm sorry, %%% 919-577-9882 % that's the way it goes..." %%%% <yates@ieee.org> % Getting To The Point', *Balance of Power*, ELO http://home.earthlink.net/~yatescr
angusyoung1000@juno.com (angusyoung1000) wrote in message news:<87995080.0410181917.4fcc39a8@posting.google.com>...
> I've been reading up on how to perform an FFT. I do not understand why > I am to set the imaginary part of the calculation to zero, however. > Here is my resource: > > http://www.relisoft.com/Science/Physics/fft.html > > See step 3 about mid-way down the page. > > Is this correct? If so, please explain to me why this is to be done.
It's basically a matter of proper memory initialization. The remark is based on the assumption that the input data are real- valued. The FFT implementation works on complex-valued data and produces a complex-valued output. The remark on setting the imaginary part to zero PRIOR to the computation is just a reminder for the programmer to ensure that no garbage is left in the imaginary parts of the numbers, either from memory allocations or from previous calls to the routine. Having said that, others have already pointed out that a real number x can be written on complex form as x = real{x} + i*imag{x} where imag{x} == 0. If this representation is the cause of your confusion, you would need to read up on some basic theory of complex numbers. Rune
allnor@tele.ntnu.no (Rune Allnor) wrote in message news:<f56893ae.0410190250.78e1d674@posting.google.com>...
> angusyoung1000@juno.com (angusyoung1000) wrote in message news:<87995080.0410181917.4fcc39a8@posting.google.com>... > > I've been reading up on how to perform an FFT. I do not understand why > > I am to set the imaginary part of the calculation to zero, however. > > Here is my resource: > > > > http://www.relisoft.com/Science/Physics/fft.html > > > > See step 3 about mid-way down the page. > > > > Is this correct? If so, please explain to me why this is to be done. > > It's basically a matter of proper memory initialization. > > The remark is based on the assumption that the input data are real- > valued. The FFT implementation works on complex-valued data and produces > a complex-valued output. The remark on setting the imaginary part to > zero PRIOR to the computation is just a reminder for the programmer to > ensure that no garbage is left in the imaginary parts of the numbers, > either from memory allocations or from previous calls to the routine. > > Having said that, others have already pointed out that a real number x > can be written on complex form as > > x = real{x} + i*imag{x} > > where imag{x} == 0. If this representation is the cause of your confusion, > you would need to read up on some basic theory of complex numbers. > > Rune
Thanks guys for the feedback. I was thinking that the article was talking about setting the imaginary part of the twiddle factor to zero. This is what was throwing me off. OK, well now it all makes perfect sense to me.
"angusyoung1000" <angusyoung1000@juno.com> wrote in message
news:87995080.0410181917.4fcc39a8@posting.google.com...
> I've been reading up on how to perform an FFT. I do not understand why > I am to set the imaginary part of the calculation to zero, however. > Here is my resource: > > http://www.relisoft.com/Science/Physics/fft.html > > See step 3 about mid-way down the page. > > Is this correct? If so, please explain to me why this is to be done. > > Thanks, > AY
It's o.k. as far as it goes but you are wasting half your fft - write to the webmaster at your referenced url and insist he/she/it stops promoting this decadent usage. Best of Luck - Mike