Solution (source code)

= Solution

In this digital-sampling context, Nyquist's theorem means the <Nyquist–Shannon sampling theorem>. A continuous <signal> with no Fourier content outside $|f|\le B$ can be reconstructed from uniformly spaced samples taken sufficiently fast. The familiar practical condition is
$$
\boxed{f_s>2B,\qquad T_s=\frac1{f_s},\qquad f_N=\frac{f_s}{2}.}
$$
Here $f_N$ is the Nyquist <frequency>, while $2B$ is the Nyquist rate required by that <signal> bandwidth. A finite-energy bandlimited formulation allows equality; a rule intended to include arbitrary pure sinusoids at the boundary must be strict, because $\sin(\pi f_st)$ vanishes at every sampling time $t=n/f_s$.

The mechanism is visible in the <Fourier transform>. Sampling by a time comb creates shifted copies of the original spectrum, separated by $f_s$:
$$
x_s(t)=\sum_nx(nT_s)\delta(t-nT_s),\qquad
X_s(f)=f_s\sum_kX(f-kf_s).
$$
If those copies do not overlap, an ideal reconstruction filter selects one copy and recovers the original waveform. Equivalently, ideal interpolation uses the normalized <sinc function>:
$$
\boxed{x(t)=\sum_{n=-\infty}^{\infty}x(nT_s)
\operatorname{sinc}\!\left(\frac{t-nT_s}{T_s}\right),\qquad
\operatorname{sinc}u=\frac{\sin\pi u}{\pi u}.}
$$
Each interpolation function is one at its own sample and zero at all other sample times. Exact reconstruction presumes the bandwidth condition, an ideal sampling clock and the full sample sequence.

If the spectrum extends beyond half the <sampling rate>, different continuous frequencies become indistinguishable: this is <aliasing>. A sinusoid at <frequency> $f$ is indistinguishable on the sampling grid from frequencies differing by integer multiples of $f_s$, with the usual sign reflection for real <signals>. For example, $10\,\mathrm{kHz}$ sampled at $8\,\mathrm{kS\,s^{-1}}$ aliases to $2\,\mathrm{kHz}$; a later digital filter cannot tell which <signal> generated those samples.

Use an analogue <anti-aliasing filter> before the <analogue-to-digital converter> and choose a <sampling rate> leaving room for its finite transition band. Faster sampling can relax that analogue filtering problem, but simply increasing the number of samples in a fixed-duration record does not improve the independent Fourier-bin spacing beyond approximately $1/T$. A long recording is needed for low-frequency resolution, while a small sampling interval is needed for high-frequency coverage. Finite records also introduce windowing and <spectral leakage>.

Digitization adds amplitude quantization as well as time sampling. An ideal $N$-bit converter spanning voltage range $V_{\rm span}$ has step $\Delta=V_{\rm span}/2^N$. When quantization error may be modeled as independent and uniform across one step, its rms size is $\Delta/\sqrt{12}$; small coherent <signals> need not obey that white-noise approximation. \b[<Sampling rate> controls temporal ambiguity, recording duration controls <frequency> resolution, and converter resolution controls amplitude discretization.]