Skip to content
Tutorials Center
My learning

Topics

Lesson 34 of 39 · PDEs and Applications

The Wave Equation

Understand the 1D wave equation: d'Alembert's traveling waves, standing-wave Fourier solutions for a plucked string, the CFL condition and a leapfrog scheme in Python.

A guitar string, a sound wave in a pipe, a ripple on a pond, a light wave in a vacuum: all obey some version of the wave equation. In one dimension it reads

TEXT
u_tt = c² u_xx

where u(x, t) is the displacement and c is the wave speed (c = sqrt(T/ρ) for a string of tension T and mass density ρ). Unlike the heat equation nothing is smoothed away: waves keep their shape and travel, reflect, and interfere. The equation has two time derivatives, so you must provide both the initial displacement u(x, 0) = f(x) and the initial velocity u_t(x, 0) = g(x).

d'Alembert's traveling waves

Introduce the new variables ξ = x - ct and η = x + ct. Then the equation becomes u_ξη = 0, so the general solution is

TEXT
u(x, t) = F(x - c t) + G(x + c t)

a wave F moving right at speed c plus a wave G moving left. Fitting the initial conditions gives d'Alembert's formula:

TEXT
u(x, t) = ½ [ f(x - ct) + f(x + ct) ] + (1/2c) ∫_{x-ct}^{x+ct} g(s) ds

For a string released from rest (g = 0) the initial bump splits into two copies of half the height that run apart in both directions. The value at (x, t) depends only on the initial data within [x - ct, x + ct], the domain of dependence: information travels at the finite speed c. This is a fundamental contrast with diffusion.

Python A bump splits into two traveling halves

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

At t = 1.5 the two half-bumps are at x = ±3, each of height 0.5, exactly where the printed row shows them.

Standing waves on a string with fixed ends

On [0, L] with u(0, t) = u(L, t) = 0, separation of variables gives X'' + λX = 0 as before (X_n = sin(nπx/L)) and T'' + c² λ_n T = 0, so T_n = A cos(ω_n t) + B sin(ω_n t) with angular frequency ω_n = nπc/L. The general solution is a sum of standing waves, the string's normal modes:

TEXT
u(x, t) = Σ ( A_n cos(nπct/L) + B_n sin(nπct/L) ) sin(nπx/L)

A_n = (2/L) ∫ f sin(nπx/L) dx and B_n = (2/(nπc)) ∫ g sin(nπx/L) dx. The frequencies are whole-number multiples of the fundamental f_1 = c/(2L). That is why a plucked string sounds musical: its overtones are harmonic. Every mode is periodic with period dividing 2L/c, so the entire solution repeats with that period.

Python A plucked string: modes and periodicity

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Rows at t = 0 and t = 2 agree: the string returns to its starting shape. At t = 1 (half a period) it is the mirror image of its initial shape, flipped upside down (compare the printed rows). The energy of mode n is proportional to n² A_n², which is why a sharp pluck, with slowly decaying A_n, sounds bright.

The leapfrog scheme

To compute waves numerically replace both second derivatives by central differences. With s = c Δt / Δx (the Courant number):

TEXT
u_i^{n+1} = 2 u_i^n - u_i^{n-1} + s² (u_{i+1}^n - 2 u_i^n + u_{i-1}^n)

It needs two time levels to start. The first step comes from the Taylor expansion with initial velocity g: u_i^1 = u_i^0 + Δt g_i + (s²/2)(u_{i+1}^0 - 2u_i^0 + u_{i-1}^0). The scheme is second-order accurate in space and time and stable when the CFL condition s <= 1 holds: the numerical domain of dependence must include the physical one. At s = 1 the scheme is exact in 1D for this equation.

Python Leapfrog: CFL stable versus unstable

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

For s <= 1 the amplitude stays close to 1 (the Gaussian travels, reflects off both fixed ends and returns after t = 2 with its shape intact), while for s = 1.05 the amplitude explodes: the CFL condition is violated.

Waves versus diffusion

Finite speed Information travels at c.
Reversible Run it backward and it still works.
Normal modes Frequencies n times the fundamental.
CFL Courant number must stay at most 1.

Waves keep their energy; diffusion destroys information.

1 / 2

Variations

  • Damping: u_tt + γ u_t = c² u_xx makes modes decay as e^{-γt/2}.
  • Driven string: add a forcing term and solve mode by mode; resonance occurs when the driving frequency matches some ω_n.
  • Free end (Neumann): cosines instead of sines; different media change c and cause partial reflection.
  • Two and three dimensions: u_tt = c² (u_xx + u_yy); a drumhead's modes involve Bessel functions.

Common mistakes

  • Providing only the initial displacement and forgetting the initial velocity.
  • Using Δt and Δx that violate c Δt <= Δx in the leapfrog scheme.
  • Forgetting that a fixed end reflects a pulse with sign change, a free end without.
  • Confusing wave speed c with the angular frequency ω_n = nπc/L.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. d'Alembert's solution describes the wave as:

    u = F(x - ct) + G(x + ct).
  2. 2. For a string of length L with fixed ends the mode frequencies are:

    ω_n = nπc/L: integer multiples of the fundamental, giving harmonic overtones.
  3. 3. The CFL condition for the leapfrog scheme is:

    Information in the scheme must travel at least as fast as the real wave.
  4. 4. How many initial conditions does the wave equation need?

    It is second order in time, so displacement and velocity are both required.

Summary

  • The wave equation u_tt = c² u_xx has finite propagation speed c.
  • d'Alembert: u = F(x - ct) + G(x + ct); the initial data fix F and G.
  • On a bounded string the solution is a sum of standing waves with frequencies nπc/L.
  • Leapfrog is second-order accurate and stable when cΔt/Δx <= 1.
  • Reflections, resonance and damping are the main variations.

Next: Laplace's Equation and Potential Problems