The functions {sin(nx)}n≥1 form an orthogonal basis of the Hilbert space L²(0,π) — this is the concrete picture behind "orthonormal basis" in functional analysis. Any target function f can be written as an infinite sum of these basis vectors; each coefficient bₙ is the orthogonal projection of f onto sin(nx), computed as an inner product. Truncating the sum at N terms gives the best possible approximation to f using only N basis vectors — that's exactly what the chart draws.
bₙ = (2/π) ∫₀^π f(x)·sin(nx) dx ("f projected onto basis vector n")
S_N(x) = Σₙ₌₁..N bₙ·sin(nx) (partial-sum reconstruction)
‖f‖² = (π/2) Σ bₙ² (Parseval's identity)
- Target function — the f(x) being decomposed; sharper corners (square, pulse) need more terms and show the Gibbs overshoot near a jump.
- Basis terms N — how many sin(nx) vectors are kept in the truncated sum; more terms means a closer fit and a smaller L² error.
- Auto build-up — animates N sweeping from 1 to 40 and back, so you can watch the reconstruction converge in real time.
- Show harmonics — overlays each individual bₙ·sin(nx) term faintly, so you can see which basis vectors contribute the most.
Real-world relevance: this same projection — decomposing a signal onto an orthonormal basis and keeping only the largest coefficients — is exactly what MP3/JPEG compression and audio equalizers do, and what quantum mechanics does when it expands a wavefunction in a Hamiltonian's eigenbasis.