I am trying to understand the effect of the critical Nyquist frequency when applying the Goertzel algorithm for estimating the power spectrum of a discrete signal. (Goertzel doesn't really matter, FFT applies as well). Assume that I generate $N=512$ discrete values of the sine wave $x[n]$, where $n=1,2,\ldots,N$ using the function

$$x[n]=\sin(30 \cdot 2\pi n/N) + \sin(60 \cdot 2\pi n/N) + \sin(120 \cdot 2\pi n/N) \\ + \sin(260 \cdot 2\pi n/N) + \sin(330 \cdot 2\pi n/N)$$

After applying the Goertzel algorithm, there will be 512 power spectrum values at $k=1,2,\ldots,512$. Looking at the results, it appears that in the upper half of the scale ($257 \leq k \leq 512$), the real (vs. imag) power spikes for frequencies 1/260 and 1/333 are negative. In addition, in the lower half of the range ($1 \leq k \leq 256$), the power value for $k=60$ is zero, and there are false positive spikes at spurious frequency values. However, if I double the length of the generated signal to 1024, and only apply the Goertzel algorithm to $k=1,2,\ldots,512$, all of the power spectrum values at $k=30, 60, 120, 260$, and $330$ are positive and there are no false positive values below 512 and the value at k=60 is non-zero and positive. My understanding of the Nyquist requirement is that the power value at $k=1$ is unreliable.

So what I believe I have observed is that if you want to use the real (vs imag) power spectrum values at frequencies between 1/2 and 1/512, you need to provide a signal with twice (1024) the number of samples. Another way of saying this is that if you have a discrete signal with 1024 samples, you can only determine the power spectrum at frequencies greater than 1/512, i.e., 1/511,1/510,...,1/2.

Is there a law or equation that states that the sample size $N$ needs to be at least twice as long as the longest wavelength to be assessed? Or, is this really the meaning of Nyquist, i.e. $2N$.


1 Answer 1


If it is a real signal, as you are doing, then the negative spectrum will be the complex conjugate of the positive spectrum. Since there are N samples in frequency given N samples in time, and the frequency axis extends from 0 to N-1 where 0 represents DC and N represents the sampling rate (with the upper half of this from N/2 to N-1 equally representing the negative frequency axis) then yes in this case you need 2N samples to represent the spectrum without aliasing; and yes this is explained by the Nyquist-Shannon sampling theorem: https://en.wikipedia.org/wiki/Nyquist%E2%80%93Shannon_sampling_theorem

However if you used an equivalent complex signal, then N samples would be sufficient.

$$x[n]=e^{j(30 \cdot 2\pi n/N)} + e^{j(60 \cdot 2\pi n/N)} + e^{j(120 \cdot 2\pi n/N)} \\ + e^{j(260 \cdot 2\pi n/N)} + e^{j(330 \cdot 2\pi n/N)}$$

  • $\begingroup$ Thanks, the Theorem flat out states at the beginning that 2B Hertz are needed when B is the greatest frequency. That clears things up -- but I do need more self-study before attempting to simulate complex numbers. $\endgroup$
    – user16354
    Dec 29, 2018 at 18:13
  • 1
    $\begingroup$ This recent answer may help you as well, assuming you are comfortable with Fourier Transforms and in particular impulse trains in time and frequency, and that multiplication in time is convolution in frequency, etc: dsp.stackexchange.com/questions/54423/…. And important to not miss the point that if you have a full complex signal with real and imaginary components, only B Hz are needed to uniquely sample a highest frequency of B. $\endgroup$ Dec 29, 2018 at 18:15
  • $\begingroup$ And I misread your comment about more self-study. The best mental short-cut for me is to review Euler's Identity, and to realize that a single impulse in frequency at frewquency $\omega_c$ is $e^{j \omega_c t}$ in time. And that the representation $Ke^{j\phi}$ is the same thing as $K\angle \phi$. From that my answer should be clearer in that your representation with sines actually includes two impulses in frequency (a positive and negative) while my representation with e is just a single impulse, for each instance. $\endgroup$ Dec 29, 2018 at 18:19
  • 1
    $\begingroup$ Great - that explains why your suggested use of a complex signal fundamentally requires only N samples. $\endgroup$
    – user16354
    Dec 30, 2018 at 21:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.