y(x,t) = 2A·sin(kx)·cos(ωt). The string is
fixed at both ends, so only wavelengths λₙ = 2L/n fit,
giving frequencies fₙ = n·v/2L. Nodes stay at zero;
antinodes swing between the dashed envelope. Toggle the two
underlying left- and right-moving travelling waves, or pluck the string
to superpose several harmonics at once.
This simulation draws a string clamped at both ends with a GLSL fragment shader. Two counter‑propagating travelling waves, A·sin(kx−ωt) and A·sin(kx+ωt), are summed pixel‑by‑pixel; the trigonometric identity that governs their sum collapses them into the standing wave y(x,t)=2A·sin(kx)·cos(ωt) — a fixed spatial envelope that only pulses in time. Because both ends are pinned, the wavenumber must satisfy kL=nπ for whole numbers n, so only the discrete harmonics λₙ=2L/n and frequencies fₙ=n·v/2L can exist. The Harmonic, Amplitude, Tension/speed and Pluck controls let you change n, A, the wave speed v, and blend in higher harmonics (2n, 3n) to approximate a plucked string.
The shader renders three things at once: the moving string itself (bright cyan curve), its fixed maximum-amplitude envelope (dashed outline), and, when toggled on, the two underlying right‑moving (warm) and left‑moving (green) travelling waves whose sum is the standing wave. Yellow dots mark the permanent nodes (zero displacement) and the antinode column is tinted pink where the swing is greatest.
Drag Harmonic n (1–8) to pick the mode; Amplitude sets each travelling wave's peak height; Tension/wave speed v raises or lowers the frequency fₙ=n·v/2L shown live in the stats. Flip Show component travelling waves to see the two GLSL waves that add up to the standing pattern, or drag Pluck to mix in the 2nd and 3rd multiples of n with 1/m²‑style weighting, mimicking a plucked guitar or piano string.
Harmonic n has exactly n−1 interior nodes (n+1 counting the two clamped ends) and n antinodes — the readout panel updates this live as "Nodes / Antinodes". Because every fₙ is an exact integer multiple of the fundamental f₁, the harmonics of a clamped string form a musical overtone series, which is why plucked or bowed strings sound like a single pitch rather than noise.
The shader evaluates a right‑moving wave A·sin(kx−ωt) and a left‑moving wave A·sin(kx+ωt) and adds them. Using the sum‑to‑product identity, sin(kx−ωt)+sin(kx+ωt)=2·sin(kx)·cos(ωt): the x‑ and t‑dependence separate, so every point on the string still oscillates in time (cos ωt) but the spatial shape sin(kx) never travels — that is exactly what "standing" means.
Both ends of the string are fixed, so the displacement must be zero at x=0 and x=L for all time. Only sine shapes with kL=nπ (n=1,2,3…) satisfy that boundary condition, giving the discrete wavelengths λₙ=2L/n and frequencies fₙ=n·v/2L that this simulator's Harmonic slider steps through. Any in‑between wavelength cannot form a stable standing pattern on a fixed‑fixed string.
A node is a point where sin(nπx/L)=0, so the string's displacement is zero at every instant — the shader marks these with a yellow dot. An antinode is where |sin(nπx/L)|=1, the point of maximum possible swing, shown as the pink‑tinted column reaching the dashed envelope. Harmonic n always has n−1 nodes strictly between the two fixed ends and n antinodes.
The frequency fₙ=n·v/2L depends on the wave speed v (set by the Tension/wave speed slider), while the node/antinode positions depend only on n and the fixed string length L=0.65 m. So sliding the speed control makes the same-looking standing pattern oscillate faster or slower — raising or lowering the pitch fₙ — without moving a single node.
Plucking a real string excites the fundamental plus a cascade of higher harmonics with decreasing amplitude. The shader approximates this by blending in the standing‑wave shapes for 2n and 3n at 45% and 25% of the base amplitude respectively, mixed in by the Pluck slider's value. This produces the sharper, triangular‑ish string shape and richer overlaid motion characteristic of a plucked guitar or piano string rather than a pure sine tone.