Solitary waves in a canal pass through each other unchanged, drawn as a Victorian plate.
Shallow canal waves follow the Korteweg-de Vries equation, u_t + 6 u u_x + u_xxx = 0, solved here pseudo-spectrally on 512 points: the dispersive term is integrated exactly with an integrating factor and the nonlinear term with fourth-order Runge-Kutta, while a sponge at the end of the periodic canal swallows departing waves. Steepening and dispersion balance in sech-squared solitons whose speed is twice their height, so taller waves catch shorter ones, pass through them and emerge ahead, each shifted along. Any heap of water breaks into solitons sorted by height plus a dispersive tail, and inverse scattering theory predicts their heights in advance, which the annotations quote. Fig. 2 stacks past profiles with hidden lines removed, a spacetime plot in which every collision leaves a jog in the tracks.
Try it. Tap the water to raise a heap: the higher above the still surface you tap, the taller it is, and a tap deep in the water makes a hollow that only spreads into ripples. Click the canal and press 1 to 4 for a heap that splits into exactly that many solitons, space for the wave maker, or C to calm the canal.
Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.
Build a soliton simulator with JavaScript and the HTML canvas element, showing solitary water waves that pass through each other and come out unchanged. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.
Start simple:
- Make a canvas that fills the window and stays sharp on high-DPI screens.
- Solve the Korteweg-de Vries equation u_t + 6 u u_x + u_xxx = 0 on a periodic domain of length about 80 with 512 points. Write a small radix-2 FFT and use the pseudo-spectral method: compute derivatives in Fourier space, integrate the stiff u_xxx term exactly with the integrating factor exp(i k^3 t), and step the rest with classical fourth-order Runge-Kutta (Trefethen's program 27 in Spectral Methods in MATLAB is the model).
- Start with two solitons u = (c / 2) sech^2(sqrt(c) / 2 (x - x0)), a tall one behind a short one. The tall one is faster, catches up, and both emerge with their shapes intact.
- Draw the surface as a line over a water-filled region.
Once that works, make it beautiful:
- Style it as a Victorian engraving: a cream paper background, the water filled with horizontal hatched lines, a heavy ink outline for the surface, and a serif caption underneath.
- Below the canal, draw a waterfall plot: every few steps save the profile and stack the saved lines upward, filling under each newer line with the paper color so it hides the older lines behind it. Each soliton leaves a straight track, and every collision leaves a visible jog, the phase shift.
- Let a click raise a heap of water at that spot. A heap A sech^2(x / w) splits into solitons sorted by height, exactly s of them when A w^2 = s (s + 1).
Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as a sponge layer so waves leave the canal, an inverse scattering prediction of the soliton heights, or comparing KdV with the dispersionless equation that breaks.