Math

Fourier Series

Add harmonics one by one and watch a square wave emerge. Toggle individual frequencies to see how each component contributes.

8 minLevel 3/3The interactive stage stays ad-free.
TargetSquareHarmonics9Largest coefficient1.273RingingGibbs
Spectrum · 1–29k1: 1.27 · k3: 0.42 · k5: 0.25 · k7: 0.18 · k9: 0.14

The dashed gold line is the target waveform. The cyan line adds the selected sine harmonics. Switch the target to compare how square, sawtooth, and triangle waves need different coefficients. The spectrum shows which harmonics matter; the overshoot near jumps is the Gibbs phenomenon.

What you are seeing

1

A periodic signal can be decomposed into sine and cosine waves at integer multiples of a base frequency.

2

The square wave uses only odd harmonics. Adding more terms sharpens the edges.

3

The overshoot near a jump is the Gibbs phenomenon; it does not disappear as you add more terms.

Why it matters

Fourier analysis is everywhere: audio compression, image processing, signal filtering, quantum mechanics, and neural network theory.

Complexity & details

A direct DFT is O(n²); the FFT is O(n log n). The animation uses a truncated series with N harmonics.

Frequently asked questions

Why does the square wave ring?+

Truncating a Fourier series removes high frequencies, causing overshoot near discontinuities. This is the Gibbs phenomenon.

What is a harmonic?+

A harmonic is a frequency that is an integer multiple of the fundamental frequency. The third harmonic, for example, is three times the base frequency.