WORKED EXAMPLES
Check the bins before reading a spectrum.
These examples are arithmetic grids, not measurements of a waveform.
48 kHz and 4,096 samples
With fs = 48,000 Hz and N = 4,096, spacing is 48,000/4,096 = 375/32 = 11.71875 Hz. The represented indices run from 0 through 2,048, for 2,049 bins including DC. Because N is even, the last bin is exactly 24,000 Hz, the theoretical Nyquist frequency.
For a 1,000 Hz target, k = 85 is closest. Its centre is 31,875/32 = 996.09375 Hz, so centre minus target is −125/32 = −3.90625 Hz. That does not establish that a tone exists at either frequency.
The record duration is 4,096/48,000 = 32/375 ≈ 0.085333333333 s. The final sample’s offset is 4,095/48,000 = 273/3,200 = 0.0853125 s.
An odd-length grid ends below Nyquist
Use fs = 100 Hz, N = 5 and target = 50 Hz. Spacing is 20 Hz. The represented centres are 0, 20 and 40 Hz. Theoretical Nyquist is 50 Hz, but there is no 50 Hz bin. The closest available centre is k = 2 at 40 Hz, with signed error −10 Hz. The target is allowed; an unavailable endpoint is not invented.
An exact midpoint tie
Use fs = 800 Hz, N = 8 and target = 150 Hz. Spacing is 100 Hz. The target sits halfway between k = 1 at 100 Hz and k = 2 at 200 Hz. Binspan’s explicit tie rule selects the lower index: k = 1, signed error −50 Hz.
Blank and zero mean different things
Clear the target field to inspect the grid alone. No target result is produced. Enter 0 to request the zero-frequency DC bin; its index, centre and error are all zero. The underlying grid does not change.
A large N does not create a giant table
With fs = 1 Hz and N = 1,000,000,000, spacing is exactly 1/1,000,000,000 Hz and the grid contains 500,000,001 nonnegative bins. Binspan shows a fixed small set of endpoints and target neighbours. It neither allocates a full spectrum nor claims that a measurement can resolve tones one nanohertz apart.