Learning Objectives
By the end of this section, you will be able to:
- Derive the formula for the natural frequencies of a vibrating string directly from the 1D wave equation
- Predict how a guitarist's fingers, a violinist's bow pressure, and a piano tuner's wrench each change pitch
- Distinguish open–open and closed–open pipe modes and explain why a clarinet plays an octave lower than a flute of the same length
- Compute drum-head frequencies using Bessel-function zeros and prove that drums are inharmonic
- Relate Fourier coefficients of the pluck shape to the timbre (the "color") of an instrument's sound
- Implement all three instrument families in plain Python, then use PyTorch's autograd to solve the inverse problem: what tension produces a given pitch?
The Big Picture: How Music Lives Inside the Wave Equation
"Every musical instrument is a boundary-value problem with a pretty face. The boundary conditions decide the scale; the shape decides the timbre."
For the last five sections we have built a deep theory of waves — the wave equation , d'Alembert's traveling-wave solution, separation of variables for standing waves, Bessel functions for circular geometry, finite-difference schemes for numerical experiments. We have been climbing a tall ladder. This section is the view from the top.
Everything you have heard in your life — every guitar, every flute, every drum, the sound of your own voice — is a particular solution of the wave equation, sculpted by the geometry of the instrument. Pitch comes from the eigenvalues. Loudness comes from the amplitudes. Timbre comes from the relative weights of the modes. Even the difference between an oboe and a clarinet — both wooden tubes — is nothing more than a difference in boundary conditions.
Analogy: an instrument is a calculator with strings
Pressing a fret on a guitar is short-handing in the formula . Tightening a tuning peg is dialing up . Blowing harder into a recorder is increasing the amplitude of the excitation, not the frequency. Every musical action maps to one symbol in a calculus formula. Once you see this, instruments stop being magic and start being experiments you can run.
Why a Whole Section on Instruments?
Three reasons. First, instruments are the most honest teachers of the wave equation: their boundary conditions are physically visible, their eigenmodes audible, their inharmonicities measurable in cents on a tuner app. Second, the same three problem types — string, pipe, drum — generalize to every wave application you will meet later: antennas (electromagnetic strings), waveguides (electromagnetic pipes), and quantum confinement (probability-amplitude membranes). Third, every one of these problems can be solved forward (geometry → pitch) and inverse (desired pitch → geometry), and the inverse direction is exactly where modern ML and physics meet.
The Vibrating String: Guitars, Violins, and Pianos
Consider a string of length , tension , and linear mass density (kilograms per metre). Both ends are clamped — the bridge at and the nut (or your finger on the fret) at . The vertical displacement obeys the 1D wave equation
with boundary conditions . We derived this in Section 1 of this chapter from Newton's second law applied to a tiny segment of string. We solved it in Sections 2–3. Now we read off the consequences for music.
The intuition before the algebra
Pluck the string and let it go. The string wants to return to its straight rest shape; tension pulls it down, but its inertia overshoots, and a wave bounces back and forth between the bridge and the nut. Because both ends are pinned, only shapes that vanish at both ends can persist — the same way only certain notes fit between two walls. Those allowed shapes are the eigenfunctions . The time they take to complete one oscillation is the period, and its reciprocal is the frequency you hear.
From the Wave Equation to Pitch in Three Steps
Step 1. Separate the variables
Write and plug into the wave equation. Dividing by :
The left side depends only on , the right only on . They can be equal only if both equal a constant; we write the constant as (negative, so the time solution oscillates rather than blows up).
Step 2. Apply the boundary conditions
The spatial ODE with only has nonzero solutions when
Those are the standing waves. Any other value of forces — silence.
Step 3. Read the frequency off the time equation
With known, the time equation has angular frequency
Converting to hertz, , we get the master formula for stringed instruments:
Read the formula like a sentence
To make a note higher: shorten (press a fret), or raise (tune up), or choose a lighter string (smaller ).
To make it lower: the opposite. A bass guitar uses thick strings exactly because is in the denominator and we can't make the body absurdly long.
Interactive Guitar String Lab
Move the sliders below to feel the formula. Watch the composite vibration (white) and the individual harmonics (colored). The bar chart is the harmonic spectrum — the recipe of the sound.
Things to try
- Pull the length slider down by half. The fundamental doubles. That is one octave higher. Halving the length on any string raises the pitch by exactly an octave — the simplest fact in music.
- Quadruple the tension. doubles → pitch doubles → one octave again. That is what a tuning peg does on every guitar.
- Raise the density 4×. Pitch drops by one octave — why bass strings are wound with extra metal.
Worked Example: Tuning a Guitar's High-E String
Let's do one full calculation by hand. A standard tuned high-E guitar string vibrates at Hz. A typical scale length is m and a typical mass density is kg/m (a 0.010-inch steel string). What tension do we need?
▶ Click to expand the full step-by-step solution
Step 1. Solve the master formula for :
Step 2. Compute :
2 · 0.65 · 329.63 = 428.52 m/s
That number is the wave speed we need on the string.
Step 3. Square and multiply by :
T = 0.00040 · (428.52)² ≈ 0.00040 · 183 629 ≈ 73.45 N
Step 4. Sanity-check. 73 N ≈ 7.5 kgf — about the weight of a backpack. That is exactly the order of magnitude that a tuning peg can supply. The guitar would be unplayable at 1 N (too slack to vibrate) or 1000 N (the bridge would tear off). The formula has correctly told us the engineering tolerance.
Step 5. Predict the other harmonics. Because :
| n | Frequency | Musical name |
|---|---|---|
| 1 | 329.63 Hz | E4 (fundamental) |
| 2 | 659.26 Hz | E5 (one octave up) |
| 3 | 988.88 Hz | B5 (octave + fifth) |
| 4 | 1318.5 Hz | E6 (two octaves up) |
| 5 | 1648.1 Hz | G♯6 (two octaves + major third) |
| 6 | 1977.7 Hz | B6 (two octaves + fifth) |
What we just did: we used pure calculus to predict the entire harmonic content of a real guitar string and inferred the tension a luthier would need to apply. No tuner needed.
The Harmonic Series and Timbre
Why does a violin sound different from a piano playing the same note? Both have a fundamental at, say, 440 Hz. The difference is in the amplitudes of the higher harmonics — the Fourier coefficients in
For a triangular pluck at position , . Two facts follow immediately:
- The decay means high harmonics are quiet — exactly why a pluck sounds rich but not screechy.
- If for some integer , then and the -th harmonic is silent. Pluck a string exactly in the middle () and the 2nd, 4th, 6th harmonics all vanish — the sound becomes hollow and flute-like. This is why guitarists pluck near the bridge for a bright sound and over the fretboard for a mellow one.
Why this matters far beyond music
The fact that where you excite a system controls which modes you see is the same idea behind Fourier image compression, mode-selective laser excitation, and even certain attention patterns in deep networks. Pluck position is a one-dimensional version of an input-feature engineering choice.
Wind Instruments: Sound in a Tube of Air
Replace the transverse displacement of a string with the longitudinal pressure of air inside a tube and you get a wind instrument. Air is compressible; the wave equation now governs pressure fluctuations:
The wave speed is no longer — it's the speed of sound in air, set by temperature, not by the instrument. The geometry only enters through boundary conditions:
- Open end (the bell of a flute, the open tone hole): pressure equals atmospheric pressure outside, so the standing-wave pressure has a node there.
- Closed end (the player's lips on a clarinet mouthpiece, the cap on an organ pipe): air cannot move past the cap, so the velocity is zero and the pressure swings maximally — a pressure antinode.
Open vs. Closed Pipes — Why a Clarinet Sounds Different
Open–open pipe (flute, recorder, open organ pipe)
Pressure node at both ends. The allowed spatial pattern is — identical to the string! So the frequencies are
Every integer multiple of the fundamental is allowed. The full harmonic series is present — flutes sound bright and full.
Closed–open pipe (clarinet, panpipe, stopped organ pipe)
Now we have an antinode at (the mouthpiece) and a node at (the open bell). The allowed pattern is and the frequencies are
Only odd multiples of the fundamental. This has three consequences musicians know in their bones:
- A closed–open pipe of length plays half the fundamental frequency of an open–open pipe of the same length — one octave lower. A clarinet body the same length as a flute body plays an octave deeper.
- The lowest overtone of a clarinet is the third harmonic (twelfth above the fundamental, not an octave). Clarinetists have a technique called "overblowing the twelfth" for exactly this reason.
- Missing even harmonics gives the "hollow, reedy" clarinet timbre. Open–open pipes have a rounder, more vocal sound because every harmonic is present.
Interactive Pipe Acoustics Lab
Switch between flute (open–open) and clarinet (closed–open), drag the length slider, and step through the mode index. Pink curve = pressure standing wave; cyan dots = air particles displaced by the wave.
Things to try
- Set the same length on both pipe kinds with mode = 1. Note the closed-open frequency is exactly half the open-open frequency.
- On a closed–open pipe, step the mode slider from 1 → 5. The harmonic numbers go 1, 3, 5, 7, 9 — the even ones never appear.
- Shrink the length. The pitch goes up — exactly what happens when you close a tone hole on a recorder.
Worked Example: Tuning a Clarinet to Middle C
How long must a clarinet (closed–open pipe) be to sound middle C ( Hz) at room temperature ( m/s)?
▶ Click to expand the full step-by-step solution
Step 1. Solve the closed–open formula for :
Step 2. Plug in numbers:
L = 343 / (4 · 261.63) ≈ 0.328 m
That is about 33 cm. A real B♭ clarinet is closer to 60 cm because it is built to sound a tone lower (D below middle C is its written C) and because end corrections at the bell shift the effective length. The formula is the first-order picture; the missing 5–10% is what makes instrument design an art.
Step 3. Tabulate the audible overtones.
| Mode n | Harmonic # | Frequency | Musical interval |
|---|---|---|---|
| 1 | 1 | 261.6 Hz | C4 (fundamental) |
| 2 | 3 | 784.9 Hz | G5 (twelfth) |
| 3 | 5 | 1308.1 Hz | E6 (two octaves + third) |
| 4 | 7 | 1831.4 Hz | A♯6 (≈ 7:4 natural seventh) |
| 5 | 9 | 2354.7 Hz | D7 (three octaves + tone) |
Step 4. Compare with a flute (open–open) of the same 33 cm length:
f₁_flute = 343 / (2 · 0.328) ≈ 523.3 Hz = C5
Exactly one octave above the clarinet. The boundary condition shifted the entire instrument by an octave. Two pieces of identical wood, one open at both ends and one closed at one end, are heard as fundamentally different instruments. This is the wave equation telling us, with no fudging, what music will sound like before the carpenter has cut a single hole.
Drums: When Calculus Goes Inharmonic
For a circular drumhead of radius , surface tension (N/m), and areal density (kg/m²), the 2D wave equation in polar coordinates gives modes
with frequencies
Here is the -th positive zero of the Bessel function . The crucial thing about these zeros is that they are not equally spaced.
| Mode (m, n) | j_{mn} | Ratio to fundamental |
|---|---|---|
| (0, 1) fundamental | 2.405 | 1.000 |
| (1, 1) | 3.832 | 1.594 |
| (2, 1) | 5.136 | 2.136 |
| (0, 2) | 5.520 | 2.296 |
| (3, 1) | 6.380 | 2.653 |
| (1, 2) | 7.016 | 2.917 |
| (0, 3) | 8.654 | 3.598 |
Compare with a string, whose ratios are 1, 2, 3, 4, 5, … — every integer. The drum's ratios are 1, 1.594, 2.136, 2.296, … — irrational and clustered. That single fact is why drums have indefinite pitch. Your ear can't lock onto a fundamental because the overtones don't reinforce it. Drums are tones with body, not pitches.
The timpani trick
Concert timpani sound "tuned" despite being drums because orchestral designers exploit air-coupling and head loading to suppress the (0, 1) mode and let (1, 1), (2, 1), (3, 1) — which form an approximate harmonic series 2 : 3 : 4 : 5 — dominate. The (0, 1) mode is too low and too fat to set pitch; the (m, 1) family does the job. Pure mathematics on top, careful engineering on the bottom.
Interactive Drum Membrane Lab
Step through the modes and watch the nodal lines appear. Dashed white circles and lines are zero-displacement curves — sprinkle sand on a real drumhead vibrating in this mode and it will settle along exactly these lines.
Worked Example: A Timpani Tuned to A₂
A concert timpani has radius m and an areal density of about kg/m². The orchestra needs it tuned to A₂ ≈ 110 Hz. What surface tension do we need on the (1, 1) mode, which dominates the perceived pitch?
▶ Click to expand the full step-by-step solution
Step 1. Look up .
j₁₁ = 3.8317 (the first zero of the Bessel function J₁)
Step 2. Solve for , then for :
Step 3. Plug in numbers:
c = 2π · 110 · 0.30 / 3.8317 ≈ 54.13 m/s
T = 0.25 · 54.13² ≈ 732.5 N/m
A real timpani head sits at roughly 1500–3000 N/m surface tension, so 732 N/m is plausible for a softer A₂ — the player tightens lugs around the rim to step through pitches, and our formula tells them exactly how the pitch will respond.
Step 4. Once is fixed, predict every other mode for free.
| Mode (m, n) | j_{mn} | Frequency | Ratio to (1,1) |
|---|---|---|---|
| (0, 1) | 2.405 | 69.1 Hz | 0.628 (suppressed in practice) |
| (1, 1) | 3.832 | 110.0 Hz | 1.000 (perceived pitch) |
| (2, 1) | 5.136 | 147.4 Hz | 1.340 ≈ a fourth |
| (0, 2) | 5.520 | 158.5 Hz | 1.440 |
| (3, 1) | 6.380 | 183.1 Hz | 1.665 ≈ a sixth |
| (1, 2) | 7.016 | 201.4 Hz | 1.831 ≈ a minor seventh |
The dominant family at 110, 147, 183 Hz forms ratios — close to , which the ear interprets as a recognizable chord-like pitch. That is why a tuned timpani sings a note while a snare drum just goes thwack.
Python and PyTorch Implementation
Putting everything together: closed-form formulas for the three instrument families, plus a PyTorch routine that inverts the string equation to solve a tuning problem. Plain Python first to build intuition, then PyTorch to show how the same idea scales to learnable systems.
Common Pitfalls
Confusing wave speed c with the speed of sound
On a string, — usually a few hundred m/s, but depends entirely on the string. In a pipe, m/s — the speed of sound in air, almost independent of the pipe. Mixing them up gives nonsensical frequencies. The wave equation only knows about its own medium.
Forgetting the end correction
Real pipes don't end exactly at the geometric opening — a small column of air outside the pipe also vibrates, making the effective length slightly longer. For a tube of radius , add roughly at each open end. The textbook formula is an idealization; instrument makers always tune by ear after calculation.
Assuming drums have harmonics
Tempting, because every other instrument we've studied does. But the zeros of Bessel functions are irrational, so drum overtones are not integer multiples of the fundamental. Designing a sound synthesizer that uses for percussion will produce something that sounds like a bell, not a drum.
Reading sin(nπp)/n² as 'always nonzero'
When the pluck position for any integers and , the corresponding Fourier coefficient is exactly zero and the harmonic is missing. Plucking at L/3 silences every 3rd, 6th, 9th harmonic. Plucking at L/7 silences every 7th. This is a feature, not a bug — guitarists use it deliberately to shape timbre.
Summary
The three classical instrument families — strings, pipes, drums — are the wave equation looked at through three different boundary windows. One PDE, three geometries, an entire orchestra.
Key formulas
| Instrument family | Frequency formula | Allowed harmonics |
|---|---|---|
| String (both ends pinned) | f_n = (n / 2L) √(T/μ) | 1, 2, 3, 4, 5, … (full series) |
| Open–open pipe (flute) | f_n = n c / (2L) | 1, 2, 3, 4, 5, … (full series) |
| Closed–open pipe (clarinet) | f_n = (2n − 1) c / (4L) | 1, 3, 5, 7, 9 (odd only) |
| Circular drum | f_{mn} = c j_{mn} / (2π a) | 1, 1.594, 2.136, 2.296, … (inharmonic) |
Key takeaways
- Pitch is an eigenvalue. The geometry of the instrument decides which eigenvalues are allowed; everything else is consequence.
- Timbre is a Fourier coefficient. The way you excite the instrument (pluck, strike, bow, blow) decides the relative amplitudes of the modes — and that decides what the note sounds like.
- Boundary conditions matter more than material. A flute and a clarinet of the same length play an octave apart purely because one end is closed.
- Drums are mathematical proof that not every wave is harmonic. Bessel-zero ratios are irrational, which is why percussion exists as a separate musical category.
- Inverse problems are the future. PyTorch's autograd lets us pose questions like "what tension produces this pitch?" without a closed-form inverse — the same trick used for shape optimization, antenna design, and acoustic metamaterials.
Coming Next: In Section 27.7 we leave the orchestra for the laboratory and apply the same machinery to electromagnetic waves — Maxwell's equations reduce to a vector wave equation whose boundary problems describe antennas, waveguides, and the colors of light.