1
$\begingroup$

I've heard that you should remove the energy at Nyquist before performing the ifft. Why is it that you can't leave the Nyquist energy there, is there danger of aliasing somehow?

$\endgroup$
  • $\begingroup$ This is a DC value that is not desired and will distribute over all time samples as a value that could impact the quality of the "filtered" signal. Why you use the FFT? $\endgroup$ – Moti Apr 18 '15 at 17:27
  • $\begingroup$ Oh wow no way. Nyquist = negative DC? $\endgroup$ – Alan Wolfe Apr 18 '15 at 17:35
  • 1
    $\begingroup$ Remember that the Nyquist value, with regard to the FFT, does not provide information of value about the signal, unless you carry a careful analysis of the signal. If you sample in high enough frequency this value might be removed with the DC value. $\endgroup$ – Moti Apr 18 '15 at 17:39
  • $\begingroup$ Interesting! I'm just using ifft for audio synthesis from the frequency domain. Add an answer and I'll accept it! $\endgroup$ – Alan Wolfe Apr 18 '15 at 18:20
6
$\begingroup$

you don't have to set $X\left(\frac{N}{2} \right)=0$ if you don't want to. it will correspond to this component:

$$ X(k)\frac{1}{N}e^{j 2 \pi \frac{nk}{N}}\bigg|_{k=\frac{N}{2}} = X\left(\frac{N}{2} \right)\frac{1}{N}(-1)^n $$

but when you sample some $x[n]$, FFT it and find that $X\left(\frac{N}{2} \right) \ne 0$, you do not know the phase of that Nyquist component before it was sampled. the Nyquist component actually aliases with itself in such a way that the quadrature part of the negative frequency cancels the quadrature part of the positive Nyquist frequency component. such would look like:

$$ = \frac{X\left(\frac{N}{2} \right)}{N}(-1)^n = \frac{X\left(\frac{N}{2} \right)}{N}\left( \cos(\pi n) + A \sin(\pi n) \right) $$

$A$ could be anything and you wouldn't know it because $\sin(\pi n)$ is always zero for any integer $n$.

so if you're doing audio, i would likely set both the Nyquist and the DC components to zero and also insure the complex-conjugate symmetry with the other bins before iFFT. just to make sure that, within rounding error, the imaginary part of your result is zero (the result is purely real) and that you have an unambiguous magnitude and phase for every non-zero component.

$\endgroup$
  • $\begingroup$ Oh goodness, how interesting! So let's say I make a band limited saw wave up to bin n/2, you are saying I need to mirror it in the top half bins as complex conjugates? I'm surprised because right now I am doing band limited saw by only filling in up to n/2 and it seems to be correct as far as I can tell. What am I missing? Also, if I did want a DC offset, of say 0.25, would it be OK to use bin 0 (and only bin 0, not the Nyquist bin) to achieve that? Thanks again so much. You are a wealth of knowledge rbj (: $\endgroup$ – Alan Wolfe Apr 18 '15 at 22:45
  • $\begingroup$ if you're doing a complex FFT and iFFT, you better the hell mirror the top half bins with complex conjugates of the bottom half. since $X[0]$ and $X\left[\frac{N}{2}\right]$ are mirrored to themselves, they must be purely real. their imaginary parts must be zero. this means, whether it's the time-domain ($x[n]$ for $0\le n<N$) or frequency-domain $X[k]$, there are exactly $N$ independent degrees of freedom. $N$ real numbers go in and $N$ independent real numbers come out. $\endgroup$ – robert bristow-johnson Apr 18 '15 at 23:55
  • $\begingroup$ can't edit the previous comment anymore. i meant to write: "if you're doing a complex FFT and iFFT, you better the hell mirror the top half bins with complex conjugates of the bottom half" if $x[n]$ or $y[n]$ are or are meant to be purely real. $\endgroup$ – robert bristow-johnson Apr 19 '15 at 0:22

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.