# [GIF] The Band Plays On (Chladni figures for a square drum)

GROUPS:
 Clayton Shonkwiler 7 Votes The Band Plays OnFollowing up on Drumbeat, which shows one of the vibration modes of a circular drum, here are the nodal lines of a family of vibration nodes of a square drum. Cribbing from the MathWorld article, the vertical displacement of the $(p,q)$ vibration mode of a $1 \times 1$ square drum is $u_{pq}(x,y) = (A \cos \omega_{pq} t + B \sin \omega_{pq} t) \sin(p \pi x) \sin (q \pi y)$,where $\omega_{pq} = \pi \sqrt{p^2 + q^2}$. This is easy enough to turn into a function: ω[p_, q_] := π Sqrt[p^2 + q^2]; ψ[x_, y_, t_, p_, q_, A_, B_] := (A Cos[ω[p, q] t] + B Sin[ω[p, q] t]) Sin[p π x] Sin[q π y]; In fact, the same holds for arbitrary rectangles, so long as the product of sines becomes $\sin(p\pi x/L_x)\sin(p \pi y/L_y)$ where $L_x$ and $L_y$ are the lengths of the sides of the rectangle. The nice thing about squares is that you get an extra symmetry: the $(p,q)$ mode and the $(q,p)$ mode have the same frequency, so any linear combination will also form a standing wave.In the animation, I'm taking the combination $u = u_{7,9} + c u_{9,7}$ and (by letting $c=\tan \theta$) varying $c$ from $-\infty$ to $\infty$. The curves in the animation are the so-called Chladni figures, or nodal lines of the vibration, meaning the solutions of $u=0$.Anyway, here's the code: With[{p = 7, q = 9, A = 1, B = 0, cols = RGBColor /@ {"#F66095", "#2BCDC1", "#393E46"}}, Manipulate[ ContourPlot[ ψ[x, y, 0., p, q, A, B] + Tan[(π/2 - .0001) (Haversine[Mod[2 θ, π]] + Floor[2 θ/π] - 1)] ψ[x, y, 0., q, p, A, B] == 0, {x, .01, .99}, {y, .01, .99}, Axes -> False, Frame -> False, ContourStyle -> Directive[CapForm["Round"], Thickness[.01], Blend[cols[[;; -2]], Haversine[2 θ]]], PlotRangePadding -> -0.01, ImageSize -> 540, Background -> cols[[-1]] ], {θ, 0., π}] ]