Module 2: Hamiltonian Vector Fields & Symplectic Integrators

Interactive WebGL2 Ping-Pong Advection & 48 kHz Shadow-Hamiltonian Audio Lab — midi-sink (libsumi + Suzu)
i_{X_H}ω = dH  |  ℒ_{X_H}ω = 0  |  det J = 1

Part 1: Shader Lab — Ping-Pong Phase-Space Advection & Liouville Area Invariance Click canvas to place initial ensemble (q₀, p₀)

Two alternating WebGL2 RGBA32F framebuffers advect a circular phase-space ensemble under the nonlinear pendulum H(q, p) = ½p² − cos(q) (or libsumi's Taylor–Green chladni_fs / Kirchhoff vortex braid). Compare 2nd-order Symplectic Störmer–Verlet (which stretches the disc into a razor-thin whorl of invariant pixel area) against 4th-order Runge–Kutta (RK4) and Euler, and compare libsumi's cumulative displacement re-basing d'(P) = d(P_src) + (P_src − P) against direct density resampling.

Scheme: Störmer–Verlet (2nd-Order Symplectic) Re-Based Area A(t)/A₀: 100.0% Eulerian Density Area: 100.0% mean |det J − 1|: 0.0000 Steps: 0 (t = 0.00)
Why two things are tested here:
1. Symplectic vs. RK4/Euler: Under Forward/Backward Euler (or RK4 at larger h), det J ≠ 1 causes even the exact Lagrangian re-based blob area A(t)/A₀ to blow up or shrink.
2. Re-Basing vs. Direct Density: Even when Störmer–Verlet keeps det J = 1, switching to Direct Eulerian Density Ping-Pong blurs the thin spiral filament away via bilinear texture diffusion!

Part 2: Sound Lab — Audifying Symplectic Shadow Hamiltonians at 48 kHz Oscillator in Left Ear + Reference Energy-Pitch Drone in Right Ear (or Stereo Mix)

We integrate a fast physical oscillator at audio rate (48 kHz) while mapping the instantaneous energy H(q(t), p(t)) (or the exact shadow Hamiltonian H̃(q(t), p(t))) to the pitch of a reference drone: f_drone = f_ref · 2^(γ · (E − E₀)/E₀). Hear Forward Euler glissando upward into the breaker, Backward Euler spiral downward into silence, RK4 sag flat, and Symplectic Leapfrog / Störmer–Verlet lock the pitch indefinitely.

Phase Portrait (q, p) vs. Shadow Ellipse H̃ det J = 1.000000
Energy Strip: True H(t)/H₀ (Gold) vs. Shadow H̃(t)/H̃₀ (Cyan) ΔH̃: +0.0000 dB
Audio: Stopped Drone Pitch Offset: +0.0 cents H(t)/H₀: 1.0000 | H̃(t)/H̃₀: 1.0000 Lab breaker (+14 dB, the lab's own): OK
Listening Guide:
• With Magic Circle or Störmer–Verlet at high ε ≈ 0.9, notice how the gold curve H(t) breathes inside a tight band while the cyan shadow Hamiltonian H̃(t) stays dead flat!
• Click [RED] Fwd Euler to hear the reference drone scream upward in pitch before the safety breaker catches it, or [RED] Bwd Euler to hear it spiral downward into silence.