Puzzled by Nyquist frequency

Say I have a 1kHz sine, so no higher harmonics, then I need to sample it at least at 2kHz to be able to reconstruct it.
But if I sample at 2kHz, but all my samples are on the zero-crossing, then my sampled signal doesn't show a sine at all, rather the ECG of a deceased patient. How can that be explained?

This can be expanded to higher sampling frequencies too. If I sample a more complex waveform at 10kHz, I should at least get the first 5 harmonics, but if the waveform is such that the samples are each time zero, then again we get nothing. This isn't far-fetched, it's perfectly possible for a rectangle wave with a duty cycle < 10%.

So why is it that the Nyquist-Shannon criterion seems to be invalid here?

• The Nyquist criterion is a minimum. Other issues, such as aliasing, might necessitate a higher sampling, or other countermeasures. – drxzcl Jul 20 '11 at 13:00
• Wow! 3 answers for 6 views! – Federico Russo Jul 20 '11 at 13:06
• @FedericoRusso You do have a tendency to ask good questions – m.Alin Apr 1 '12 at 17:24
• Short of it: In your example sampling a 1kHz sine at 2kHz aliases the signal to that of a 0Hz sine—resulting in the dead patient! – Phil Jan 8 '15 at 0:57

You actually need just over 2 kHz sampling rate to sample 1 kHz sine waves properly. It's $$f_N < f_S / 2$$ not $$f_N \le f_S / 2$$

P.S. If you took your signal into complex space, where a sinusoid is of the form $$v(t) = Ae^{j(2 \pi f t - \theta)} = A(\cos(2 \pi f t - \theta) + j \sin(2 \pi f t - \theta))$$ where t is time, A is amplitude, f is frequency, and θ is phase offset, $$f_N = f_S / 2$$ is the point where the frequency "folds over", i.e. you cannot distinguish f from -f. Further increases in frequency will appear, after sampling, to have the sampling frequency subtracted from them, in the case of a pure sinusoid.

Non-Sinusoids

For the case of a square wave at 1 kHz with a duty cycle less than or equal to 10% which is sampled at 10 kHz, you are misunderstanding the input.

First you would need to decompose your waveform into a Fourier series to figure out what the amplitudes of the component harmonics are. You will probably be surprised that the harmonics for this signal are quite large past 5 kHz! (The rule of thumb of third harmonic being 1/3 as strong as the fundamental, and 5th being 1/5 of fundamental, only applies to 50% duty cycle square waves.)

The rule of thumb for a communications signal is that your complex bandwidth is the same as the inverse of the time of your smallest pulse, so in this case you're looking at a 10 kHz bandwidth minimum (-5 kHz to 5 kHz) for a 10% duty cycle with the fundamental at 1 kHz (i.e. 10 kbps).

So what will ruin you is that these strong higher-order harmonics will fold over and interfere (constructively or destructively) with your in-band harmonics, so it's perfectly expected that you might not get a good sampling because so much information is outside the Nyquist band.

• That doesn't explain the second example though, where the sample frequency is 10 times the groung frequency – Federico Russo Jul 20 '11 at 13:07
• Yeah, missed that. Added to my answer. Fun thing to think about: Category 5e wire, which can transport Gigabit Ethernet data, has a specified bandwidth of 100 MHz. Cat 6 goes to 250 MHz and cat 7 goes to 750 MHz. – Mike DeSimone Jul 20 '11 at 13:24
• So that would mean that for the pulsed signal amplitude and phase for every harmonic has a mapping to a mirrored harmonic with exactly the same phase, but inverted amplitude? – Federico Russo Jul 20 '11 at 13:29
• @Federico: "fold over" in this case means mirrored about the Nyquist frequency. So if you are sampling at 10 kHz, and you try to sample a 11 kHz sine, you'll get 9 kHz output instead. Try to sample 13 kHz and you'll get 7 kHz out instead. – endolith Jul 20 '11 at 13:51
• For the last comment, the example is when you look at the cars on TV: when the rotation speed approaches a multiple of the framerate, the wheel seems slowing down until it's still, and then starts rotating in the opposite sense. – clabacchio Apr 13 '12 at 12:56

Mike explains it well: it's the aliasing which makes the harmonics disappear in the sampled signal, the folding of the higher frequencies from $F_S + f$ to $F_S - f$.
When working with sampled signals you always have to make sure to filter out anything above $F_S / 2$. In this spectrum the blue part is your base band signal's spectrum from $-F_S / 2$ to $F_S / 2$. (See this question about negative frequencies).
Note that this spectrum is repeated around every multiple of $F_S$. In this example there's no problem; the original signal is separated from the images, and can be reconstructed. In this example (only positive frequencies shown) we can see that the base band signal extends to beyond $F_S / 2$. Due to the folding aliases overlap with our base signal, and there's no way we can filter them out again. That's why you need a (sharp) low-pass filter.

Now you may say that the pulse will look completely different after low-pass filtering, and that's right, but if you don't want that you've chosen your sample frequency too low. (For a discontinuous signal like the pulse, which has an infinite spectrum, you will always have distortion, whatever your $F_S$). Remember that you can reconstruct the signal only for frequencies smaller than $F_S / 2$.

• +1 for the pictures. Make it a lot more clear. – Federico Russo Jul 20 '11 at 14:49
• Yay pictures! I should use those more often, but I have too much fun with ASCII art. Anyway, all that overlap in figure 2 could be usable if the frequencies you actually use are completely within the non-overlapping part, but this isn't common outside of sigma-delta modulation. – Mike DeSimone Jul 20 '11 at 21:53
• In some cases, it may be okay to let through in to the sampling stuff that is above Fs/2, if one will, after sampling, remove anything which is at the aliased frequencies. For example, if one wants to end up with sampled audio at 8,000Hz but not filter out stuff below 3,500, it may be hard to make a filter that sharp using analog circuitry. On the other hand, if one starts by sampling at 16,000Hz and digitally filters out stuff above 4,000Hz, one would only need an analog filter which attenuated stuff above 12KHz while keeping stuff below 4KHz. Anything between 4-12Khz would alias to 4-8Khz. – supercat Mar 1 '12 at 16:33
• @supercat - Your anti-alias filter should always be analog. I agree with your point about the analog filter, but the numbers you're using are incorrect. 4-12kHz will alias to 4-12kHz, not 8kHz. (You can easily see this if you check bandwidths, which should be equal.) – stevenvh Mar 1 '12 at 16:49
• @stevenvh: Typically, the result of sampling is described solely in terms of frequencies at Nyquist or below, I think, though every frequency below Nyquist will be aliased to one between Nyquist and the sampling rate. My point is that if one is planning to digitally filter anything above 4KHz, one doesn't have to worry that frequencies between 8KHz-12Khz will get folded back to the range 4KHz-8KHz; since they'll be filtered out anyway. One nearly always needs some sort of analog anti-aliasing filter, but in many cases oversampling can ease the requirements considerably. It's... – supercat Mar 1 '12 at 17:02

Theorem is ok. Your signal should NOT contain frequencies equal or higher than half of sampling rate, accordint to Nyquist. Shannon probably allowes it, but it is his version of theorem, which probably causes ambiguity at critical frequency.

Edit (Re: downvoting for short answer ?): I dont see necessity to explain the sampling method itself. The question is about confusion "is critical frequency included into band or it is not", and if wording of theorem by Shannon contains fault. It actually does (as I see it in the world wiki). Or most likely the wiki authors cited his word inprecisely. And by the way, there are 4 independent authors in 20th century of this very theorem, so the confusion of anyone learning the idea from random sources can get worse.

• If your sampling input doesn't have some kind of low pass filter, nothing should be filtered out; all harmonics should fold over and potentially interfere with each other. Some modern radios use Nyquist frequency folding as a band shifter by using a wide-band-input ADC with a bandpass filter on the front end. – Mike DeSimone Jul 20 '11 at 13:23
• @Mike DeSimone: Thank you for explaining the aliasing effect, but again, question is not about "end-of-band", not "in-band" or "out of band" reconstruction. – user924 Jul 20 '11 at 16:24

If you have 2 samples on a sine wave of $N Hz$, and they occur at the zero-crossings, at $\frac{1}{2}N$ and $1N$ then you can determine the frequency of the signal by the time between the two samples.

$f=\dfrac{1}{2t}$

Where $f$ is the frequency and $t$ is the time between two zero-crossing samples.

But according to Wikipedia:

In essence, the theorem shows that a bandlimited analog signal that has been sampled can be perfectly reconstructed from an infinite sequence of samples if the sampling rate exceeds 2B samples per second, where B is the highest frequency in the original signal.

So a sampling frequency of twice the frequency is wrong - it should be just over twice the frequency. That way successive samples capture slightly different portions of the waveform.

• Like I also said to Mike: that doesn't explain the second example though, where the sample frequency is 10 times the groung frequency – Federico Russo Jul 20 '11 at 13:09
• A rectangle wave has some incredibly high harmonics. Nyquist states it is for just over 2x the highest frequency. The highest frequency could be hundreds, if not thousands of times higher than a 50% duty cycle. – Majenko Jul 20 '11 at 13:24
• It is also for a continuous signal - a PWM rectangle wave at 10% duty is not continuous. A 50% PWM could be said to be a continuous signal for the lowest frequency (the duty cycle), but not for the higher frequencies. – Majenko Jul 20 '11 at 13:26
• @Matt - every signal is cintinuous for the lowest frequency, since all composing frequencies are sines, according to Fourier. It's also perfectly possible to make Federico's pulse continuous, and still have the same sampled result. – stevenvh Jul 20 '11 at 13:40

When sampling at a particular rate F, every frequency component f will generate aliases of the form kF+f and kF-f for all integer values of k. In common usage, there are no frequency components above F/2 when the signal is sampled, so the only components in the range 0 to F/2 will be those that were present in the original signal. After sampling, there will be signal components above F/2 (generated as aliases of those below). The most troublesome of these for any frequency f in the original signal will be the one at frequency F-f.

Note that as frequency f approaches F/2 from below, the first alias frequency will approach F/2 from above. If the input contains a signal at frequency F/2-0.01Hz, there will be an alias at frequency F/2+0.01Hz--just 0.02Hz above it. Separating the original and alias signals will be theoretically possible, but in practice difficult. The sampled waveform will appear as the sum of two equal-strength waves of nearly equal frequency. As such, its amplitude will appear to change with the relative phase of the higher-frequency waves. In the case where the input frequency is exactly F/2, the alias frequency will also be exactly F/2. Since there will be no frequency separation at all between the original and alias, separation will be impossible. The phase relationship between the original and aliased signals will determine the amplitude of the resulting signal. If the original and aliased signals are 180 degrees out of phase, the original and aliased signals will precisely cancel.