This simulator builds a real Fourier series term by term and shows, in 3D, how simple sine and cosine harmonics sum into a complex periodic signal. Choose a target waveform, control how many harmonics are included and how they're summed, then watch the partial sum converge — or fail to converge cleanly — against the target.
• A real-time 3D scene with a harmonic-stack view and a rotating-vectors (phasor) view, plus reset camera, auto orbit and expand controls; horizontal is phase −π…π, vertical is signal amplitude, and depth separates individual harmonic indices. • Eight target waveforms (square, sawtooth, triangle, centered pulse, full-wave rectified sine, single sine, drawn periodic signal, editable harmonic recipe) and three summation methods (ordinary partial sum, Fejér arithmetic mean, Lanczos sigma factors). • Play/pause phase animation, a 15° single-step advance, a reset-lab action, an export-series action, and a visual-speed slider from 0.05 to 0.5 cycles per second. • A target-versus-partial-sum chart plotting the target, the mint approximation, the rose error and amber-dotted equally spaced samples. • A Coefficients & drawing tab with a 64-knot drawing canvas (drag to sketch a periodic target, use/clear/sine-preset buttons), a harmonic-recipe editor (harmonic index n, cosine aₙ, sine bₙ, DC mean, copy-current-coefficients and apply-recipe-edit buttons), an amplitude/phase spectrum chart, and a full coefficient table (frequency, aₙ, bₙ, amplitude, phase, weight per harmonic). • A Convergence & sampling tab with a compare-N-from-1-to-32 convergence/RMSE study and chart, an energy and total-harmonic-distortion panel, and a samples-per-period selector (8/16/32/64/128) with a sampled-spectrum chart demonstrating aliasing. • An Experiments & tests tab with twelve guided experiments (from a single sine up through Gibbs ringing, Fejér suppression, an aliasing demonstration and a missing-fundamental case) and a run-20-checks numerical verification bench. • A Learn & quiz tab with twelve guided lessons and a twelve-question knowledge-check quiz with scored, randomized answer order.
Every target is built from f(θ) = DC + Σ[aₙcos(nθ) + bₙsin(nθ)], where orthogonality over a full period lets each coefficient be extracted independently: aₙ = (1/π)∫f·cos(nθ)dθ and bₙ = (1/π)∫f·sin(nθ)dθ. Symmetry cuts this work in half — the unshifted square, sawtooth and triangle presets are odd functions and use sine terms only, while the centered pulse and full-wave rectified sine are even and use cosine terms only. The 'build a square wave' experiment walks N from 1 to 9 to 31 and shows the odd harmonics progressively sharpening the transition edges while the even sine coefficients stay exactly zero throughout.
Coefficient decay rate reveals smoothness: square and sawtooth coefficients fall off as 1/n because of their jump discontinuities, while the continuous (but corner-containing) triangle wave's coefficients fall off faster, as 1/n² — directly comparable in the 'compare smoothness' experiment at N=9. Every harmonic pair can also be written as a single amplitude-phase term, A·cos(nθ+φ) with A=√(aₙ²+bₙ²) and φ=atan2(−bₙ,aₙ); phase becomes undefined whenever that harmonic's amplitude is exactly zero.
At a jump discontinuity, ordinary partial sums never fully lose their overshoot — the 'inspect Gibbs ringing' experiment loads a square wave at N=31 and shows the peak still exceeding roughly 1.179 on a jump of height 2, matching the theoretical large-N Gibbs limit of about 8.95% of the jump, even as the integrated RMS error keeps shrinking and the ringing region narrows. Fejér averaging (weight = 1 − n/(N+1)) and Lanczos sigma weighting both trade away that sharp edge for reduced ringing rather than adding new information about the target — the 'suppress ringing' experiment compares ordinary and Fejér sums side by side at the same N=31 square wave.
The Sampling tab computes a genuine DFT from samples of the current partial sum, not from the idealized discontinuous target, and Parseval's identity (mean-square = DC² + ½Σ(aₙ²+bₙ²)) is checked numerically against direct time-domain integration. Sampling below twice the highest active frequency causes real ambiguity: the built-in alias experiment loads a recipe containing only the 7th sine harmonic sampled 8 times per period, and the resulting spectrum shows energy folded into bin 1 instead of bin 7 — a direct demonstration of why the sample rate must exceed twice the highest active frequency.
No. Near a jump discontinuity, an ordinary Fourier partial sum keeps a persistent overshoot of roughly 8.95% of the jump size no matter how large N gets — increasing N only narrows the region where that overshoot occurs, it does not shrink the peak itself. Fejér or Lanczos summation weighting is required to actually suppress the ringing, at the cost of a less sharp transition edge.
It comes down to symmetry. An odd function (like the unshifted square, sawtooth or triangle wave) has only sine coefficients, while an even function (like a centered pulse or a full-wave rectified sine) has only cosine coefficients. Shifting a waveform in time typically breaks this symmetry and mixes both coefficient types together, even though it leaves the harmonic amplitude spectrum unchanged.
This is aliasing. If the sample rate does not exceed twice the highest active frequency, different continuous-time harmonics can produce identical sample sequences. The simulator demonstrates this directly: a signal built purely from the 7th sine harmonic, sampled only 8 times per period, shows its energy appearing in bin 1 of the sampled spectrum instead of bin 7.
THD here is defined as the RMS of all harmonics above the first, divided by the RMS of the first (fundamental) harmonic — so it requires a nonzero first harmonic in the denominator. A full-wave rectified sine, under this simulator's chosen period, has its lowest nonzero harmonic at n=2, with no fundamental component at n=1 at all, making the standard THD ratio undefined for that specific waveform.