Partial Differential Equations II


Topics in Digital Heritage:
Numerical Methods for Digital Reconstruction

Jin Woo Lee

KAIST

Fall 2026

Recap

Last Time: The 1D Wave Equation

\[ u_{tt}=\gamma^2u_{xx},\qquad \gamma=\frac{c}{L},\quad c=\sqrt{T/\rho} \] Insert \(e^{j(\omega t+\beta x)}\): dispersion relation \(\ \omega=\gamma\beta\). Every wavelength travels at \(\gamma\), so the partials are harmonic: \(f_n=nf_0\).

Scheme \(\ \delta_{tt}u=\gamma^2\delta_{xx}u\), Courant number \(\lambda=\gamma k/h\).

Von Neumann: insert \(u_l^n=z^ne^{j\beta lh}\): \[ z+2A+z^{-1}=0,\qquad A=2\lambda^2\sin^2\tfrac{\beta h}{2}-1 \] \(|z_\pm|=1\) for all \(\beta\) iff \(|A|\le1\) \(\Leftrightarrow\) \(\lambda\le1\) (CFL).

Numerical dispersion: \(\ \sin\frac{\omega k}{2}=\lambda\sin\frac{\beta h}{2}\). Exact at \(\lambda=1\); for \(\lambda<1\) short waves are too slow.

Also: discrete energy is conserved; boundary conditions via virtual grid points; \(-2\sigma_0u_t\) damps every partial at the same rate.

Show code
s = np.linspace(0, np.pi, 200)                         # s = beta h
sym2 = 4 * np.sin(s / 2)**2                            # -h^2 x symbol of delta_xx
fig, axs = plt.subplots(2, 1, figsize=(3.9, 3.6), sharex=True)
axs[0].plot(s / np.pi, s**2, "k--", lw=1, label="$u_{xx}$: $\\beta^2h^2$")
axs[0].plot(s / np.pi, sym2, color=COL["string"], lw=2, label="$\\delta_{xx}$: $4\\sin^2(\\beta h/2)$")
axs[1].plot(s / np.pi, s**4, "k--", lw=1, label="$u_{xxxx}$: $\\beta^4h^4$")
axs[1].plot(s / np.pi, sym2**2, color=COL["bar"], lw=2, label="$\\delta_{xxxx}$: $16\\sin^4(\\beta h/2)$")
for ax, top in zip(axs, [10, 100]):
    ax.set_ylim(0, top); ax.legend(fontsize=7.5, loc="upper left")
axs[0].set_title("what each operator multiplies a Fourier mode by", fontsize=9)
axs[1].set_xlabel("$\\beta h/\\pi$  (1 = spatial Nyquist)")
plt.tight_layout()
plt.show()

Reused today

Every new operator gets the same treatment: its dispersion relation, its symbol inserted into \(A\), and \(|A|\le1\).

What the Ideal String Misses

Show code
p = np.arange(1, 25)
z = jn_zeros(0, 6).tolist() + jn_zeros(1, 6).tolist() + jn_zeros(2, 6).tolist() + jn_zeros(3, 5).tolist()
rows = [("ideal string", p, COL["string"]),
        ("piano string\n(exaggerated)", p * np.sqrt(1 + 0.01 * p**2) / np.sqrt(1.01), COL["stiff"]),
        ("bar, free ends\n(xylophone)", bar_modes(200)[0][:8] / bar_modes(200)[0][0], COL["bar"]),
        ("circular drum", np.sort(z) / jn_zeros(0, 1)[0], COL["membrane"])]
fig, ax = plt.subplots(figsize=(5.2, 3.2))
for i, (name, f, col) in enumerate(rows):
    y = -i
    for fp in f[f <= 12.5]:
        ax.plot([fp, fp], [y - 0.32, y + 0.32], color=col, lw=2)
    ax.text(-0.3, y, name, ha="right", va="center", fontsize=8.5, color=col)
for m in range(1, 13):
    ax.axvline(m, color="0.85", lw=0.6, ls="--", zorder=0)
ax.set_xlim(0, 12.6); ax.set_ylim(-3.6, 0.6); ax.set_yticks([])
ax.set_xlabel("frequency / fundamental (dashed: harmonics)")
ax.set_title("where the partials are", fontsize=9)
plt.tight_layout()
plt.show()

Show code
f = np.linspace(50, 8000, 300)
s0, s1 = loss_params(110, 0, 5.0, 110, 1.0, 4000)
T60 = 3 * np.log(10) / (s0 + s1 * (2 * np.pi * f)**2 / 220**2)
fig, ax = plt.subplots(figsize=(3.8, 3.2))
ax.plot(f / 1e3, np.full_like(f, 3.0), color=COL["string"], lw=2, label="last class: $-2\\sigma_0u_t$")
ax.plot(f / 1e3, T60, color=COL["stiff"], lw=2, label="real string: high partials\ndie first")
ax.set_xlabel("frequency (kHz)"); ax.set_ylabel("$T_{60}$ (s)"); ax.set_ylim(0, 5.5)
ax.set_title("how long each partial rings", fontsize=9); ax.legend(fontsize=7.5)
plt.tight_layout()
plt.show()

Today

Add stiffness (inharmonic partials) and frequency dependent loss (darkening tone), then go briefly to 2D (drums, plates). Same toolbox: difference operators, matrices, boundary conditions, energy, von Neumann analysis.

A Tour of Audio PDEs

system PDE instruments covered
ideal string \(u_{tt}=\gamma^2u_{xx}\) guitar, harp (roughly) class 14
stiff string \(u_{tt}=\gamma^2u_{xx}-\kappa^2u_{xxxx}\) piano today
bar \(u_{tt}=-\kappa^2u_{xxxx}\) xylophone, marimba, tuning fork today
frequency dependent loss \(\dots-2\sigma_0u_t+2\sigma_1u_{txx}\) every real instrument today
helical spring coupled fourth order system spring reverb
acoustic tube \(\frac{1}{S}(S\,p_x)_x=\frac{1}{c^2}p_{tt}\) (Webster) winds, the vocal tract later
membrane \(u_{tt}=\gamma^2\nabla^2u\) drums, timpani today (2D)
plate \(u_{tt}=-\kappa^2\nabla^4u\) gongs, plate reverb today (2D)
air in a room \(p_{tt}=c^2\nabla^2p\) (3D) rooms, halls later

Today’s ILO

  • Explain how a fourth order term causes dispersion and inharmonicity, and implement schemes for bars and stiff strings with their boundary conditions and von Neumann stability conditions.
  • Set frequency dependent loss from two decay times and evaluate the tone over time.
  • Compute modes of non-uniform structures as an eigenproblem of the semidiscrete system, and use them to tune and strike a marimba bar (modal synthesis).
  • Extend grid functions to 2D, simulate membranes and plates, and weigh 2D stability limits and cost.
  • Choose a method and recall the stability condition for each audio PDE.

Stiffness: Bars and Stiff Strings

The Ideal Bar: A Fourth Derivative

Bending moment \(\propto\) curvature \(u_{xx}\); its second derivative is a force: \[ u_{tt}=-\kappa^2u_{xxxx},\qquad \kappa^2=\frac{EI}{\rho A\,L^4} \] Insert \(e^{j(\omega t+\beta x)}\):

String Bar
Angular frequency \(\omega=\gamma\beta\) \(\omega=\kappa\beta^2\)
Phase velocity \(\frac{\omega}{\beta}=\gamma\) \(\frac{\omega}{\beta}=\kappa\beta\)
Group velocity \(\frac{d\omega}{d\beta}=\gamma\) \(\frac{d\omega}{d\beta}=2\kappa\beta\)

Short waves travel faster: physical dispersion

Show code
L, M = 8.0, 4096                                   # a long domain, exact solution by FFT
x = (np.arange(M) - M / 2) * L / M
beta = 2 * np.pi * np.fft.fftfreq(M, L / M)
evolve = lambda u0, omega, t: np.real(np.fft.ifft(np.fft.fft(u0) * np.cos(omega * t)))
u0 = np.exp(-(x / 0.05)**2)
fig = plt.figure(figsize=(4.8, 3.8))
ax = fig.add_subplot(2, 1, 1)
for t, a, mag in [(0, 0.35, 1), (0.6, 1, 4)]:
    ax.plot(x, evolve(u0, beta, t), color=COL["string"], alpha=a, lw=1.4, label=f"string, $t={t}$")
    ax.plot(x, mag * evolve(u0, beta**2 * 0.02, t) - 1.2, color=COL["bar"], alpha=a, lw=1.2,
            label=f"bar, $t={t}$" + (" ($\\times4$)" if mag > 1 else ""))
ax.set_xlim(-1.2, 1.2); ax.set_yticks([]); ax.set_xlabel("$x$")
ax.set_title("same pulse: the string keeps its shape, the bar disperses", fontsize=9)
ax.legend(fontsize=6.5, ncol=2, loc="upper right")
om, V, xb = bar_modes(200)
for i in range(3):
    ax = fig.add_subplot(2, 3, 4 + i)
    ax.plot(xb, V[:, i] / np.abs(V[:, i]).max(), color=COL["bar"], lw=1.6); ax.axhline(0, color="0.85", lw=0.6)
    ax.set_title(f"mode {i + 1}: $\\times${om[i] / om[0]:.2f}", fontsize=8.5); ax.set_xticks([]); ax.set_yticks([])
plt.tight_layout()
plt.show()

Discretizing the Bar: Stability

\[ \delta_{tt}u=-\kappa^2\,\delta_{xxxx}u,\qquad \delta_{xxxx}=\delta_{xx}\delta_{xx} \] Von Neumann as for the string, \(u_l^{n}=z^ne^{j\beta lh}\): \[ z+2\underbrace{\left(8\mu^2\sin^4\tfrac{\beta h}{2}-1\right)}_{A}+z^{-1}=0,\qquad \mu=\frac{\kappa k}{h^2} \] Again, the roots are \(z_\pm=-A\pm\sqrt{A^2-1}\), and the scheme is stable if \(|A|\le1\).

\[ |A|\le1\iff\mu\le\frac12\iff h\ge\sqrt{2\kappa k} \]

Show code
gamma, f1 = 440.0, 523.25                             # 220 Hz string, C5 xylophone bar
kappa = 2 * np.pi * f1 / 4.7300407**2                 # free-free: omega_1 = kappa (4.730)^2
h = np.logspace(-3, 0, 200)
fig, ax = plt.subplots(figsize=(4.6, 3.6))
for kmax, col, lab in [(h / gamma, COL["string"], "string: $k\\leq h/\\gamma$  (slope 1)"),
                       (h**2 / (2 * kappa), COL["bar"], "bar: $k\\leq h^2/2\\kappa$  (slope 2)")]:
    ax.loglog(h, kmax, color=col, lw=2, label=lab)
    ax.fill_between(h, 1e-9, kmax, color=col, alpha=0.08)
ax.axhline(1 / fs, color="0.3", ls="--", lw=1)
ax.text(1.1e-3, 1.25 / fs, "$k=1/44100$", fontsize=8, color="0.3")
for hmin, col in [(gamma / fs, COL["string"]), (np.sqrt(2 * kappa / fs), COL["bar"])]:
    ax.plot(hmin, 1 / fs, "o", color=col, ms=6)
    ax.annotate(f"$h_{{\\min}}$: $N={int(1 / hmin)}$", (hmin, 1 / fs), (hmin * 1.3, 0.25 / fs),
                color=col, fontsize=8.5, arrowprops=dict(arrowstyle="-", color=col, lw=0.6))
ax.set_ylim(1e-8, 1e-2); ax.set_xlim(1e-3, 1)
ax.set_xlabel("grid spacing $h$"); ax.set_ylabel("largest stable time step $k$ (s)")
ax.set_title("stable below each line: 220 Hz string vs C5 bar", fontsize=9)
ax.legend(fontsize=7.5, loc="upper left")
plt.tight_layout()
plt.show()

  • At a fixed audio rate the bar allows only a very coarse grid.
  • Stability bound depends on the operator. Recall that the fastest grid mode (spatial Nyquist) must satisfy \(\omega_{\max}k\le2\) (class 13):
string bar
\(\omega_{\max}\) (from the symbol) \(2\gamma/h\) \(4\kappa/h^2\)
\(\omega_{\max}k\le2\) \(\lambda=\gamma k/h\le1\) \(\mu=\kappa k/h^2\le\tfrac12\)
scaling \(k\propto h\) \(k\propto h^2\)

Bar Boundary Conditions on the Grid

Fourth order: two conditions per end, imposed with virtual grid points as in class 14.

end conditions on the grid example
simply supported \(u=u_{xx}=0\) \(u_{-1}=-u_1\): matrix \(\mathbf{D}_{xx}^2\) (analysis)
clamped \(u=u_x=0\) \(u_{-1}=u_1\): first row \([7,-4,1]/h^4\) tuning fork, kalimba
free \(u_{xx}=u_{xxx}=0\) two virtual points, messy xylophone bar on cords

Energy form for free ends: discretize the potential \(\tfrac{\kappa^2}{2}\int u_{xx}^2\) as \(\tfrac{\kappa^2}{2}\sum h(\delta_{xx}u)^2\), then \(\mathbf{M}\mathbf{u}''=-\kappa^2\mathbf{K}\mathbf{u}\). The free conditions come out by themselves (summation by parts in reverse).

# delta_xx at the interior nodes only
D2 = sp.diags([1, -2, 1], [0, 1, 2], shape=(N - 1, N + 1)) / h**2
K = h * D2.T @ D2          # free ends, automatically
Show code
N = 6                                                  # grid u_0 .. u_6, everything times h^4
Dxx = sp.diags([1, -2, 1], [-1, 0, 1], shape=(N - 1, N - 1)).toarray()   # Dirichlet h^2 delta_xx
D2 = sp.diags([1, -2, 1], [0, 1, 2], shape=(N - 1, N + 1)).toarray()     # interior rows only
w = np.ones(N + 1); w[[0, -1]] = 0.5                   # trapezoid weights: M = h diag(w)
ss = Dxx @ Dxx                                         # simply supported: u_{-1} = -u_1
cl = ss.copy(); cl[0, 0] = cl[-1, -1] = 7              # clamped: u_{-1} = u_1
fr = np.diag(1 / w) @ D2.T @ D2                        # free: M^{-1} K from the energy form
fig = plt.figure(figsize=(4.6, 4.2))
gs = fig.add_gridspec(2, 2, height_ratios=[5, 7])
for ax, A, title, first in [(fig.add_subplot(gs[0, 0]), ss, "simply supported", 1),
                            (fig.add_subplot(gs[0, 1]), cl, "clamped", 1),
                            (fig.add_subplot(gs[1, :]), fr, "free (energy form)", 0)]:
    n = len(A)
    ref = sp.diags([1, -4, 6, -4, 1], np.arange(-2, 3), shape=(n, n)).toarray()   # plain interior stencil
    ax.imshow(A, cmap="RdBu_r", vmin=-8, vmax=8)
    for i in range(n):
        for j in range(n):
            changed = A[i, j] != ref[i, j]
            if A[i, j] != 0:
                ax.text(j, i, f"{A[i, j]:g}", ha="center", va="center", fontsize=8,
                        color="w" if abs(A[i, j]) >= 6 else "k", fontweight="bold" if changed else "normal")
            if changed:                                # entries set by the boundary condition
                ax.add_patch(plt.Rectangle((j - 0.5, i - 0.5), 1, 1, fill=False, ec="k", lw=1.4))
    labels = [f"$u_{{{m}}}$" for m in range(first, first + n)]
    ax.set_xticks(range(n)); ax.set_xticklabels(labels, fontsize=7)
    ax.set_yticks(range(n)); ax.set_yticklabels(labels, fontsize=7)
    ax.tick_params(length=0, top=True, labeltop=True, bottom=False, labelbottom=False)
    ax.set_title(title, fontsize=9)
fig.suptitle("$h^4\\,\\delta_{xxxx}$ as a matrix, $N=6$ (boxed: set by the boundary)", fontsize=9)
plt.tight_layout()
plt.show()

Interior rows are always \([1,-4,6,-4,1]\); only the corner rows differ. The free rows \([2,-4,2]\) and \([-2,5,-4,1]\) match what two virtual points would give.

Why the Bar Comes Out Flat

At 44.1 kHz the explicit scheme allows only \(N=12\) for a C5 bar, and every mode comes out flat. Why? Insert \(z=e^{j\omega k}\) into the characteristic equation, solve for \(\omega\), and compare with the exact value.

String (exact: \(\omega=\gamma\beta\)) \[ \sin\frac{\omega k}{2}=\lambda\sin\frac{\beta h}{2} \] \[ \omega\approx\gamma\beta\Bigl(1\underbrace{-\tfrac{(\beta h)^2}{24}}_{\text{space}}\ \underbrace{+\ \lambda^2\tfrac{(\beta h)^2}{24}}_{\text{time}}\Bigr) \] Same order: they cancel at \(\lambda=1\). Exact.

Bar (exact: \(\omega=\kappa\beta^2\)) \[ \sin\frac{\omega k}{2}=2\mu\sin^2\frac{\beta h}{2} \] \[ \omega\approx\kappa\beta^2\Bigl(1\underbrace{-\tfrac{(\beta h)^2}{12}}_{\text{space}}\ \underbrace{+\ \mu^2\tfrac{(\beta h)^4}{24}}_{\text{time}}\Bigr) \] Time is one order higher: nothing cancels the space error. Always flat.

Reading the expansion

  • \(\beta h=2\pi/(\text{grid points per wavelength})\): small \(\beta h\) = a well resolved wave.
  • The inner \(\sin\) comes from the spatial difference, the outer \(\arcsin\) from the time difference. Expand each: \(\ \sin x\approx x\bigl(1-\tfrac{x^2}{6}\bigr)\), \(\ \arcsin x\approx x\bigl(1+\tfrac{x^2}{6}\bigr)\).

Flat in Practice: The C5 Bar

  • The error grows like \((\beta h)^2\): high modes suffer most. At \(N=12\), \(\beta_ph\) runs from \(0.39\) (mode 1) to \(1.44\) (mode 5).
  • Free ends add an error of the same size: the mode shapes are not sines near the ends.
  • Time stepping raises the pitch only slightly (red vs purple).
  • Refining helps (\(\propto h^2\)), but \(N>12\) means \(\mu>\tfrac12\): unstable.

Remedies

  • An implicit scheme: free choice of \(h\).
  • Modal synthesis with modes computed once on a fine grid.
Show code
bp = np.array([4.7300407, 7.8532046, 10.9956078, 14.1371655, 17.2787597])   # free-free: beta_p
kappa = 2 * np.pi * 523.25 / bp[0]**2                 # C5 bar
k = 1 / fs; N = int(1 / np.sqrt(2 * kappa * k)); h = 1 / N
exact = kappa * bp**2
cents = lambda om: 1200 * np.log2(om / exact[:len(om)])
om_int = kappa * 4 * np.sin(bp * h / 2)**2 / h**2     # interior symbol of delta_xxxx at the exact beta_p
om_sp = kappa * bar_modes(N)[0][:5]                   # + free end rows (space only)
om_fd = 2 / k * np.arcsin(np.minimum(1, k * om_sp / 2))   # + time stepping: the actual scheme
fig, axs = plt.subplots(2, 1, figsize=(5.2, 4.2), height_ratios=[1.15, 1])
p = np.arange(1, 6); wd = 0.26
for i, (om, col, lab) in enumerate([(om_int, "0.65", "interior dispersion $\\delta_{xxxx}$"),
                                    (om_sp, COL["bar"], "+ free end rows (space only)"),
                                    (om_fd, "firebrick", "+ time stepping (the scheme)")]):
    axs[0].bar(p + (i - 1) * wd, cents(om), wd, color=col, label=lab)
axs[0].axhline(-100, color="k", ls=":", lw=0.8)
axs[0].text(0.6, -95, "a semitone", fontsize=7, ha="left", va="bottom")
axs[0].set_xticks(p); axs[0].set_xlabel(f"mode ($\\beta_ph$ from {bp[0] * h:.2f} to {bp[-1] * h:.2f})")
axs[0].set_ylabel("cents"); axs[0].legend(fontsize=7, loc="lower left")
axs[0].set_title(f"C5 bar, $N={N}$ ($\\mu={kappa * k / h**2:.2f}$): where the error comes from", fontsize=9)
Ns = np.array([8, 12, 24, 48, 96, 192])
for m, mk in [(0, "o"), (2, "s"), (4, "^")]:
    err = [-cents(kappa * bar_modes(n)[0][:5])[m] for n in Ns]
    axs[1].loglog(Ns, err, mk + "-", color=COL["bar"], alpha=1 - 0.25 * m / 2, ms=4, label=f"mode {m + 1}")
axs[1].loglog(Ns, 2000 / Ns**2, "k--", lw=0.8); axs[1].text(60, 2000 / 60**2 * 0.45, "slope $-2$", fontsize=8)
axs[1].axvline(N, color="firebrick", lw=1); axs[1].axvspan(N, 250, color="firebrick", alpha=0.06)
axs[1].text(N * 1.1, 0.3, "explicit: unstable\n($\\mu>1/2$)", color="firebrick", fontsize=7.5)
axs[1].set_xlim(7, 250); axs[1].set_xlabel("grid cells $N$"); axs[1].set_ylabel("cents flat (space only)")
axs[1].legend(fontsize=7, loc="upper right")
plt.tight_layout()
plt.show()

Stiff Strings: Why Piano Tuners Stretch Octaves

\[ u_{tt}=\gamma^2u_{xx}-\kappa^2u_{xxxx} \] Scheme: \(\ \delta_{tt}u=\gamma^2\delta_{xx}u-\kappa^2\delta_{xxxx}u\)
Dispersion relation: \(\omega^2=\gamma^2\beta^2+\kappa^2\beta^4\)

Simply supported ends (\(\beta=p\pi\)): \[ f_p=p\,f_0\sqrt{1+Bp^2},\qquad B=\frac{\kappa^2\pi^2}{\gamma^2} \]

  • Partials are sharp, more so going up: inharmonicity.
  • Tuners stretch octaves so that the upper note matches the sharp 2nd partial of the lower one.
Show code
f0, B = 110.0, 4e-4
y, N = stiff_string(f0, B, sig0=1.0, dur=1.0, xe=0.13)
fig, axs = plt.subplots(2, 1, figsize=(5.0, 3.8))
Y = np.abs(np.fft.rfft(y * np.hanning(len(y)))); f = np.fft.rfftfreq(len(y), 1 / fs)
p = np.arange(1, 31); f_th = p * f0 * np.sqrt(1 + B * p**2)
for q in p:
    axs[0].axvline(q * f0, color="0.85", ls="--", lw=0.7)
axs[0].plot(f, 20 * np.log10(Y / Y.max() + 1e-9), color="k", lw=0.7)
axs[0].plot(f_th, np.full_like(f_th, 3), "v", color="firebrick", ms=3.5)
axs[0].set_xlim(1500, 3000); axs[0].set_ylim(-80, 8); axs[0].set_xlabel("frequency (Hz)")
axs[0].set_title(f"$f_0=110$ Hz, $B=4\\times10^{{-4}}$, $N={N}$: peaks drift off the harmonics", fontsize=9)
# partials of the scheme from the eigenvalues of the update matrix
gamma, kappa, k, h = 2 * f0, np.sqrt(B) * 2 * f0 / np.pi, 1 / fs, 1 / N
Dxx = sp.diags([1, -2, 1], [-1, 0, 1], shape=(N - 1, N - 1)).toarray() / h**2
lam = np.sort(np.linalg.eigvalsh(gamma**2 * Dxx - kappa**2 * Dxx @ Dxx))[::-1][:30]
f_num = 2 / k * np.arcsin(np.minimum(1, k / 2 * np.sqrt(-lam))) / (2 * np.pi)
axs[1].plot(p, 1200 * np.log2(f_th / (p * f0)), color="firebrick", lw=1.8, label="theory $\\sqrt{1+Bp^2}$")
axs[1].plot(p, 1200 * np.log2(f_num / (p * f0)), "o", color="k", ms=3, label="scheme")
axs[1].axhline(100, color="0.7", ls=":", lw=1); axs[1].text(1, 110, "a semitone", fontsize=7.5, color="0.5")
axs[1].set_xlabel("partial $p$"); axs[1].set_ylabel("cents above $p f_0$")
axs[1].legend(fontsize=7.5, loc="upper left")
plt.tight_layout()
plt.show()

The symbols add: \(A=2\lambda^2s^2+8\mu^2s^4-1\) with \(s=\sin\frac{\beta h}{2}\), so \(|A|\le1\iff\lambda^2+4\mu^2\le1\), i.e. \[ h\ge\sqrt{\tfrac12\Bigl(\gamma^2k^2+\sqrt{\gamma^4k^4+16\kappa^2k^2}\Bigr)} \] \(\kappa=0\ \Rightarrow\ h\ge\gamma k\) (string). \(\ \gamma=0\ \Rightarrow\ h \ge\sqrt{2\kappa k}\) (bar).

Try It: From String to Bar

Loss and Shape

Frequency Dependent Loss

\[ u_{tt}=\gamma^2u_{xx}-\kappa^2u_{xxxx}-2\sigma_0u_t+2\sigma_1u_{txx} \] Decay rate of wavenumber \(\beta\): \(\ \sigma(\beta)\approx\sigma_0+\sigma_1\beta^2\), larger for short waves.

Set from two decay times, e.g. \(T_{60}=5\) s at 110 Hz and \(0.5\) s at 4 kHz: a \(2\times2\) linear system for \((\sigma_0,\sigma_1)\).

Scheme: use \(\delta_{t-}\) in the new term so the update stays explicit: \[ \dots-2\sigma_0\delta_{t\cdot}u+2\sigma_1\delta_{t-}\delta_{xx}u \] Stability: \(h\ge\sqrt{\tfrac12\bigl(a+\sqrt{a^2+16\kappa^2k^2}\bigr)}\) with \(a=\gamma^2k^2+4\sigma_1k\). The energy still only decreases.

Show code
f0, B = 110.0, 1e-4
s0, s1 = loss_params(f0, B, 5.0, 110, 0.5, 4000)
runs = [("$\\sigma_0$ only: $T_{60}=5$ s everywhere", 3 * np.log(10) / 5.0, 0.0),
        (f"$\\sigma_0={s0:.2f}$, $\\sigma_1={s1:.1e}$: $T_{{60}}$ 5 s at 110 Hz, 0.5 s at 4 kHz", s0, s1)]
fig, axs = plt.subplots(2, 1, figsize=(5.0, 3.8), sharex=True)
for ax, (title, a0, a1) in zip(axs, runs):
    y, N = stiff_string(f0, B, sig0=a0, sig1=a1, dur=2.0, xe=0.1)
    S, t, f = spectrogram(y)
    ax.pcolormesh(t, f / 1e3, S, vmin=-80, vmax=0, cmap="magma", shading="auto")
    ax.set_ylim(0, 8); ax.set_ylabel("kHz"); ax.set_title(title + f"  ($N={N}$)", fontsize=8.5)
axs[1].set_xlabel("time (s)")
plt.tight_layout()
plt.show()

Tuning a Marimba Bar by Carving It

Marimba makers carve an arch under the bar to tune 2nd mode to

  • 4× the fundamental (2 octaves);
  • xylophones to 3× (1 octave + perfect 5th).

Thickness \(e(x)\): stiffness \(\propto e^3\), mass \(\propto e\): \[ \mathbf{K}=\mathbf{D}_2^\top\operatorname{diag}(h\,e^3)\,\mathbf{D}_2,\quad \mathbf{M}=\operatorname{diag}(h\,e) \] No closed form, so solve the generalized eigenproblem \[ \mathbf{K}\mathbf{v}=\omega^2\mathbf{M}\mathbf{v} \]

Show code
from scipy.optimize import brentq
arch = lambda d: (lambda x: 1 - d * np.clip(1 - ((x - 0.5) / 0.3)**2, 0, None))
ratios = lambda d: (lambda om: om[1:3] / om[0])(bar_modes(150, arch(d))[0])
ds = np.linspace(0, 0.68, 30); R = np.array([ratios(d) for d in ds])
d_mar = brentq(lambda d: ratios(d)[0] - 4, 0.3, 0.7)          # marimba: f2 = 4 f1
d_xyl = brentq(lambda d: ratios(d)[0] - 3, 0.05, 0.4)         # xylophone: f2 = 3 f1
fig, axs = plt.subplots(1, 2, figsize=(5.6, 3.6), width_ratios=[1, 1.1])
axs[0].plot(ds, R[:, 0], color=COL["bar"], lw=2, label="$f_2/f_1$")
for d, r, lab in [(d_xyl, 3, "xylophone"), (d_mar, 4, "marimba")]:
    axs[0].plot(d, r, "o", color="firebrick"); axs[0].axhline(r, color="0.85", lw=0.8, zorder=0)
    axs[0].text(d - 0.02, r + 0.08, f"{lab}\n$d={d:.2f}$", fontsize=7.5, color="firebrick", ha="right")
axs[0].set_xlabel("carving depth $d$"); axs[0].set_ylabel("ratio"); axs[0].legend(fontsize=7, loc="upper left")
axs[0].set_title("carve deeper, raise the ratio", fontsize=9)
om, V, x = bar_modes(150, arch(d_mar))
ax = axs[1]
ax.fill_between(x, 0.6 + 0.25 * arch(d_mar)(x), 0.6, color="burlywood")
ax.text(0.5, 0.92, "cross section", ha="center", fontsize=7.5)
for i in range(3):
    ax.plot(x, 0.25 * V[:, i] / np.abs(V[:, i]).max() - 0.6 * i, color=COL["bar"], lw=1.5)
    ax.text(1.02, -0.6 * i, f"$\\times${om[i] / om[0]:.2f}", fontsize=8.5, va="center")
ax.set_xlim(0, 1.25); ax.axis("off"); ax.set_title("the tuned marimba bar and its modes", fontsize=9)
plt.tight_layout()
plt.show()

(scipy.linalg.eigh(K, M)), and find the depth giving ratio 4 (or 3 for xylophones) with a root finder.

  • Carving the middle lowers mode 1 most (it bends most there), so the ratio rises.
  • Tuning mode 3 too (to 10× on real marimbas) needs more shape parameters requiring better optimization.

Striking the Bar: Mallets and Modal Synthesis

Linear structure + known modes \(\Rightarrow\) use modal synthesis

  • exact pitch with the class 13 recursion: \[ \begin{aligned} q_p^{n+1}=\ &2e^{-\sigma_pk}\cos(\omega_pk)\,q_p^n-e^{-2\sigma_pk}q_p^{n-1}\\ &+k^2\phi_p(x_e)\,F^n \end{aligned} \]

Mallet:

  • \(\ F=K_H\,[u_H-u(x_e)]_+^{\alpha}\)

  • \(\ u_H''=-F/M_H\).

  • A point force enters through a spreading operator \(J_{x_e}\); the bar is read by an interpolation operator \(I_{x_o}\).

Show code
def strike_bar(profile, f1=261.6, dur=1.2, xe=0.4, xo=0.05, KH=3e10, alpha=2.5, MH=0.02, vH=1.0):
    om, V, x = bar_modes(150, profile)
    keep = om * f1 / om[0] < 2 * np.pi * 18000                # modes below 18 kHz
    om, V = om[keep] * 2 * np.pi * f1 / om[0], V[:, keep]
    sig = 0.6 + 2e-8 * om**2                                  # higher modes decay faster
    phe, pho = V[int(xe * 150)], V[int(xo * 150)]             # spreading / interpolation weights
    k = 1 / fs; c1, c2 = 2 * np.exp(-sig * k) * np.cos(om * k), np.exp(-2 * sig * k)
    q, qp = np.zeros(len(om)), np.zeros(len(om))
    uH, uHp, out, F_hist = -1e-5, -1e-5 - k * vH, np.zeros(int(dur * fs)), []   # just short of contact, moving in
    for n in range(len(out)):
        F = KH * max(uH - phe @ q, 0.0)**alpha                 # contact force
        q, qp = c1 * q - c2 * qp + k**2 * phe * F, q
        uH, uHp = 2 * uH - uHp - k**2 * F / MH, uH
        out[n] = pho @ q; F_hist.append(F)
    return out, np.array(F_hist), om / (2 * np.pi)

uniform = lambda x: np.ones_like(x)
fig, axs = plt.subplots(5, 1, figsize=(4.9, 4.2), height_ratios=[1, 1, 1, 0.45, 0.8],
                        gridspec_kw=dict(hspace=0.25))
axs[3].axis("off"); axs = axs[[0, 1, 2, 4]]          # a spacer row before the force plot
runs = [(uniform, 0.4, "0.45", "uniform bar, $x_e=0.4$"),
        (arch(d_mar), 0.4, COL["bar"], "marimba bar, $x_e=0.4$"),
        (arch(d_mar), 0.5, "darkorange", "marimba bar, $x_e=0.5$ (center)")]
for ax, (prof, xe, col, lab) in zip(axs, runs):
    y, F, fm = strike_bar(prof, xe=xe)                        # read near the end (x_o = 0.05): every mode shows
    Y = np.abs(np.fft.rfft(y * np.hanning(len(y)))); f = np.fft.rfftfreq(len(y), 1 / fs)
    ax.plot(f / 261.6, 20 * np.log10(Y / Y.max() + 1e-9), color=col, lw=0.9)
    for r in [1, 2.76, 4, 5.4, 9.35]:
        ax.axvline(r, color="0.85", ls="--", lw=0.8, zorder=0)
    ax.text(11.9, -10, lab, color=col, fontsize=8, ha="right", va="top")
    ax.set_xlim(0, 12); ax.set_ylim(-120, 5); ax.set_yticks([])
    ax.set_xticks([1, 2.76, 4, 5.4, 9.35]); ax.tick_params(labelbottom=False)
    if prof is uniform:
        axs[3].plot(1e3 * np.arange(len(F)) / fs, F / F.max(), color="k", lw=1.2)
axs[2].annotate("no mode 2", (4, -100), (5.3, -75), fontsize=7.5, color="darkorange",
                arrowprops=dict(arrowstyle="->", color="darkorange", lw=0.8))
axs[2].tick_params(labelbottom=True, labelsize=8)
axs[2].set_xlabel("frequency / $f_1$  ($f_1$ = C4)", fontsize=8, labelpad=1)
axs[0].set_title("same mallet, same pitch: mode 2 at 2.76 vs 4; gone at the center", fontsize=9)
axs[3].set_xlim(0, 3); axs[3].set_xlabel("time (ms)", fontsize=8); axs[3].set_yticks([])
axs[3].set_title("contact force", fontsize=9)
fig.subplots_adjust(left=0.03, right=0.97, top=0.93, bottom=0.09)
plt.show()

  • Strike off center: mode 2 is antisymmetric, with a node at the middle; a center strike drops the \(4\times\) partial (orange).
  • Read near an end: every mode is large there (at \(x_o=0.23\) the uniform bar’s fundamental would vanish, a node of mode 1).

Going 2D: Drums and Plates

Grids in 2D

Grid function \(u_{l,m}^n\approx u(lh,\,mh,\,nk)\).

  • Laplacian: \(\ \delta_\Delta=\delta_{xx}+\delta_{yy}\) (5 points), the operator of last class’s scan fill.
  • Biharmonic: \(\ \delta_{\Delta\Delta}=\delta_\Delta\delta_\Delta\) (13 points), for plates.
  • Matrices are Kronecker sums:
D, I = D_xx(n, h), sp.identity(n)
Lap = sp.kron(I, D) + sp.kron(D, I)   # 5 point
Bih = Lap @ Lap                       # 13 point
  • Round domains: polar grids or staircase boundaries. Off-grid pickups and forces: bilinear interpolation (class 8).

Cost

Unknowns grow like \((f_s/\gamma)^d\): hundreds in 1D, tens of thousands for a drum in 2D, billions for a room in 3D (class 16).

The 2D Wave Equation: Drums

\[ u_{tt}=\gamma^2\nabla^2u\quad\Rightarrow\quad\delta_{tt}u=\gamma^2\delta_\Delta u \] Von Neumann with \(e^{j(\beta_xlh+\beta_ymh)}\): the symbols of \(\delta_{xx}\) and \(\delta_{yy}\) add, \[ A=2\lambda^2\bigl(s_x^2+s_y^2\bigr)-1,\quad s_{x,y}=\sin\tfrac{\beta_{x,y}h}{2} \] Worst case: the checkerboard (\(s_x=s_y=1\)), so \[ \lambda=\frac{\gamma k}{h}\le\frac{1}{\sqrt2} \]

Show code
n = 161; h = 1 / (n - 1); lam = 1 / np.sqrt(2)
X, Y = np.meshgrid(np.linspace(-0.5, 0.5, n), np.linspace(-0.5, 0.5, n))
u = 0.5 * (1 + np.cos(np.pi * np.clip(np.hypot(X, Y) / 0.04, 0, 1)))    # struck: a smooth bump
up = u.copy(); steps = int(0.3 / (lam * h))
for _ in range(steps):
    un = np.zeros_like(u)
    un[1:-1, 1:-1] = (2 * u[1:-1, 1:-1] - up[1:-1, 1:-1] + lam**2 * (u[2:, 1:-1] + u[:-2, 1:-1]
                      + u[1:-1, 2:] + u[1:-1, :-2] - 4 * u[1:-1, 1:-1]))
    up, u = u, un
fig, axs = plt.subplots(1, 2, figsize=(5.6, 3.2), width_ratios=[1, 1.15])
axs[0].imshow(u, cmap="RdBu_r", vmin=-0.02, vmax=0.02, extent=[-0.5, 0.5, -0.5, 0.5], origin="lower")
s = np.linspace(0, 2 * np.pi, 200); r = steps * lam * h
axs[0].plot(r * np.cos(s), r * np.sin(s), color="k", lw=0.7, ls="--")
axs[0].set_title(f"$\\lambda=1/\\sqrt{{2}}$, after {steps} steps\n(dashed: exact wavefront)", fontsize=8.5); axs[0].axis("off")
pq = np.sort([np.hypot(p_, q_) for p_ in range(1, 9) for q_ in range(1, 9)]) / np.sqrt(2)
circ = np.sort(np.concatenate([jn_zeros(m, 8) for m in range(0, 8)])) / jn_zeros(0, 1)[0]
for i, (name, fr, col) in enumerate([("harmonic", np.arange(1, 7), "0.5"), ("square", pq, COL["membrane"]),
                                     ("circle", circ, "darkgreen")]):
    for v in fr[fr <= 5.2]:
        axs[1].plot([v, v], [-i - 0.3, -i + 0.3], color=col, lw=1.6)
    axs[1].text(0.15, -i, name, ha="right", va="center", fontsize=8.5, color=col)
axs[1].set_xlim(0.2, 5.3); axs[1].set_ylim(-2.6, 0.6); axs[1].set_yticks([])
axs[1].set_xlabel("frequency / fundamental"); axs[1].set_title("membrane partials", fontsize=9)
plt.tight_layout()
plt.show()

  • Numerical dispersion now depends on direction: exact along the diagonals at \(\lambda=1/\sqrt2\), slow along the axes. No \(\lambda\) is exact everywhere.
  • Modes: square \(\propto\sqrt{p^2+q^2}\); circle \(\propto\) Bessel zeros \(j_{m,n}\).
    • Not harmonic, so drums have a vague pitch (timpani shift them close to harmonic).

Plates: Gongs and Plate Reverb

\[ u_{tt}=-\kappa^2\nabla^4u-2\sigma_0u_t+2\sigma_1\nabla^2u_t+J_{x_e}F \] Scheme: \(\ \delta_{tt}u=-\kappa^2\delta_{\Delta\Delta}u+\dots\).

The symbol of \(\delta_{\Delta\Delta}\) is the square of that of \(\delta_\Delta\): \(A=8\mu^2(s_x^2+s_y^2)^2-1\), so \[ \mu=\frac{\kappa k}{h^2}\le\frac14 \]

Show code
def lap(v):                                          # 5 point Laplacian times h^2, zero outside
    out = np.zeros_like(v)
    out[1:-1, 1:-1] = v[2:, 1:-1] + v[:-2, 1:-1] + v[1:-1, 2:] + v[1:-1, :-2] - 4 * v[1:-1, 1:-1]
    return out
n = 161; h = 1 / (n - 1)
X, Y = np.meshgrid(np.linspace(-0.5, 0.5, n), np.linspace(-0.5, 0.5, n))
u0 = 0.5 * (1 + np.cos(np.pi * np.clip(np.hypot(X, Y) / 0.06, 0, 1)))
mu = 0.25; u, up = u0.copy(), u0.copy()              # plate, kappa = 1: k = mu h^2
for _ in range(200):
    u, up = 2 * u - up - mu**2 * lap(lap(u)), u
lam = 1 / np.sqrt(2); w, wp = u0.copy(), u0.copy()  # membrane with the same spread
for _ in range(int(0.3 / (lam * h))):
    w, wp = 2 * w - wp + lam**2 * lap(w), w
fig, axs = plt.subplots(1, 2, figsize=(5.4, 3.0))
for ax, field, title in [(axs[0], w, "membrane: a sharp ring"), (axs[1], u, f"plate ($\\mu=1/4$): ripples run ahead")]:
    v = np.abs(field).max() * 0.4
    ax.imshow(field, cmap="RdBu_r", vmin=-v, vmax=v); ax.axis("off"); ax.set_title(title, fontsize=9)
plt.tight_layout()
plt.show()

  • Dispersive like the bar: short waves run ahead of long waves.
    • This is physical dispersion, so every correct solution has it, modal synthesis included.
    • The FD scheme adds numerical dispersion on top (direction dependent, as for the membrane).
  • Plate reverb (EMT 140, 1957): a suspended steel sheet, driven at one point by the audio signal \(F(t)\) and read at two pickups for stereo. Digital versions: this scheme, or modal synthesis (next slide).
  • Gongs and cymbals at large amplitude become nonlinear (pitch glides, shimmer); cf. Duffing oscillator.

Try It: Drum and Plate

Choosing a Method

Audio PDEs at a Glance

system scheme stable when grid at 44.1 kHz (example)
string \(\delta_{tt}u=\gamma^2\delta_{xx}u\) \(\lambda=\gamma k/h\le1\) \(\approx100\) points (220 Hz)
stiff string \(+\,-\kappa^2\delta_{xxxx}u\) \(h\ge\sqrt{\frac12(\gamma^2k^2+\sqrt{\gamma^4k^4+16\kappa^2k^2})}\) \(\approx100\) points (110 Hz, \(B=4\times10^{-4}\))
bar \(\delta_{tt}u=-\kappa^2\delta_{xxxx}u\) \(\mu=\kappa k/h^2\le\frac12\) \(\approx12\) points (C5 bar)
membrane \(\delta_{tt}u=\gamma^2\delta_\Delta u\) \(\lambda\le\frac{1}{\sqrt2}\) \(10^4\) to \(10^5\) points
plate \(\delta_{tt}u=-\kappa^2\delta_{\Delta\Delta}u\) \(\mu\le\frac14\) \(10^4\) to \(10^5\) points

All are \(|A|\le1\) in the von Neumann characteristic equation \(z+2A+z^{-1}=0\) (class 14), evaluated at the worst mode (spatial Nyquist). Equivalently \(k\le2/\sqrt{\lambda_{\max}}\) for the spatial operator (class 13); all follow from the energy method too.

Checklist

  1. Linear, modes computable (even for a carved bar): modal synthesis, exact pitch.
  2. Ideal 1D string or tube: digital waveguide, \(O(1)\) per sample.
  1. Nonlinear, coupled, or 2D/3D: finite differences (or finite elements for complex shapes).
  2. Always: monitor the discrete energy; keep \(\lambda\) or \(\mu\) near the limit.

Looking Ahead

Where These Ideas Come Back

  • Project proposals (next week): any PDE of today can model a heritage instrument or space.
  • Wave Propagation: waves spreading in 2D and 3D, reflection, absorbing boundaries, room acoustics.
  • 1D Wave Equation and Stability Analysis: von Neumann analysis and the energy method in full, beyond the explicit schemes of these two weeks (implicit schemes for bars); numerical dispersion in detail.
  • Stringed Instruments: stiff, lossy strings driven by the hammer and bow of class 13 through spreading operators; strings coupled to a soundboard (a plate).
  • Wind Instruments: tubes of varying cross section (Webster’s equation, handled like today’s carved bar) driven by a reed.

Recap

Recap on Today’s ILO

  • Stiffness: \(u_{xxxx}\) causes dispersion (\(\omega=\kappa\beta^2\)) and inharmonicity; von Neumann gives \(\mu\le\tfrac12\), so bars need only a few grid points; free ends come for free from the energy form.
  • Frequency dependent loss: \(2\sigma_1u_{txx}\) darkens the tone; set \((\sigma_0,\sigma_1)\) from two \(T_{60}\)’s; \(\delta_{t-}\) keeps it explicit.
  • Modes of any shape: the eigenproblem \(\mathbf{K}\mathbf{v}=\omega^2\mathbf{M}\mathbf{v}\) tunes a carved marimba bar; modal synthesis plus a mallet plays it.
  • 2D: membranes (\(\lambda\le1/\sqrt2\)) and plates (\(\mu\le\tfrac14\)); unknowns grow like \((f_s/\gamma)^2\).
  • Choose: modal for linear, waveguides for ideal 1D, finite differences for the rest; always watch the energy.
  • Next week: project proposals.