What is being decomposed?
Your drawing defines 512 equally spaced samples of one period T. The FFT computes their discrete Fourier transform (DFT). Each frequency bin supplies an amplitude and phase for a sinusoid.
The DC term is the signal’s mean. It stays in every approximation. The slider adds frequency terms from low to high, including any bins whose amplitude is zero.
Why does the sum improve?
The sampled sinusoids are orthogonal. Adding their measured contributions preserves more signal energy and reduces the RMS error.
At 256 terms, the sum reproduces every stored sample to numerical precision. The curves between samples show the periodic sinusoidal interpolation.
Amplitude and phase work together
Aₖ sets a cosine’s height. φₖ sets its horizontal shift. Both are required to recover the signal. Colored bars and phase dots appear as their terms enter the sum. Enable “Show expected FFT” to also see the remaining components in gray.
Why do sharp edges ring?
A finite sum of smooth sinusoids rounds sharp corners and can overshoot near jumps (the Gibbs phenomenon). More terms narrow the ringing region; error at each individual time need not decrease.
The drawing repeats. A mismatch between its ends creates a jump at the boundary. The highest frequency is 256 cycles per period, the Nyquist limit for these 512 samples. Its amplitude uses a single bin; lower positive frequencies combine conjugate pairs.
For a nonperiodic continuous signal, the Fourier transform uses a continuous frequency spectrum. This simulator demonstrates its sampled, finite-record counterpart.
DFT and FFT conventions · NumPy documentation