Fourier / Signal Math Lab

Build a signal from sine waves and see its frequency spectrum. The lab runs a 128- to 1,024-point FFT, finds the fundamental, the harmonics and the THD, previews ideal filters and warns when a tone is above the Nyquist limit. A third mode works out sample-rate, bin-width and note-to-frequency numbers.

Calculator Numbers & Math Updated Oct 3, 2026
How to Use
  1. In Spectrum analyzer, type one sine component per line as frequency amplitude [phase°]: 8 1 is an 8 Hz sine of amplitude 1.
  2. Or set f₀ and press sine, square, saw or triangle to fill the box with that wave’s Fourier series, up to 16 terms below the Nyquist limit.
  3. Set the sample rate fₛ and the FFT size N (128 to 1,024). The bins are fₛ ÷ N apart: 1 Hz at the default 256 and 256.
  4. Read the peaks, the fundamental, the harmonic count and the THD under the plots. An orange warning names any component above fₛ ÷ 2 and the frequency it folds to.
  5. Switch to Filter preview for an ideal low-pass, high-pass, band-pass or notch filter (original in grey, filtered in pink), or to Sampling & Nyquist for duration, bin width, note ↔ frequency, period and wavelength.
Signal
PRESETS
Examples
Spectrum

Waveform (time domain)

Spectrum (frequency domain)

Fundamental
—
THD
—
Peaks
—
Bin width
—

Worked Example

A square wave from its harmonics. With f₀ = 8 Hz, fₛ = 256 Hz and N = 256, the square preset writes the odd harmonics 8, 24, 40 … 120 Hz with amplitudes 4/(πn): 1.273, 0.424, 0.255, 0.182, 0.141, 0.116, 0.098 and 0.085. The next one, 136 Hz, would be above the 128 Hz Nyquist limit, so the series stops there. Each harmonic lands exactly on a 1 Hz bin, so the spectrum shows the same eight heights, and the lab reports a fundamental of 8 Hz and a THD of 43.826% (harmonics up to the 12th).

CD audio. In Sampling & Nyquist, fₛ = 44,100 Hz and N = 1,024 give a window of 1,024 ÷ 44,100 = 23.22 ms, bins 44,100 ÷ 1,024 = 43.066 Hz wide, a Nyquist limit of 22,050 Hz and 512 usable bins. A4 is 440 Hz: a period of 1 ÷ 440 = 2.273 ms and a wavelength in air of 343 ÷ 440 = 0.78 m.

The common mistake: trusting an aliased peak. Sample a 200 Hz tone at 256 Hz and the spectrum shows one clean spike at 56 Hz (256 − 200) with amplitude 1, and nothing at 200 Hz. The FFT cannot tell the difference; only the sample rate can. At fₛ = 512 Hz the same tone appears at the right place, 200 Hz. Sample at more than twice the highest frequency present, or filter it out before sampling.

Show Work

Type at least one sine component (frequency and amplitude) to see the bin width, the peaks, the harmonic matching and the THD worked out.

Formulas

Discrete Fourier transform
X[k] = Σ x[n]·e^(−2πi·kn/N)
Bin width and window
Δf = fₛ ÷ N, T = N ÷ fₛ
Nyquist and aliasing
f_N = fₛ ÷ 2; f > f_N appears at |f − k·fₛ|, nearest k
Square wave
(4/π)·Σ sin(nωt) ÷ n, n = 1, 3, 5 …
Total harmonic distortion
THD = √(A₂² + A₃² + …) ÷ A₁
Note to frequency
f = 440 × 2^((m − 69) ÷ 12)

From Heat Flow to the FFT

Joseph Fourier claimed that any periodic function could be written as a sum of sines and cosines while studying how heat spreads through solids. He presented the idea in 1807 and published it in Théorie analytique de la chaleur in 1822. Partial sums of his series overshoot at a jump: J. Willard Gibbs described the effect in 1899 (Henry Wilbraham had found it in 1848), and the overshoot settles at about 9% of the jump, so a square wave that swings between −1 and +1 peaks near 1.18 however many terms you add.

Harry Nyquist showed in 1928 that a channel of bandwidth B can carry up to 2B independent pulses a second, and Claude Shannon gave the sampling theorem its standard form in 1949. James Cooley and John Tukey published the fast Fourier transform in 1965, cutting the work of an N-point transform from about N² to N log₂ N operations: for N = 1,024 that is about 10,240 instead of 1,048,576. Gauss had used a similar method around 1805, but it went unnoticed.

About This Tool

This lab builds synthetic signals from sine components, so you know exactly what went in and can check what the FFT reports. It lists the peaks, picks the fundamental and harmonics, gives the THD, flags every component above the Nyquist limit with the frequency it folds to, previews ideal low-pass, high-pass, band-pass and notch filters, and works out sampling and pitch numbers. It does not listen to a microphone; for live sound, use the Audio Spectrum Analyzer.

Everything runs in your browser; nothing is uploaded.

Related tools: Audio Spectrum Analyzer, Fourier Epicycle Drawer, and Convolution Calculator.

Frequently Asked Questions

What does the FFT show?

It turns the waveform (amplitude against time) into a spectrum (amplitude against frequency). The default signal, 8 1, 20 0.5, 33 0.3, shows three spikes at 8, 20 and 33 Hz with heights 1, 0.5 and 0.3. At fₛ = 256 Hz and N = 256 the window is 1 s long and the bins are 1 Hz apart, so whole-number frequencies land exactly on a bin. A 20.5 Hz tone falls between two bins and its spike reads about 0.32 instead of 0.5: that is spectral leakage.

What is the Nyquist frequency, and what is aliasing?

Sampling at fₛ can only represent frequencies up to fₛ ÷ 2, the Nyquist frequency. A tone above it does not vanish; it shows up at a lower, false frequency. The aliasing demo samples 200 Hz at 256 Hz: the only spike is at 256 − 200 = 56 Hz, with the full amplitude of 1. Raise fₛ above 400 Hz (try 512) and the spike moves to 200 Hz.

Why is a square wave’s 3rd harmonic one third of the fundamental?

Its Fourier series is (4/π)(sin ωt + sin 3ωt/3 + sin 5ωt/5 + …): odd harmonics only, falling as 1/n. A square wave of height 1 has a fundamental of 4/π = 1.273, a 3rd harmonic of 0.424 and a 5th of 0.255. A triangle wave falls as 1/n² (0.811, then 0.090), which is why it looks and sounds smoother. The presets stop below the Nyquist limit: at f₀ = 8 Hz and fₛ = 256 Hz that is 8 square-wave terms, up to 120 Hz.

What is THD, and why does the square preset show 43.826%?

Total harmonic distortion is the root-sum-square of the harmonics divided by the fundamental. A pure sine has 0%. The lab counts harmonics up to the 12th, so the square preset (3rd, 5th, 7th, 9th and 11th) gives 43.826%. The infinite series gives √(π²/8 − 1) = 48.3%. The triangle preset gives 11.963% against 12.1% for the full series.

What kind of filter is the preview?

An ideal brick-wall filter: the lab takes the FFT, zeroes every bin outside the pass band and transforms back. In the low-pass example (8 Hz, 20 Hz and 50 Hz tones, cutoff 15 Hz) only the 8 Hz tone gets through, at its full amplitude of 1; the high-pass at 30 Hz keeps only 50 Hz at 0.4. Real filters roll off gradually: a first-order RC low-pass is only 3 dB down at its cutoff and falls 20 dB per decade.

How do I use the Fourier / Signal Math Lab?

Just type your numbers. The answer shows up right away — there is no button to press. Change anything and it updates by itself.

Is it free? Does it work without internet?

Yes to both. It is free with no sign-up, and once the page has loaded it keeps working even with no internet.

Where does my data go?

Nowhere — every calculation runs on your own device. Nothing you enter is uploaded, logged, or stored.

Common Use Cases

Teaching Fourier series

Watch 8 odd harmonics, from 1.273 down to 0.085, add up to a square wave.

Sampling and aliasing

See a 200 Hz tone sampled at 256 Hz turn into a 56 Hz one.

Audio sample rates

CD audio at 44,100 Hz: Nyquist 22,050 Hz, and 43.066 Hz bins for a 1,024-point FFT.

Notes and pitch

A4 is 440 Hz: a period of 2.273 ms and a wavelength of 0.78 m in air.

Filter intuition

Strip the 20 Hz and 50 Hz tones out of a mix with a 15 Hz low-pass.

Last updated: