Loading the engineShared by all simulations, so the next one opens instantly.
The physics

The vibrating string is where the physics of waves began. Pythagoras linked consonant intervals to simple ratios of string lengths, Brook Taylor computed the pitch of a string in 1713, and Jean le Rond d’Alembert wrote down the wave equation for it in 1747. Daniel Bernoulli then argued that every motion of the string is a sum of sine-shaped normal modes, a claim that led to a long dispute with Euler and d’Alembert and was settled only by Fourier’s series in the early nineteenth century. The modes are the harmonics of a guitar or a harp: the fundamental sets the pitch, and the mix of higher harmonics, which depends on where the string is plucked, sets the timbre.

What you see

The upper panel shows the displacement u(x,t) of a string of 800 nodes with both ends fixed, drawn to a fixed scale so a damped string visibly shrinks. Upward displacement is warm, downward blue. A plucked string is a polygon: its two kinks run along the string at speed c, reflect at the ends and rebuild the starting triangle once per period.

The lower panel shows the first 16 modes as bars of height |an(t)|, the projection of the current shape onto sin⁡(nπx/L). Each bar pulses at its own frequency fn, since an(t)=Ancos⁡(2πfnt), and its highest point is the mode amplitude An.

Governing equation

∂2u∂t2=c2∂2u∂x2−2γ∂u∂t,u(0,t)=u(L,t)=0.

Its solutions are sums of normal modes un=Ane−γtsin⁡(nπx/L)cos⁡(ωnt) with ωn=(nπc/L)2−γ2, so the frequencies form the harmonic series fn=nc/2L as long as the damping is weak. A triangular pluck of height h at a fraction p of the length has

An=2hsin⁡(nπp)n2π2p(1−p),

and every harmonic with a node at the plucking point is missing.

The simulation uses the leapfrog finite-difference scheme with grid spacing and time step 1, so c is the Courant number in cells per step and L=799 cells. At exactly 1 cell per step the scheme reproduces d’Alembert’s solution without error; below it, short waves travel slightly too slowly, and above it the scheme is unstable. With damping the limit lies a little lower, at c2≤1−γ, so the slider stops at 0.99. Without damping the discrete energy stays constant to better than 10−6 over 20,000 steps. The page runs 16 steps per frame, 960 steps per second at 60 frames per second.

Presets

Plucked at one fifth: a triangle of height 1 with its peak 160 cells from the left end, at c=0.99. The measured mode amplitudes relative to the fundamental are 0.404, 0.180 and 0.062 for n=2,3,4, as sin⁡(nπ/5)/(n2sin⁡(π/5)) predicts, and modes 5, 10 and 15 are absent. The fundamental period is 2L/c=1614 steps, 1.7 s.

Plucked in the middle: only odd harmonics appear, with A3/A1=1/9 and A5/A1=1/25 as measured.

Damped string: the one-fifth pluck with γ=0.0002 per step. Every mode decays as e−γt, by a factor e every 5000 steps (5.2 s, about three periods), and the measured fundamental after three periods matches e−γt to within 3 %. All modes lose amplitude at the same rate per unit time, so the shape keeps its form while it shrinks. Real strings lose their high harmonics faster, because air drag and internal friction grow with frequency; this model leaves that out.

Loose string: the one-fifth pluck at half the wave speed, c=0.5. Every frequency halves, an octave lower, and the measured period is 3196 steps (3.3 s), as 2L/c predicts.

Parameters

Wave speed (cells per step): c, from 0.05 to 0.99. It acts at once and changes the pitch of all modes in proportion.

Damping (per step): γ, from 0 to 0.001. It acts at once.

Mode spectrum: shows or hides the bar chart of the mode amplitudes. It changes only the drawing.