Fourier Series Builder: Add Harmonics, Watch the Wave
Pick a waveform and the number of harmonics. The partial sum is drawn over the ideal wave, with each coefficient and how much of the signal's power the harmonics carry.
Harmonics 1 to 5 carry 93.31% of the signal's power. The partial sum peaks at 1.188 (the Gibbs overshoot stays near 9% of the jump however many harmonics you add).
| n | a_n | b_n | Amplitude |
|---|---|---|---|
| 1 | 0.0000 | 1.2732 | 1.2732 |
| 2 | 0.0000 | 0.0000 | 0.0000 |
| 3 | 0.0000 | 0.4244 | 0.4244 |
| 4 | 0.0000 | 0.0000 | 0.0000 |
| 5 | 0.0000 | 0.2546 | 0.2546 |
The formulas
a0 is the average; an and bn are found by integrating x(t) against each cosine and sine over one period.
Parseval's theorem: the average power is the sum of the powers in the DC term and each harmonic.
Worked example: building a square wave
- A ±1 square wave has bn = 4/(nπ) for odd n and nothing else: b1 = 1.2732, b3 = 0.4244, b5 = 0.2546.
- Its average power is 1. The fundamental alone carries (4/π)²/2 = 81.1% of it; harmonics 1, 3 and 5 together carry 93.3%.
- However many harmonics you add, the partial sum overshoots the jump to about 1.179, 9% of the jump height on each side: the Gibbs phenomenon.
- A triangle wave is continuous, so its coefficients fall as 1/n² and the fundamental alone carries 98.5% of its power, with no overshoot.
- Coefficients fall as 1/n for a waveform with jumps and as 1/n² for one with only corners, which is why the triangle converges so much faster.
- Waveforms with half-wave symmetry, such as the square and triangle, have only odd harmonics.