FFT Fourier Decomposition
Explore signal components with a radix-2 Cooley-Tukey transform in your browser
Signal
12 lines · 137 charsUp to 65,536 samples. Everything is computed in this tab.
Spectrum
256 point FFT · 1 Hz per binSignal
Magnitude spectrum (amplitude)
Phase spectrum (cosine phase, −π to π)
A sine of phase 0 reads −π/2. Bins with negligible magnitude show 0.
| Frequency | Amplitude | Phase |
|---|---|---|
| 50.00 Hz | 1.000 | -1.571 rad |
| 90.00 Hz | 0.450 | -0.971 rad |
One-sided amplitudes: 2·|X|/Σwindow, and 1·|X|/Σwindow at 0 Hz and Nyquist. Bin spacing 1 Hz, window: rectangular.
Inverse FFT round-trip error (against the windowed samples): —
Examples
Exact 50 Hz tone
analyzeFourier(generateSyntheticSignal([{ frequency: 50, amplitude: 1, phase: 0 }], 256, 256), 256)peaks[0] -> { frequency: 50, magnitude: ~1 }Fifty cycles fit exactly into 256 samples at 256 Hz, so all energy lands on bin 50.
Lossless round-trip
ifft(fft([1.25, -2, 0.5, 3, 4.5, -1, 0, 2]))the original 8 samples backForward then inverse FFT inverts exactly up to floating-point rounding.
About this tool
FFT Fourier Decomposition analyzes signals with analyzeFourier(input, sampleRate): it returns the complex spectrum, per-bin magnitude/phase entries, magnitude-ranked peaks, and the ifft-reconstructed signal. Building blocks fft, ifft (alias inverseFFT), generateSyntheticSignal (alias generateSignal), detectPeaks, and isPowerOfTwo are exported individually.
The transform is an iterative radix-2 Cooley-Tukey FFT: inputs must be a positive power of two (never padded or mutated), bin k sits at k * sampleRate / N, and magnitudes scale by 2/N (1/N at DC and Nyquist). Peak detection keeps local maxima above 1e-10 and sorts them loudest-first.
Everything is deterministic and client-side: the same samples and sample rate always give the same bins and peaks, and round-tripping real data through ifft(fft(x)) recovers the input within floating-point tolerance.
How to use this tool
Prepare power-of-two samples
Supply 64, 256, 1024, or any 2^n-length array — other lengths throw instead of padding.
Analyze at the true rate
Pass the real sample rate so bin frequencies (k * rate / N) land on the intended hertz.
Read peaks loudest-first
Take peaks[0] as the dominant tone with its index, frequency, magnitude, and phase.
Verify with reconstruction
Compare reconstructed against the input to confirm the spectrum explains the signal.
Use cases
Identifying dominant tones
Decompose a recording into ranked sine components with frequency and phase.
Teaching bin math
Show how the same 50 Hz tone moves bins when the sample rate changes at fixed N.
Validating signal chains
Round-trip samples through fft/ifft to prove the pipeline is lossless.
Common mistakes
Mistake:Passing a non-power-of-two length and expecting zero-padding.
Fix:The FFT throws on lengths like 100 or 3 — resample or truncate to 2^n first (e.g. 128, 256).
Mistake:Reading peak index as hertz.
Fix:Index is the bin number; multiply by sampleRate / N for hertz — bin 25 at 512 Hz/N=256 is still 50 Hz.
Mistake:Expecting DC energy in peaks.
Fix:detectPeaks scans interior bins only, so a flat DC signal reports bin 0 magnitude with an empty peaks list.
Frequently asked questions
What does this tool do?
It analyzes signals with analyzeFourier(input, sampleRate) — complex spectrum, per-bin magnitudes/phases, loudest-first peaks, and the ifft reconstruction — plus fft, ifft (inverseFFT), generateSyntheticSignal (generateSignal), detectPeaks, and isPowerOfTwo.
Why is my 50 Hz tone on the wrong bin?
Bins are k * sampleRate / N: 50 Hz sits on bin 50 at 256 Hz/N=256 but bin 25 at 512 Hz/N=256. Read frequency, not index, and pass the true sample rate.
Is my signal uploaded or stored?
No. Synthesis, FFT butterflies, peak picking, and reconstruction run entirely in your browser.
Why did the FFT throw, or why are there no peaks?
Lengths must be a positive power of two — the FFT throws instead of padding, so resize to 2^n. An empty peaks list with strong bin-0 energy means a DC-only signal, which peak detection intentionally skips.
Related guides
References & standards
Related tools
.env Secret Safety Linter
Validate .env syntax and spot likely leaked credentials or placeholder secrets.
.gitattributes Generator
Build .gitattributes rules for line endings, Git LFS, GitHub linguist marks and merge drivers — with a one-line explanation for every rule.
.htaccess Generator
Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth
2D Fluid Dynamics & Particle Physics Sandbox
A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.
A/B Test Sample Size Calculator
Compute required sample size per variant and test duration from baseline conversion rate, minimum detectable effect, alpha and power.
ABA Routing Number Validator
Validate 9-digit US ABA routing numbers with 3-7-1 Mod-10 breakdown.