› Fourier Series Simulator Back
Signal Processing / Math

Fourier Series Simulator

Synthesize square, triangle, and sawtooth waves using N=1–50 harmonics. Watch the Gibbs overshoot and harmonic spectrum evolve in real-time.

Original calculator and graphs

Waveform, N, amplitude, and playback multiplier are linked to the main screen. The share URL does not save the displayed phase.

Parameters
Waveform type
Highest harmonic index N
Amplitude A
Playback multiplier (dimensionless)
Gibbs: ~9.0% overshoot
Results
Harmonics N
10
Peak Value
—
RMS Error
—
Waveform Synthesis (Real-time Animation)

Each circle is a harmonic. The orange endpoint’s vertical coordinate is the sum. Drag the waveform horizontally or use Left/Right arrows to scrub phase; vertical gestures scroll. The two diagrams use separate automatic scales. Shared URLs restore waveform, N, amplitude and playback multiplier; they do not save the current animated phase.

Harmonic amplitudes & DC
Spectrum

Inputs and interaction

Choose waveform, highest harmonic index N and amplitude A. N is the highest retained frequency index, not the number of nonzero terms. A square wave at N=10 uses five components: 1, 3, 5, 7 and 9. The period is normalized to T=1; the axes do not report measured seconds or Hz.

Add the vertical components of the rotating vectors to obtain the synthesized waveform. DC is the mean and is added once. The orange endpoint and the left edge of the waveform refer to the same phase t/T. Each diagram uses its own automatic scale: compare numerical values, not lengths across the two views. Horizontal drag or Left/Right arrows scrub phase and pause playback; vertical gestures scroll the page. Playback speed is a dimensionless display multiplier.

Controls span N=1–50, A=0.5–2.0 and playback multiplier=0.1–3.0. Example buttons set A=1, multiplier=1 and phase=0, then pause.

Worked checks

For a square wave with A=1 and N=1, f₁(t)=4sin(2πt)/π. At t/T=0.25 the sum is 4/π≈1.27324; the full-period RMS error is √(1−8/π²)≈0.43524. N=2 gives the same result because the second harmonic is zero.

For a half-wave rectified sine with A=2 and N=1, DC=2/π≈0.63662 and the first sine amplitude is 1. At t/T=0.25 the sum is 1+2/π≈1.63662 and RMS error is √(0.5−4/π²)≈0.30776. Compare the vector endpoint, numerical sum, DC bar and first-harmonic bar under the same settings.

Each button sets A=1, speed=1 and phase=0, then pauses the example.

Model and limits

Square and sawtooth discontinuities produce Gibbs oscillations. The displayed finite-N overshoot is measured from the computed peak and divided by the jump 2A. About 8.949% is the asymptotic limit as N grows, not a percentage of A. Continuous triangle waves still have finite-N error; a corner differs from a jump in value.

The formulas below define the coefficients and partial sum. Rotating vectors illustrate a real Fourier series; they are not physical particle trajectories or a DFT of an arbitrary drawing. The spectrum shows magnitudes √(aₙ²+bₙ²), without separate sign or phase; DC is |a₀/2|. The peak is estimated on 4096 samples, while RMS uses Parseval. Both diagrams autoscale with amplitude, so also check numerical results.

Theory & Key Formulas

$$\begin{aligned}f_N(t)&=\frac{a_0}{2}+\sum_{n=1}^{N}h_n(t)\\h_n(t)&=a_n\cos(n\omega_0t)\\&\quad+b_n\sin(n\omega_0t)\\\omega_0&=\frac{2\pi}{T}\end{aligned}$$

Square: $b_n = \tfrac{4A}{n\pi}$ (odd $n$ only)
Triangle: $b_n = \tfrac{8A}{n^2\pi^2}\sin\!\tfrac{n\pi}{2}$
Sawtooth: $b_n = -\tfrac{2A}{n\pi}(-1)^n$
Half-wave sine: $a_0/2=A/\pi$, $b_1=A/2$, $a_n=-2A/[\pi(n^2-1)]$ (even $n\ge2$). All other coefficients are zero.

The period is normalized to 1. N is the highest retained harmonic, not the number of nonzero terms. The rising sawtooth starts at 0 and jumps from +A to −A halfway through the period; jump points use the average of the two limits. RMS error is the full-period integral evaluated by Parseval’s relation. Peak amplitude is a 4096-point numerical estimate. Finite-N overshoot is measured relative to the jump size 2A. The spectrum shows √(aₙ²+bₙ²), with DC = a₀/2 separately.

This sawtooth jumps from +A to −A at half a period, with the midpoint value at a jump. The tool does not perform measured FFT, denoising, circuit bandwidth or hardware compliance analysis. Use it to understand periodic components in vibration, acoustics or heat models; check actual units and measurement conditions separately.

N is the highest retained harmonic. Increasing it reduces full-period RMS error. Near square and sawtooth jumps, overshoot approaches about 9% of the jump size 2A while its spatial extent shrinks. The triangle wave is continuous and has no Gibbs overshoot caused by a jump in its value.
The horizontal axis is harmonic order n, not Hz. Each bar shows the combined sine/cosine amplitude √(aₙ²+bₙ²). DC separately shows the absolute mean a₀/2. Square-wave harmonics are odd only, with amplitude proportional to 1/n. This is not power or a measured FFT.
Approximating a periodic jump with finitely many smooth components leaves oscillations near it. At the jump itself, the series converges to the mean of its one-sided limits. The approximately 9% limit is relative to jump size 2A, not amplitude A, and is distinct from the measured overshoot at finite N.
This normalized model teaches how truncation changes the waveform, error and spectrum. Example buttons reproduce exact conditions; pause to compare them. It does not analyze measured FFT data or evaluate real circuit filter performance, bandwidth or standards compliance.

References: Mathematics for Quantum Physics: coefficients and half-wave rectification; UC Davis: sawtooth and Parseval exercises. Period and phase conventions have been adapted to this page's normalization.

Rotations and waves: original 3Blue1Brown explanation

🎬 Watch it in motion

Fourier Series | spinning circles that draw any picture #Shorts
Fourier Series | spinning circles that draw any picture #Shorts
Fourier Synthesis | building sharp corners from pure sines #Shorts
Fourier Synthesis | building sharp corners from pure sines #Shorts