Flow Lab

Syllabus / Module 16: Capstone Builds

Lesson 16.4

Capstone: Drum & Membrane Mode Synthesizer

Simulate 2D wave equations on drums of arbitrary shape, compute modes via eigenvalue solvers, and synthesize the sound.

Written byClaude Sonnet

🌊
Why this matters for simulation: Acoustic eigenmodes are exactly what wind-tunnel designers must avoid.

By the end of this lesson you can…

  • Assemble the 2D wave equation on a masked grid with the leapfrog scheme, and measure its step limit by running it, checking it against $2/\sqrt{\lambda_{\max}}$ and the bipartite fact $\lambda_{\max} = 8 - \lambda_{\min}$.
  • Write the masked Dirichlet Laplacian as a symmetric positive definite matrix and say why its eigenvectors are the vibration modes and why the frequency of mode $k$ is $c\sqrt{\lambda_k}$.
  • Compute the lowest modes of an arbitrary shape with a block shift-invert subspace iteration, and explain why a block of vectors is needed when eigenvalues repeat.
  • Compare a staircase circle with the Bessel zeros $j_{mn}$, state which quantities converge at second order and which only at first order, and say why the frequency ratios converge faster than the absolute pitch.
  • Synthesise a drum sound as a sum of decaying sinusoids with amplitudes $\varphi_k(\text{strike})\,\varphi_k(\text{pickup})/r_k$, and predict from the nodal lines which modes a given strike point does not excite.
  • Draw a shape, read off its modes and pitches, and state what 'can you hear the shape of a drum' does and does not claim.
  • Name the biggest ways a membrane-tension model differs from a real drum: air loading, stiffness, nonlinearity and the staircase rim.
On this page
·
  1. What we are building
  2. Step 1: the wave equation on a masked grid
  3. The step limit, measured
  4. Step 2: the masked Laplacian is a symmetric matrix, and its eigenvectors are the modes
  5. The sparse eigensolver
  6. Step 3: the circle against Bessel, and the square where everything is exact
  7. The square, where the discrete modes are exact
  8. Step 4: modal synthesis
  9. Which modes a strike excites
  10. The sound, checked
  11. Step 5: draw your own shape
  12. The lab
  13. Honest limits
  14. Concept checks
  15. Problems
  16. What comes next
  17. Key Takeaways

16.3 Capstone: Reaction–Diffusion Pattern Lab ended with a question: on a periodic square the Laplacian has eigenvectors we know in closed form, the Fourier modes, so the implicit step was a transform, a division and an inverse transform. What happens when the domain is not periodic and not a rectangle? Then there is no formula and no FFT, but the eigenproblem is still there, and it is the one that decides how every drum, bell, wine glass and loudspeaker cone sounds. This capstone builds a drum synthesiser around that eigenproblem. We put the wave equation on a grid with a mask that says which cells belong to the drum, show that the grid operator is a symmetric matrix, find its lowest eigenvectors with a sparse solver we write ourselves, check the circle against the Bessel-function theory of 8.6 Orthogonal Polynomials & Special Functions, and turn the eigenpairs into sound by adding up decaying sinusoids. The showpiece is a lab where you draw a shape, see its modes, strike it where you like, and hear it.

▶ Video The wave equation on a masked grid and its step limit, the masked Laplacian as a symmetric matrix, the circle against the Bessel zeros, modal synthesis of a strike, and the modes of a shape you drawcaptions only
Transcript
  1. A drum head is a membrane clamped at the rim. On a grid, a mask says which nodes belong to the drum, and every neighbour outside the mask is held at zero: a staircase rim. Minus the five point Laplacian becomes an operator A. The leapfrog step is two u minus the previous u minus nu squared A u, and a strike is a velocity impulse at one node.
  2. How big a step is safe? Leapfrog is stable when nu squared times the largest eigenvalue is at most four. The grid is bipartite: flip the sign of every other node and A becomes eight I minus A, so the largest eigenvalue is eight minus the smallest. The limit is therefore always a little above one over root two, 0.7071. For a disk of radius 6 the formula gives 0.71359 and running the scheme gives 0.71360.
  3. Number the inside nodes and A is a symmetric positive definite matrix. Its eigenvectors decouple the wave equation into independent oscillators of angular frequency root lambda, so an eigenvector is a mode, and frequency ratios are square roots of eigenvalue ratios. The lab uses block inverse iteration with a Rayleigh Ritz step on a banded Cholesky factor, in a block because symmetric shapes repeat eigenvalues. On a disk of radius 24, lambda one is 0.009832, matching scipy.
  4. On the square there is no staircase, and the discrete modes are products of sines, so the solver can be checked exactly: at N equals 20, lambda one is 0.044677 and agrees with the closed form to about 10 to the minus 15. Against the continuum frequency ratios the error is clean second order: 4.724 percent at N equals 10, 1.311 at 20, 0.345 at 40 and 0.0885 at 80.
  5. The circle is a staircase. Its Bessel ratios are 1, 1.5933, 2.1355, 2.2954 and so on: not integers. Against them the worst ratio error over modes 2 to 12 falls from 10.03 percent at radius 4 to 0.082 percent at radius 64. Better than first order, not a clean second. The absolute eigenvalue is worse: lambda one is low by 11.2 percent, 5.93, 3.48, 1.96 and 1.01, only first order.
  6. Why is the pitch low? The clamped staircase rim sits about a quarter to a third of a cell outside the nominal radius. The effective radius is 4.2457 at R equals 4 and 64.3258 at R equals 64, an excess that does not shrink. A slightly bigger drum is a lower drum, and since the offset is nearly the same for every mode, dividing by lambda one cancels it. The grid also splits the degenerate 2,1 pair, by 4.77 percent at radius 4 and 0.0483 at radius 64.
  7. Here are real eigenvectors of the radius 16 disk as heat maps: cyan negative, amber positive, grey the nodal line. The one one mode has one diameter, the two one has two, and zero two has a nodal ring. Their frequency ratios are the Bessel values 1.5933, 2.1355 and 2.2954, then 2.6531 and 2.9173. A pair is two shapes at any rotation, so the solver may return either.
  8. Now the sound. Strike node p, listen at node r. Each mode contributes its value at the strike times its value at the pickup, over its frequency ratio, times a decaying sine. Frequencies are 110 Hz times root lambda over root lambda one. With a 60 dB time of 1.5 seconds, the 1,1 pair fades in 0.9339 seconds and mode 6 in 0.5654. On a five by five square the sum matches leapfrog to 1.4 times 10 to the minus 13.
  9. Where you strike decides what you hear. The coefficient phi k at the strike vanishes on a nodal line. On a 15 by 15 square struck at the centre, the 1,1 mode has the value 0.015625 there, but the 2,2 cross has a nodal line through the centre and its sum is below 10 to the minus 22: silent. On the disk, a centre strike excites only the rotationally symmetric modes. Strike off centre and the pairs join in.
  10. Nothing cared that the drum was round. Paint a shape and the lab rebuilds the matrix and solves again. The L shaped drum is a convergence test: a two by two square with a one by one corner removed. With s cells per unit length, lambda one is 9.6932 at s equals 8, 9.6735 at 16 and 9.6562 at 32, against a reference 9.6397 that I remember. Paint a notch in the circle and its degenerate pairs split.
  11. Honest limits. A membrane under tension is not a drum: no air loading, no stiffness, no nonlinearity, and the damping law is a choice. The staircase limits the ratios to an order between 1.5 and 1.9, and the pitch to first. The isospectral pair from Kac's question I recall but did not verify, and the sound has never been heard. Next, L-16.5, the orbital transfer planner: an orbit is conservative, nothing damps errors, and the leapfrog you ran here is symplectic. Does that carry over to gravity?

What we are building

A drum head is a membrane under uniform tension, clamped at the rim. Its small vertical displacement u(x,y,t)u(x, y, t) obeys the 2D wave equation of 9.8 Higher Dimensions: Membranes & Drums,

utt=c2∇2uinside the drum,u=0on the rim.u_{tt} = c^2\nabla^2 u \quad\text{inside the drum}, \qquad u = 0 \quad\text{on the rim}.

Everything in this capstone uses units in which c=1c = 1 and the grid spacing is h=1h = 1 cell, so the time step Δt\Delta t is the Courant number ν=c Δt/h\nu = c\,\Delta t/h and a frequency is in radians per time step. The sound only needs one more choice, which is the pitch of the lowest mode, and we pick f1=110f_1 = 110 Hz and rescale everything else by it. Nothing here is calibrated to a real drum, and the closing section says how a real one differs.

Every result below states the grid, the resolution, the time step and the tolerance. Each was produced twice: once by the lab’s own functions run under node, and once by a separate numpy and scipy program (a different assembly of the matrix by Kronecker products, a different eigensolver, scipy’s eigsh with shift-invert, and scipy’s jn_zeros for the Bessel zeros). Where the two programs disagreed by more than rounding I would say so; they did not, and the largest disagreement in any eigenvalue was 2.4×10−152.4 \times 10^{-15} in relative terms. A few claims come from memory and are marked as such. Timings belong to one machine and are not recomputable. The one thing I could not test is the sound: WebAudio does not run in a headless browser, so the audio path is written and checked sample by sample against the formula, but nobody has listened to it while I wrote this.

Five steps build the lab, then the lab itself:

  1. the wave equation on a masked grid, the leapfrog step and its measured step limit;
  2. the masked Laplacian as a matrix and the modes as its eigenvectors;
  3. the circle: staircase against Bessel, and the square, where everything is exact;
  4. modal synthesis: strike, project, damp, add up;
  5. draw your own shape.

Step 1: the wave equation on a masked grid

Let the grid nodes be the points (i,j)(i, j), and let a boolean mask say which of them belong to the drum. A node with a neighbour outside the mask treats that neighbour as having u=0u = 0, which is the clamped rim, drawn as a staircase through the grid. Define the operator

(Au)j,i=4uj,i−uj,i−1−uj,i+1−uj−1,i−uj+1,i,u=0 at every node outside the mask.(Au)_{j,i} = 4u_{j,i} - u_{j,i-1} - u_{j,i+1} - u_{j-1,i} - u_{j+1,i}, \qquad u = 0 \text{ at every node outside the mask}.

That is minus the five-point Laplacian of 10.1 Finite Differences: Discretizing Derivatives with the outside neighbours set to zero, so ∇2u≈−Au/h2\nabla^2 u \approx -Au/h^2. The wave equation becomes the system utt=−(c2/h2) Auu_{tt} = -(c^2/h^2)\,Au, and the leapfrog scheme of 10.5 Wave Equation Numerics & the CFL Condition advances it with

un+1=2un−un−1−ν2Aun.u^{n+1} = 2u^{n} - u^{n-1} - \nu^2 A u^{n}.

This is the central difference in time, second order, and it needs two time levels. A strike is a velocity impulse at one node: u0=0u^0 = 0 and u1=epu^1 = e_p, a one at the struck node pp and zeros elsewhere (this is our convention for the initial data).

The step limit, measured

For the empty square the limit on ν\nu is the familiar 1/21/\sqrt 2. For a general shape it is set by the largest eigenvalue λmax⁡\lambda_{\max} of AA: leapfrog is stable if and only if ν2λmax⁡≤4\nu^2\lambda_{\max} \le 4, so ν≤2/λmax⁡\nu \le 2/\sqrt{\lambda_{\max}}. We do not need to compute λmax⁡\lambda_{\max} from scratch, because the grid is bipartite. Colour the nodes like a checkerboard and let DD be the diagonal matrix of ±1\pm 1 by colour. Every neighbour pair has opposite colours, so DD flips the sign of every off-diagonal entry of AA and leaves the 44 on the diagonal alone, which means DAD=8I−ADAD = 8I - A. The two matrices are similar, so their eigenvalues are related by λ↦8−λ\lambda \mapsto 8 - \lambda, and

λmax⁡=8−λmin⁡,νmax⁡=28−λ1>28=12.\lambda_{\max} = 8 - \lambda_{\min}, \qquad \nu_{\max} = \frac{2}{\sqrt{8 - \lambda_1}} \gt \frac{2}{\sqrt 8} = \frac{1}{\sqrt 2}.

The smallest eigenvalue λ1\lambda_1 is positive for any shape, so 1/2=0.70711/\sqrt2 = 0.7071 is a safe step for every drum, and the true limit sits a little above it. The cell below checks this by running the scheme: it bisects on whether random initial data blows up. That is the same method as the explicit-limit measurement in 16.3 Capstone: Reaction–Diffusion Pattern Lab, and it needs no theory.

🐍 PythonStep 1: the masked operator, the bipartite identity, and the leapfrog step limit measured by bisection
⌘/Ctrl + Enter

The lab’s own measurement, bisecting for 2828 iterations on random initial data over 40004000 steps with the blow-up threshold at 10810^8, and the numpy version of the same experiment, agree with the formula to about 2×10−62 \times 10^{-6} (the measured value always sits slightly above the formula, because just beyond the limit the growth per step is so close to 11 that 40004000 steps are not enough to reach the threshold):

shape and resolutionnodes NNλmax⁡\lambda_{\max}formula 2/λmax⁡2/\sqrt{\lambda_{\max}}measured, nodemeasured, numpy
square, 8×88 \times 864647.758777.758770.7180150.7180150.71801640.71801640.71801670.7180167
square, 16×1616 \times 162562567.931897.931890.7101360.7101360.71013780.71013780.71013780.7101378
square, 32×3232 \times 32102410247.981897.981890.7079090.7079090.70791020.70791020.70791070.7079107
square, 64×6464 \times 64409640967.995337.995330.7073130.7073130.70731530.70731530.70731500.7073150
disk, R=8R = 81931937.915007.915000.7108930.7108930.71089490.71089490.71089590.7108959
disk, R=16R = 167937937.978207.978200.7080720.7080720.70807390.70807390.70807390.7080739

Here λmax⁡\lambda_{\max} is 8−λ18 - \lambda_1, and scipy’s eigsh with which="LA" returns the same largest eigenvalue to 10−1410^{-14}. The square tends to 1/2=0.707111/\sqrt2 = 0.70711 from above as the grid refines, exactly as the formula λ1=8sin⁡2(π/(2(N+1)))\lambda_1 = 8\sin^2(\pi/(2(N+1))) predicts. The cell above, a disk of radius 66 cells (109109 nodes), gave λmin⁡=0.14468\lambda_{\min} = 0.14468, λmax⁡=7.85532\lambda_{\max} = 7.85532, formula 0.713590.71359 and measured 0.713600.71360 (1515 bisections, 15001500 steps, node and numpy alike).

Step 2: the masked Laplacian is a symmetric matrix, and its eigenvectors are the modes

Number the inside nodes 1,…,N1, \dots, N row by row. Then AA is an N×NN \times N matrix with 44 on the diagonal and −1-1 for each pair of neighbouring inside nodes. It is symmetric, and it is positive definite: for any vector xx on the inside nodes, xTAx=∑(xa−xb)2x^{\mathsf T}Ax = \sum (x_a - x_b)^2 over neighbouring pairs, plus a term for every missing neighbour, and the sum is zero only for x=0x = 0 because the rim pins the membrane. By the spectral theorem of 1.6 Change of Basis & Diagonalization, AA has NN real positive eigenvalues λ1≤λ2≤…\lambda_1 \le \lambda_2 \le \dots and orthonormal eigenvectors φ1,φ2,…\varphi_1, \varphi_2, \dots.

Why eigenvectors are modes: the semi-discrete wave equation is utt=−ν02Auu_{tt} = -\nu_0^2 A u with ν0=c/h\nu_0 = c/h. Write u(t)=∑kak(t)φku(t) = \sum_k a_k(t)\varphi_k. The orthonormal basis decouples the system into NN independent oscillators ak′′=−ν02λkaka_k'' = -\nu_0^2\lambda_k a_k, and each of those is the harmonic oscillator of 5.3 Mechanical Vibrations: Spring–Mass–Damper with angular frequency

ωk=ν0λk=chλk.\omega_k = \nu_0\sqrt{\lambda_k} = \frac{c}{h}\sqrt{\lambda_k}.

The shape φk\varphi_k keeps its form while it oscillates, and that is what a mode is. Only the ratios fk/f1=λk/λ1f_k/f_1 = \sqrt{\lambda_k/\lambda_1} matter for the timbre, and the choice f1=110f_1 = 110 Hz fixes the scale. We cannot get all NN eigenpairs cheaply for a fine grid, but we do not want all of them: the highest ones are grid noise, and a drum sound is mostly the first twenty or so. We want the lowest KK eigenpairs.

You will write the matrix first. It is the construction of the cell above, now asked of you, and the tests check it against hand-computable cases.

🧪 Coding exerciseExercise: the masked Laplacian as a dense matrix
⌘/Ctrl + Enter

The sparse eigensolver

A dense np.linalg.eigh of an N×NN \times N matrix costs about N3N^3 operations, which is fine for the cell above and hopeless for the lab: a circle on a 65×6565 \times 65 grid has N=2801N = 2801 nodes and I want the answer while you draw. The matrix is sparse (at most five entries per row), and we want only the smallest eigenvalues. The classical remedy is the inverse iteration of 1.5 Eigenvectors & Eigenvalues: repeatedly applying A−1A^{-1} to a vector multiplies the component along φk\varphi_k by 1/λk1/\lambda_k, so the component with the smallest λ\lambda wins. Doing this with a block of pp vectors at once, re-orthonormalising and diagonalising the small p×pp \times p matrix XTAXX^{\mathsf T}AX after each solve (the Rayleigh-Ritz step), gives the lowest pp eigenpairs together.

Two choices matter. First, each solve is with the same matrix, so factor it once: AA is banded (the bandwidth is the grid width), and a banded Cholesky factorisation costs about Nw2N w^2 with ww the bandwidth, and each later solve costs NwN w. Second, use a block rather than one vector, because shapes with symmetry have repeated eigenvalues. A circle’s modes come in degenerate pairs, one cos⁡mθ\cos m\theta and one sin⁡mθ\sin m\theta for every m≥1m \ge 1, and a single-vector iteration finds one vector of an eigenspace and misses the other. The lab asks for p=K+max⁡(6,K/2)p = K + \max(6, K/2) vectors so that the KK we keep are well separated from the unconverged rest. It iterates until the largest residual ∥Aφ−λφ∥\lVert A\varphi - \lambda\varphi\rVert is below 10−810^{-8} (the tolerance used in the lab; the checks below use 10−1010^{-10} and 10−1110^{-11}), and it solves the circle on a 49×4949 \times 49 grid (N=1597N = 1597) for K=20K = 20 modes in 455455 ms and the 65×6565 \times 65 grid (N=2801N = 2801) in 965965 ms on my machine (timings, not recomputable). This is the same operation as scipy’s eigsh(A, k, sigma=0), which is the next cell.

You will build it yourself in numpy, with a dense np.linalg.solve in place of the banded factorisation.

🧪 Coding exerciseExercise: the lowest k modes by block inverse iteration with Rayleigh-Ritz
⌘/Ctrl + Enter

For a large sparse matrix you would hand the work to a library, and the next cell does that with scipy.sparse.linalg.eigsh using shift-invert about 00, on a disk of radius 2424 (17891789 unknowns, 87578757 stored entries). The cell has a dense fallback in case the sparse solver is not available in your browser Python, and prints which route it took. The values it prints, λ1=0.009832\lambda_1 = 0.009832 and the twelve ratios, match the lab’s own solver (iterated to 10−1110^{-11} on the same mask) to the six digits shown.

🐍 PythonPlayground: the sparse route, scipy eigsh with shift-invert on a disk of radius 24
⌘/Ctrl + Enter

Step 3: the circle against Bessel, and the square where everything is exact

For a circular drum of radius RR the separation of variables of 9.8 Higher Dimensions: Membranes & Drums gives modes Jm(jmnr/R)cos⁡mθJ_m(j_{mn}r/R)\cos m\theta and Jm(jmnr/R)sin⁡mθJ_m(j_{mn}r/R)\sin m\theta, where jmnj_{mn} is the nnth positive zero of the Bessel function JmJ_m (8.6 Orthogonal Polynomials & Special Functions). The frequencies are proportional to jmnj_{mn}, and the lowest ones, relative to the fundamental j01=2.404826j_{01} = 2.404826, are

modejmnj_{mn}ratio jmn/j01j_{mn}/j_{01}multiplicity
(0,1)(0,1)2.4048262.4048261111
(1,1)(1,1)3.8317063.8317061.59331.593322
(2,1)(2,1)5.1356225.1356222.13552.135522
(0,2)(0,2)5.5200785.5200782.29542.295411
(3,1)(3,1)6.3801626.3801622.65312.653122
(1,2)(1,2)7.0155877.0155872.91732.917322
(4,1)(4,1)7.5883427.5883423.15553.155522

(The lab computes the zeros itself, from the Bessel integral Jm(x)=12π∫02πcos⁡(mt−xsin⁡t) dtJ_m(x) = \frac1{2\pi}\int_0^{2\pi}\cos(m t - x\sin t)\,dt evaluated by a 256256-point periodic trapezoid sum, a scan and a bisection, and they match scipy’s jn_zeros to 2×10−162 \times 10^{-16}.) These are not integer ratios: a circular drum is not harmonic, and that is one reason a drum has a pitch much less definite than a string.

On the grid the circle is a staircase: the nodes strictly inside a circle of radius RR cells, centred on a node. We expect error from the jagged rim. The cell below computes the lowest twelve eigenvalues by dense eigh for R=4,8,12R = 4, 8, 12, forms the ratios λk/λ1\sqrt{\lambda_k/\lambda_1}, and reports the error against the Bessel ratios.

🐍 PythonStep 3: staircase circle against the Bessel ratios, three resolutions
⌘/Ctrl + Enter

Here are the numbers of the lab’s solver (disk of radius RR cells, K=12K = 12 modes, tolerance 10−1010^{-10}), confirmed by the numpy and scipy program to 4×10−154 \times 10^{-15}:

RR (cells)nodes NNλ1\lambda_1Reff=j01/λ1R_{\text{eff}} = j_{01}/\sqrt{\lambda_1}λ1R2/j012−1\lambda_1R^2/j_{01}^2 - 1largest ratio error, modes 2-12
4445450.3208210.3208214.24574.2457−11.2%-11.2\%10.03%10.03\%
881931930.0850000.0850008.24858.2485−5.93%-5.93\%2.473%2.473\%
16167937930.0218040.02180416.286016.2860−3.48%-3.48\%0.880%0.880\%
3232320532050.0055370.00553732.318632.3186−1.96%-1.96\%0.304%0.304\%
646412849128490.00139760.001397664.325864.3258−1.01%-1.01\%0.082%0.082\%

Three things are in this table. The first is the absolute pitch. The staircase circle sounds lower than the true circle: λ1R2/j012−1\lambda_1R^2/j_{01}^2 - 1 is negative at every resolution. The reason is that the clamped boundary of the staircase sits about a quarter to a third of a cell outside the nominal radius: the effective radius ReffR_{\text{eff}} that reproduces the computed λ1\lambda_1 exceeds RR by 0.2460.246, 0.2490.249, 0.2860.286, 0.3190.319, 0.3260.326 cells as RR doubles from 44 to 6464. A drum that is a fraction of a cell larger is a lower drum, and since Reff−RR_{\text{eff}} - R does not shrink, the error in λ1\lambda_1 falls only like 1/R1/R, which is first order (the entries go −11.2%-11.2\%, −5.93%-5.93\%, −3.48%-3.48\%, −1.96%-1.96\%, −1.01%-1.01\%: roughly halving per doubling, order about 0.80.8 to 1.01.0).

The second is the ratios. The offset of the rim is nearly the same for every mode, so it cancels when we divide by λ1\lambda_1. The largest ratio error falls from 10.03%10.03\% at R=4R = 4 to 0.082%0.082\% at R=64R = 64, a factor of 122122 over a factor of 1616 in radius, which is an observed order of about 1.51.5 to 1.91.9 for the successive doublings (the exponents per doubling, the base-22 logarithm of each error ratio, are 2.022.02, 1.491.49, 1.531.53 and 1.891.89, noisy because the staircase changes its shape every time RR changes). It is better than first order but not a clean second, and I would not quote one number for it. At R=64R = 64 the twelve ratios are 11, 1.59321.5932 (twice), 2.1352.135, 2.13552.1355, 2.2952.295, 2.65232.6523 (twice), 2.91632.9163 (twice), 3.15293.1529 and 3.15553.1555, against the Bessel values above, and the error on each is under 0.1%0.1\% (the per-mode errors in percent are 00, −0.01-0.01, −0.01-0.01, −0.03-0.03, 0.000.00, −0.02-0.02, −0.03-0.03, −0.03-0.03, −0.03-0.03, −0.03-0.03, −0.08-0.08, 0.000.00).

The third is the splitting of a degenerate pair. The continuum has the (2,1)(2,1) pair exactly degenerate, and the square grid only has a fourfold symmetry, which cannot keep cos⁡2θ\cos 2\theta and sin⁡2θ\sin 2\theta equal. At R=4R = 4 the pair splits by 4.77%4.77\% in λ\lambda, at R=8R = 8 by 2.96%2.96\%, at R=16R = 16 by 0.951%0.951\%, at R=32R = 32 by 0.467%0.467\% and at R=64R = 64 by 0.0483%0.0483\% (as (λ5−λ4)/λ4(\lambda_5 - \lambda_4)/\lambda_4). The (1,1)(1,1) pair, which the four-fold symmetry does keep degenerate, stays equal to about 10−1310^{-13}, which is rounding. A grid synthesiser therefore plays a slow beat between the two members of a split pair that a real drum would not have (the real drum has its own, from imperfections).

The square, where the discrete modes are exact

On the square drum there is no staircase, only the interior grid, and the discrete modes are products of sines: φmn(i,j)∝sin⁡mπiN+1sin⁡nπjN+1\varphi_{mn}(i,j) \propto \sin\frac{m\pi i}{N+1}\sin\frac{n\pi j}{N+1} with eigenvalues 4sin⁡2mπ2(N+1)+4sin⁡2nπ2(N+1)4\sin^2\frac{m\pi}{2(N+1)} + 4\sin^2\frac{n\pi}{2(N+1)}. For N=20N = 20 the solver gives λ1=0.044677\lambda_1 = 0.044677, and the largest relative disagreement with this formula over twelve modes is 8.9×10−168.9 \times 10^{-16} (node) and 2.4×10−152.4 \times 10^{-15} (numpy). Against the continuum ratios (m2+n2)/2\sqrt{(m^2 + n^2)/2} the discretisation error is a clean second-order effect. The largest error over the first twelve modes:

NNlargest ratio error
10104.724%4.724\%
20201.311%1.311\%
40400.345%0.345\%
80800.0885%0.0885\%

Each doubling divides the error by about 3.63.6 to 3.93.9, an observed order of about 1.851.85 to 1.961.96. Compare that with the staircase circle: a straight rim that lies on the grid gives second order, a curved rim cut into steps gives something worse, and the difference is entirely the boundary. Note that the square’s modes have exact repeats, m2+n2\sqrt{m^2 + n^2} for several pairs (m,n)(m,n) at once, such as (1,7)(1,7) and (5,5)(5,5), which both have m2+n2=50m^2 + n^2 = 50; those eigenvalue groups are real degeneracies and the block solver finds all their members.

Step 4: modal synthesis

Strike the drum at node pp and listen at node rr. With the velocity-impulse initial data and the orthonormal eigenbasis, mode kk starts with coefficient ak(0)=0a_k(0) = 0 and velocity φk(p)\varphi_k(p), so it contributes φk(p) sin⁡(ωkt)/ωk\varphi_k(p)\,\sin(\omega_kt)/\omega_k at its own node pattern, and the pickup at node rr hears φk(r)\varphi_k(r) times that. In the units of the lab, with pitches scaled by the fundamental,

s(t)=∑k=1Kφk(p) φk(r)rk  e−σktsin⁡(2πfkt),fk=rkf1,rk=λk/λ1.s(t) = \sum_{k=1}^{K} \frac{\varphi_k(p)\,\varphi_k(r)}{r_k}\; e^{-\sigma_kt}\sin(2\pi f_kt), \qquad f_k = r_kf_1, \quad r_k = \sqrt{\lambda_k/\lambda_1}.

The 1/rk1/r_k factor is the 1/ωk1/\omega_k of a velocity impulse, so higher modes are quieter at the start. The damping σk\sigma_k is where physics goes in. A real membrane loses energy to the air and to internal friction, and higher modes die faster. A simple model that captures this has σk\sigma_k rising with rk2r_k^2:

σk=ln⁡1000T60(1+d (rk2−1)),\sigma_k = \frac{\ln 1000}{T_{60}}\bigl(1 + d\,(r_k^2 - 1)\bigr),

where T60T_{60} is the time for the fundamental to fall by 6060 dB, which is a factor 10001000 in amplitude, and d≥0d \ge 0 tunes how much faster the high modes die. In the lab with T60=1.5T_{60} = 1.5 s and d=0.4d = 0.4, for the disk of radius 88 the fundamental decays in 1.51.5 s, the (1,1)(1,1) pair in 0.93390.9339 s, mode 44 in 0.63520.6352 s, mode 55 in 0.62140.6214 s and mode 66 in 0.56540.5654 s (these follow the formula, which numpy reproduces). This model is a choice and not a derivation, a common one in modal-synthesis work (from memory). Frequency-dependent damping with a quadratic law is easy to defend for viscous damping of a stiff plate and harder to defend for air loading of a membrane.

Which modes a strike excites

The coefficient φk(p)\varphi_k(p) vanishes if pp lies on a nodal line of mode kk, a curve where the mode shape is zero. A mode with a nodal line through the strike point is not excited at all by a strike there. On the square with N=15N = 15 and the strike at the centre node (7,7)(7, 7), the sum of φ2\varphi^2 over an eigenspace at the centre is 0.0156250.015625 (=(2/16)2= (2/16)^2) for the (1,1)(1,1) and (3,3)(3,3) modes, 0.031250.03125 for the (1,3)/(3,1)(1,3)/(3,1) pair (the sum over the pair, which is 2×(2/16)22 \times (2/16)^2 and is basis-independent), and below 10−2210^{-22} for the rest in the solver (exactly zero in the closed form). Every mode with an even mm or nn has the centre on a nodal line and is silent. The same drum struck at the centre and off the centre sounds different for exactly this reason, and a drummer who strikes near the rim excites almost everything.

We report each eigenspace, a cluster of degenerate modes, as one line, and sum φk(p)φk(r)\varphi_k(p)\varphi_k(r) over the cluster before dividing by rr. The individual vectors of a degenerate pair are an arbitrary rotation of each other, so the amplitude of a single member is meaningless but the cluster sum is not.

The sound, checked

Two checks make the synthesis trustworthy. The first is exactness: on a tiny 5×55 \times 5 square (2525 nodes) with all 2525 modes kept, ν=0.6\nu = 0.6, 200200 steps, the strike at node 33 and the pickup at node 1212, the leapfrog solution and the exact discrete modal formula

un(r)=∑kφk(p)φk(r) sin⁡(nθk)sin⁡θk,2sin⁡(θk/2)=νλk,u^n(r) = \sum_{k}\varphi_k(p)\varphi_k(r)\,\frac{\sin(n\theta_k)}{\sin\theta_k}, \qquad 2\sin(\theta_k/2) = \nu\sqrt{\lambda_k},

agree to 1.4×10−131.4 \times 10^{-13} (node) and 1.9×10−141.9 \times 10^{-14} (numpy). So the leapfrog wave you see in the lab view is exactly a sum of modes, with a slightly shifted frequency. The second check is the spectrum: leapfrog’s frequency per step is not νλk\nu\sqrt{\lambda_k} but θk\theta_k above, and for the disk of radius 88 (193193 nodes), ν=0.5\nu = 0.5, 2152^{15} steps, the measured spectral peaks (Hann window, four times zero padding, parabolic refinement) match 2sin⁡−1(νλ/2)2\sin^{-1}(\nu\sqrt{\lambda}/2) to about 10−710^{-7} relative for the resolved modes. The time-stepped sound therefore plays the modes about 0.09%0.09\% (mode 11) to 0.86%0.86\% (mode 99) higher in pitch than the semi-discrete frequencies. The modal synthesiser skips the time stepping altogether and uses the semi-discrete fk=rkf1f_k = r_kf_1, so the audio and the wave view differ by that dispersion error.

The third check is the sound itself, before WebAudio: synthesise 66 s at 4410044100 Hz for the disk of radius 88 with f1=110f_1 = 110 Hz, T60=3T_{60} = 3 s, d=0.1d = 0.1, and read the peaks of the spectrum. They sit within 0.0030.003 Hz of fkf_k for the resolved modes: the fundamental at 110.0110.0 Hz, the (1,1)(1,1) pair at 174.468174.468 Hz, mode 44 at 230.842230.842 Hz (measured 230.845230.845). The recomputation in numpy gave the same.

Now you build it. The exercise is the synthesis formula, tested against an explicit sum and against the nodal-line rule on a 5×55 \times 5 square struck at its centre.

🧪 Coding exerciseExercise: modal_sound, the sum of decaying sinusoids
⌘/Ctrl + Enter

Step 5: draw your own shape

Nothing in the previous steps cared that the drum was round or square, only that the mask is a mask. Drawing a shape is editing the mask, rebuilding the matrix and re-solving, and the lab does that in about half a second for a mid-size grid. The famous question about this is Mark Kac’s 1966 paper, “Can one hear the shape of a drum?” (from memory: it appeared in the American Mathematical Monthly). Hearing is the spectrum, the set of eigenvalues, and the question is whether the spectrum fixes the shape. Part of the answer is yes: the spectrum determines the area, through Weyl’s law, by which the number of eigenvalues below λ\lambda grows like area×λ/(4π)\text{area} \times \lambda/(4\pi) (from memory), and it determines the perimeter (from memory). The full answer is no. In 1992 Gordon, Webb and Wolpert exhibited two non-congruent planar polygons with identical Laplace spectra (from memory). I tried to reproduce such a pair on the grid by searching small lattice polygons, and I did not find one, so the lab shows no isospectral pair and I make no claim that I verified that theorem here. A grid also would not give an exact test: a staircase discretisation of two isospectral polygons is not isospectral, so at most the grid spectra would be close.

A concrete test that does converge is the L-shaped drum, a 2×22 \times 2 square with a 1×11 \times 1 corner removed, whose first eigenvalue is a standard benchmark because the re-entrant corner is singular. The cell below uses ss cells per unit length, with the nodes on the two inner edges of the removed quadrant taken out of the mask (they are the clamped rim, so the rim lies exactly on grid lines), and rescales λ1\lambda_1 by s2s^2 to get the continuum value.

🐍 PythonStep 5: the L-shaped drum, first eigenvalue at two resolutions
⌘/Ctrl + Enter

The lab’s solver and the numpy and scipy program agree at the three resolutions I ran: s=8s = 8 (161161 nodes) gives 9.69329.6932, s=16s = 16 (705705 nodes) gives 9.67359.6735, and s=32s = 32 (29452945 nodes) gives 9.65629.6562 (residual about 4×10−124 \times 10^{-12} in the lab, the node and scipy values equal to all printed digits). A reference value I remember for the continuum λ1\lambda_1 is 9.63979.6397 (from memory, a published high-precision value; I did not recompute it). The differences from it, 0.05350.0535, 0.03380.0338 and 0.01650.0165, shrink by a factor of 1.61.6 and then 2.02.0: a staircase on a singular corner converges slowly, and the order I can read from three points is between about 0.70.7 and 11, not better. For a circle and a square of the same area aa the continuum values of λ1\lambda_1 are 18.17/a18.17/a and 19.74/a19.74/a (arithmetic from j012πj_{01}^2\pi and 2π22\pi^2, not a lab output), and the disk is the lowest of all shapes at fixed area, the Faber-Krahn theorem (from memory).

The lab

The sim below holds all of this in one place. The left panel is the drum. Choose a shape (circle, square, rectangle, L, ellipse, triangle) or switch the pointer to paint and erase and draw your own, and the lab recomputes the lowest 2020 modes (about half a second at the default 49×4949 \times 49 grid, a timing). The mode slider selects which mode to show as a diverging heat map (the shape oscillates in time at the mode’s relative frequency, if animation is on), and the right panel is the strike spectrum: one bar per eigenspace, whose height is ∣∑φk(p)φk(r)/rk∣\lvert\sum\varphi_k(p)\varphi_k(r)/r_k\rvert, so a bar is missing where the strike point lies on a nodal line. Click a bar to select its mode. For the circle, diamonds mark the Bessel ratios jmn/j01j_{mn}/j_{01} so you can see how well the staircase did, and the readout prints the solver’s iterations, time and residual. Switch the view to the leapfrog wave to watch the strike ring; a point strike excites every grid mode up to the checkerboard, so that view looks grainy, and the fine grain is the high modes that the sound (which keeps 2020) leaves out. Three things to try: strike the circle at its centre and see that only the rotationally symmetric (0,n)(0,n) modes sing; strike it near the rim and hear the pairs join in; paint a notch into the rim and watch the degenerate pairs split.

◆ Interactive The drum lab: pick or draw a shape, choose a mode, strike and listen, and compare the circle with the Bessel ratios (49 x 49 grid, 20 modes)

Loading simulation…

The sim can also be opened on a particular mode. Here it is opened on mode 2 of the square, one member of a degenerate pair: the solver returns an arbitrary basis of the pair’s plane, so the nodal line you see may be a straight cut or a diagonal. Mode 4 is the single (2,2)(2,2) cross.

◆ Interactive The square drum on mode 2, a degenerate pair (37 x 37 grid)

Loading simulation…

Honest limits

  • A membrane under tension is not a drum. A real drumhead is coupled to a shell of air, and the added air mass lowers the low modes more than the high ones and shifts the ratios away from the Bessel values. The lab has no air in it. That is the largest known physical difference, and I cannot give a number for it here (from memory: this air loading is what makes the real fundamental of a timpani sit well below the dry membrane’s).
  • No stiffness. A real membrane has some bending stiffness, which adds a ∇4\nabla^4 term, raises high modes above the pure membrane ratios, and is the main difference between a membrane and a thin plate. The lab omits it.
  • No nonlinearity. The wave equation here is linear, so there is no pitch glide after a hard strike, which real drums have, and amplitudes add exactly. The pitch glide of a hard-struck drum is a tension effect (from memory).
  • The damping is a choice. The rk2r_k^2 law is a convenient family and not a measurement of anything.
  • The staircase limits the accuracy. Ratios converge at an order between 1.51.5 and 1.91.9 on the circle, absolute pitch only at about first order, and a re-entrant corner converges even more slowly. A finite-element discretisation with a smooth boundary fixes the first two, and is the subject of 10.13 Introduction to Finite Elements.
  • The sound is unheard. The synthesis is verified sample by sample against the formula (above), but WebAudio cannot be run in a headless browser, so the playback path, the gain and the click-free envelope have not been checked by ear. If it clips or clicks, that is a bug I could not see.
  • Isospectral drums are from memory. I did not verify the Gordon-Webb-Wolpert pair, and the lab does not show one.

Concept checks

✅ Concept check

A disk of radius $6$ cells has $\lambda_{\min} = 0.14468$ for $A$. Using $\lambda_{\max} = 8 - \lambda_{\min}$, what is the leapfrog step limit $2/\sqrt{\lambda_{\max}}$?

✅ Concept check

What is the frequency ratio of the first $m = 1$ mode of an ideal circular drum to its fundamental, $j_{11}/j_{01}$, with $j_{01} = 2.404826$ and $j_{11} = 3.831706$?

✅ Concept check

A circular drum has its fundamental at $110$ Hz. Using the Bessel ratio $j_{21}/j_{01} = 2.1355$, at what frequency does the $(2,1)$ mode ring?

✅ Concept check

Why does the staircase circle's ratio $\sqrt{\lambda_k/\lambda_1}$ converge faster than its absolute eigenvalue $\lambda_1$?

✅ Concept checkselect all that apply

Select all that are true of striking a square drum exactly at its centre.

✅ Concept check

What does Kac's question 'can one hear the shape of a drum?' ask?

Problems

✏️ Pen & paperA three-by-three drum by hand●○○

Take the square drum with N=3N = 3 (3×3=93 \times 3 = 9 nodes). (a) Find λ11\lambda_{11} and λ12\lambda_{12} from 4sin⁡2mπ8+4sin⁡2nπ84\sin^2\frac{m\pi}{8} + 4\sin^2\frac{n\pi}{8}. (b) Find the discrete frequency ratio of mode (1,2)(1,2) to mode (1,1)(1,1) and compare it with the continuum value 5/2\sqrt{5/2}.

Show worked solution

(a) With 4sin⁡2(π/8)=2−24\sin^2(\pi/8) = 2 - \sqrt2, 4sin⁡2(2π/8)=24\sin^2(2\pi/8) = 2 and 4sin⁡2(3π/8)=2+24\sin^2(3\pi/8) = 2 + \sqrt2: λ11=2(2−2)=4−22=1.17157\lambda_{11} = 2(2 - \sqrt2) = 4 - 2\sqrt2 = 1.17157 and λ12=(2−2)+2=4−2=2.58579\lambda_{12} = (2 - \sqrt2) + 2 = 4 - \sqrt2 = 2.58579.

(b) The discrete ratio is 2.58579/1.17157=1.4856\sqrt{2.58579/1.17157} = 1.4856, and the continuum ratio is 5/2=1.5811\sqrt{5/2} = 1.5811, so the discrete drum is 6.04%6.04\% low in this ratio. With only three nodes per side the grid is coarse, and the error fell to 4.7%4.7\% for the worst of the first twelve modes at N=10N = 10 and to 0.09%0.09\% at N=80N = 80 in the table above. (Dense eigh of the 9×99 \times 9 matrix gives the same 1.171571.17157 and 2.585792.58579.)

✏️ Pen & paperThe step limit of a three-node strip●●○

A strip of three nodes in a row (a 1×31 \times 3 mask) has A=(4−10−14−10−14)A = \begin{pmatrix}4 & -1 & 0\\ -1 & 4 & -1\\ 0 & -1 & 4\end{pmatrix} with eigenvalues 4−24 - \sqrt2, 44 and 4+24 + \sqrt2. Find the leapfrog limit νmax⁡\nu_{\max}, and check the bipartite relation λmax⁡=8−λmin⁡\lambda_{\max} = 8 - \lambda_{\min}.

Show worked solution

Leapfrog is stable for ν2λmax⁡≤4\nu^2\lambda_{\max} \le 4, so νmax⁡=2/λmax⁡=2/4+2=2/5.41421=0.8595\nu_{\max} = 2/\sqrt{\lambda_{\max}} = 2/\sqrt{4 + \sqrt2} = 2/\sqrt{5.41421} = 0.8595. For the bipartite check, 8−λmin⁡=8−(4−2)=4+2=λmax⁡8 - \lambda_{\min} = 8 - (4 - \sqrt2) = 4 + \sqrt2 = \lambda_{\max}, as required. The strip’s limit is above 1/2=0.70711/\sqrt2 = 0.7071, which is the general lower bound and is only approached by large drums.

✏️ Pen & paperStriking the middle of the three-by-three drum●●●

For the N=3N = 3 square drum struck and picked up at the centre node, find which eigenspaces are excited and the amplitudes ∑φk(p)2/rk\sum\varphi_k(p)^2/r_k per eigenspace, with rk=λk/λ1r_k = \sqrt{\lambda_k/\lambda_1}. Use the eigenvalues 4−224 - 2\sqrt2, 4−24 - \sqrt2 (twice), 44 (three modes), 4+24 + \sqrt2 (twice) and 4+224 + 2\sqrt2.

Show worked solution

The mode (m,n)(m,n) has the centre value φ=12sin⁡mπ2sin⁡nπ2\varphi = \frac12\sin\frac{m\pi}{2}\sin\frac{n\pi}{2} (the normalisation is 2/(N+1)=1/22/(N+1) = 1/2 per direction), so φ2=1/4\varphi^2 = 1/4 if mm and nn are both odd and 00 otherwise. The even-index modes (1,2)(1,2), (2,1)(2,1), (2,3)(2,3), (3,2)(3,2) and (2,2)(2,2) are silent: their nodal lines pass through the centre. The excited ones are (1,1)(1,1) with λ=4−22\lambda = 4 - 2\sqrt2, the pair (1,3)(1,3) and (3,1)(3,1) which share λ=4\lambda = 4, and (3,3)(3,3) with λ=4+22\lambda = 4 + 2\sqrt2. The frequency ratios are r=1r = 1, r=4/(4−22)=1.8478r = \sqrt{4/(4 - 2\sqrt2)} = 1.8478, and r=(4+22)/(4−22)=1+2=2.4142r = \sqrt{(4 + 2\sqrt2)/(4 - 2\sqrt2)} = 1 + \sqrt2 = 2.4142. The cluster sums ∑φ2\sum\varphi^2 are 1/41/4, 2×1/4=1/22 \times 1/4 = 1/2 and 1/41/4, so the amplitudes are 0.250.25, 0.5/1.8478=0.27060.5/1.8478 = 0.2706 and 0.25/2.4142=0.10360.25/2.4142 = 0.1036. The strongest line is not the fundamental but the pair at 1.84781.8478 times it, because two modes contribute to it. (A numpy check of the 9×99 \times 9 matrix gives the same values.)

What comes next

We built a drum from a mask, a matrix and a sparse eigensolver, and the Bessel comparison gave us an honest account of what the staircase costs: a pitch that is off by a fraction of a cell of radius, and ratios that are good to a fraction of a percent at a radius of sixty-four cells. The structure is again that of every grid simulator, a stencil, an analysis step and careful bookkeeping, but the analysis step is new: instead of marching in time we diagonalised, and the physics became a list of frequencies.

The next capstone, L-16.5, the Orbital Transfer Planner, is deliberately a very different problem. A drum is linear and dissipative, so errors in the integrator are damped and a modal sum is exact. An orbit is nonlinear and conservative: nothing damps, errors accumulate for as long as you integrate, and a method that is accurate and stable in this lesson’s sense can still make an orbit spiral out. The question becomes whether a scheme preserves the conserved energy and angular momentum, which is the idea behind symplectic integrators, and the planner has to keep an orbit honest over many revolutions (12.7 Orbital Mechanics and 14.7 N-Body Simulation lay the physics). The leapfrog you ran in step 1 is, in fact, a symplectic scheme for a linear problem; whether that carries over to gravity is the thing to look for.

Key Takeaways

  • A drum on a grid is a mask plus the five-point operator AA (4 on the diagonal, −1-1 per inside neighbour): symmetric positive definite, with eigenpairs (λk,φk)(\lambda_k, \varphi_k) that decouple the wave equation into oscillators of frequency ωk=(c/h)λk\omega_k = (c/h)\sqrt{\lambda_k}.
  • Leapfrog is stable for ν≤2/λmax⁡\nu \le 2/\sqrt{\lambda_{\max}}; the grid is bipartite, so λmax⁡=8−λmin⁡\lambda_{\max} = 8 - \lambda_{\min} and 1/21/\sqrt2 is a safe step for every shape. Measured by bisection the limit matches the formula to about 2×10−62 \times 10^{-6} (0.713600.71360 against 0.713590.71359 for a disk of radius 66 cells).
  • The lowest modes come from a block shift-invert subspace iteration with Rayleigh-Ritz on a banded Cholesky factor, equivalent to scipy eigsh(A, k, sigma=0); a block of vectors is required because symmetric shapes have repeated eigenvalues.
  • The staircase circle sounds lower than the true circle (the effective radius is 0.250.25 to 0.330.33 cells too large), with λ1\lambda_1 converging at about first order and the frequency ratios at an observed order of about 1.51.5 to 1.91.9: the worst ratio error is 10.0%10.0\% at R=4R = 4 and 0.082%0.082\% at R=64R = 64. A square, with no staircase, converges at second order (4.724%4.724\% at N=10N = 10 to 0.0885%0.0885\% at N=80N = 80).
  • Modal synthesis sums φk(p)φk(r)/rk e−σktsin⁡(2πfkt)\varphi_k(p)\varphi_k(r)/r_k\,e^{-\sigma_kt}\sin(2\pi f_kt); a strike on the nodal line of a mode does not excite it, so striking a square at its centre silences every mode with an even index.
  • A degenerate eigenspace is returned in an arbitrary basis, so only the cluster sum ∑φk(p)φk(r)\sum\varphi_k(p)\varphi_k(r) has a meaning; the grid splits the circle’s m=2m = 2 pair by 4.8%4.8\% at R=4R = 4 and 0.048%0.048\% at R=64R = 64.
  • The membrane model leaves out air loading, stiffness and nonlinearity, and the damping law is a choice. Kac’s question has the answer no in general (the Gordon-Webb-Wolpert pair is from memory and was not verified here), and the audio path is unverified by ear.
Finished this lesson?

Mark it complete to track your progress (saved in this browser). Reading every section does this for you.