TExcelTAD
Home › Differential Equations › The Wave Equation

The Wave Equation

A guitar string, a drum skin, sound in a pipe and electromagnetic waves all obey the wave equation

utt=c2 uxx,u_{tt} = c^2\,u_{xx},

where cc is the wave speed. For a string of length LL fixed at both ends, u(x,t)u(x, t) is the displacement. Unlike the heat equation, it needs two initial conditions (position and velocity), and its solutions do not decay: they oscillate forever.

The problem

utt=c2uxx,u(0,t)=u(L,t)=0,u(x,0)=f(x),ut(x,0)=g(x).u_{tt} = c^2u_{xx}, \quad u(0, t) = u(L, t) = 0, \quad u(x, 0) = f(x), \quad u_t(x, 0) = g(x).

Separation of variables

With u=X(x)T(t)u = X(x)T(t): T′′c2T=X′′X=−λ\frac{T''}{c^2T} = \frac{X''}{X} = -\lambda. The space part is the same eigenvalue problem as for heat, Xn=sin⁡nπxLX_n = \sin\frac{n\pi x}{L}, λn=(nπL)2\lambda_n = \left(\frac{n\pi}{L}\right)^2. The time part is now a second-order equation, T′′+c2λnT=0T'' + c^2\lambda_nT = 0, an oscillator with angular frequency ωn=nπcL\omega_n = \frac{n\pi c}{L}:

u(x,t)=∑n=1∞(Ancos⁡nπctL+Bnsin⁡nπctL)sin⁡nπxL.u(x, t) = \sum_{n=1}^\infty \left(A_n\cos\frac{n\pi ct}{L} + B_n\sin\frac{n\pi ct}{L}\right)\sin\frac{n\pi x}{L}.

At t=0t = 0: f=∑Ansin⁡nπxLf = \sum A_n\sin\frac{n\pi x}{L} and g=∑BnnπcLsin⁡nπxLg = \sum B_n\frac{n\pi c}{L}\sin\frac{n\pi x}{L}, so AnA_n are the sine coefficients of ff, and BnB_n those of gg divided by nπcL\frac{n\pi c}{L}.

Music: harmonics

The mode frequencies fn=nc2Lf_n = \frac{nc}{2L} are integer multiples of the fundamental f1=c2Lf_1 = \frac{c}{2L}. That is why a string has a clear pitch, with overtones at 2, 3, 4, … times the fundamental. Halving LL (pressing a fret at the middle) doubles the frequency: one octave up. With tension TT and linear density μ\mu, c=T/μc = \sqrt{T/\mu}.

python · try it yourself
import numpy as np

L, T, mu = 0.65, 70.0, 0.0004            # guitar-like string: 65 cm, 70 N tension, 0.4 g/m
c = np.sqrt(T / mu)
f1 = c / (2 * L)
print(f"wave speed {c:.1f} m/s, fundamental {f1:.1f} Hz")
print("first five harmonics:", np.round(f1 * np.arange(1, 6), 1))
wave speed 418.3 m/s, fundamental 321.8 Hz
first five harmonics: [ 321.8  643.6  965.4 1287.2 1609. ]

Example: a plucked string

Pull the middle of a string of length 1 to height hh and release from rest: ff is a triangle, g=0g = 0. The sine coefficients of the triangle are An=8hn2π2sin⁡nπ2A_n = \frac{8h}{n^2\pi^2}\sin\frac{n\pi}{2}: only odd harmonics, decaying like 1n2\frac{1}{n^2}. Plucking at a different point changes the mix of harmonics, which is why the same guitar string sounds brighter when picked near the bridge.

python · try it yourself
import numpy as np

h, c, L = 0.01, 1.0, 1.0
n = np.arange(1, 400)
A = 8 * h / (n * np.pi)**2 * np.sin(n * np.pi / 2)
u = lambda x, t: np.sum(A * np.cos(n * np.pi * c * t / L) * np.sin(n * np.pi * x / L))
for t in (0.0, 0.25, 0.5, 1.0, 2.0):
    print(f"t = {t}: u(0.5) = {u(0.5, t): .5f}, u(0.25) = {u(0.25, t): .5f}")
t = 0.0: u(0.5) =  0.00999, u(0.25) =  0.00500
t = 0.25: u(0.5) =  0.00500, u(0.25) =  0.00499
t = 0.5: u(0.5) =  0.00000, u(0.25) =  0.00000
t = 1.0: u(0.5) = -0.00999, u(0.25) = -0.00500
t = 2.0: u(0.5) =  0.00999, u(0.25) =  0.00500

At t=1t = 1 the string is upside down, and at t=2=2Lct = 2 = \frac{2L}{c} it is back where it started: the motion is periodic with period 2Lc\frac{2L}{c}.

Energy is conserved

The energy E=12∫0L(ut2+c2ux2)dxE = \frac{1}{2}\int_0^L\left(u_t^2 + c^2u_x^2\right)dx (kinetic plus stretching) is constant in time: differentiate under the integral and integrate by parts using the equation and the fixed ends. The wave equation, unlike the heat equation, loses nothing; real strings stop because of air resistance and internal friction, which add a damping term utu_t.

In software

  • Physical-modelling synthesis (the Karplus-Strong algorithm and digital waveguides) simulates the wave equation on a string to make realistic plucked sounds.
  • Seismic imaging, ultrasound and radar solve the wave equation numerically on huge grids; The Wave Equation and the CFL Condition covers the time-step limit those codes obey.

Exercises

Exercise 1: One mode

Solve utt=4uxxu_{tt} = 4u_{xx} on (0,π)(0, \pi), fixed ends, u(x,0)=sin⁡2xu(x, 0) = \sin 2x, ut(x,0)=0u_t(x, 0) = 0.

Answer

u=cos⁡4t sin⁡2xu = \cos 4t\,\sin 2x.

Solution

c=2c = 2, n=2n = 2, L=πL = \pi: ω=nπcL=4\omega = \frac{n\pi c}{L} = 4.

Exercise 2: Initial velocity

Same equation, u(x,0)=0u(x, 0) = 0, ut(x,0)=6sin⁡3xu_t(x, 0) = 6\sin 3x.

Answer

u=sin⁡6t sin⁡3xu = \sin 6t\,\sin 3x.

Solution

ω3=6\omega_3 = 6 and B3ω3=6B_3\omega_3 = 6, so B3=1B_3 = 1.

Exercise 3: Octaves and fifths (code)

A string's fundamental is 110 Hz. Which length fraction gives 165 Hz, and which harmonic of the open string equals the second harmonic of the shortened string?

Answer

23\frac{2}{3} of the length; the 3rd harmonic (330 Hz).

Solution

f1∝1Lf_1 \propto \frac{1}{L}, so 110165=23\frac{110}{165} = \frac{2}{3}. The shortened string's second harmonic is 330=3⋅110330 = 3 \cdot 110: the musical fifth shares overtones with the root.

python · try it yourself
from fractions import Fraction
f1 = 110
print(Fraction(f1, 165), [f1 * k for k in range(1, 5)], [165 * k for k in range(1, 3)])
2/3 [110, 220, 330, 440] [165, 330]

Test yourself

How many initial conditions does the wave equation need?

  1. One: u(x,0)u(x, 0)
  2. Two: u(x,0)u(x, 0) and ut(x,0)u_t(x, 0)
  3. None
  4. Three

The mode frequencies of a fixed string are…

  1. nc2L\frac{nc}{2L}, integer multiples of the fundamental
  2. c2Ln2\frac{c}{2L}n^2
  3. random
  4. cLcL

Compared with the heat equation, solutions of the wave equation…

  1. decay faster
  2. oscillate without decaying
  3. are always zero
  4. blow up