Lesson 8 of 15

Wave Equation

Wave Equation

The 1D wave equation governs the propagation of waves (sound, light, strings):

2ut2=c22ux2\frac{\partial^2 u}{\partial t^2} = c^2\, \frac{\partial^2 u}{\partial x^2}

where cc is the wave speed.

d'Alembert's Solution

For an infinite domain with initial displacement f(x)f(x) and initial velocity g(x)g(x), the general solution is:

u(x,t)=f(xct)+f(x+ct)2+12cxctx+ctg(s)dsu(x, t) = \frac{f(x - ct) + f(x + ct)}{2} + \frac{1}{2c} \int_{x-ct}^{x+ct} g(s)\, ds

This has a beautiful physical interpretation: the wave splits into a right-traveling copy and a left-traveling copy of the initial displacement, each at speed cc.

For zero initial velocity (g=0g = 0):

u(x,t)=f(xct)+f(x+ct)2u(x, t) = \frac{f(x - ct) + f(x + ct)}{2}

Standing Waves

On a finite domain [0,L][0, L] with Dirichlet boundary conditions, the normal modes are standing waves:

un(x,t)=sin ⁣(nπxL)cos ⁣(nπctL)u_n(x, t) = \sin\!\left(\frac{n\pi x}{L}\right) \cos\!\left(\frac{n\pi c t}{L}\right)

The angular frequencies are ωn=nπc/L\omega_n = n\pi c / L, giving the harmonic series of the string.

Dispersion Relation

For a non-dispersive medium, the dispersion relation is:

ω=ck\omega = c\, k

The phase velocity (speed of a wave crest) equals the group velocity (speed of energy transport):

vphase=ωk=cv_{\text{phase}} = \frac{\omega}{k} = c

Your Task

Implement dalembert(x, t, c, f_func, g_func=None) using d'Alembert's formula. If g_func is provided, integrate numerically using 100 midpoint steps; if g_func=None, use zero initial velocity. Implement standing_wave(x, t, c, L, n=1) for the nn-th normal mode. Implement wave_phase_velocity(omega, k) returning ω/k\omega/k.

Python runtime loading...
Loading...
Click "Run" to execute your code.