A storm swell where walls of water rise from nowhere through nonlinear focusing.
The wave groups obey the nonlinear Schrodinger equation for deep water, solved by split-step Fourier on a periodic 5.8 km stretch of sea: dispersion is exact in Fourier space and the cubic term is an exact phase rotation. That cubic term makes even wave trains unstable (the Benjamin-Feir instability), pulling energy into short bursts like the Peregrine breather, which rises to three times its background and vanishes again. The surface adds a second-order Stokes correction and is ray-marched column by column from a camera that rides the swell with the groups, heights drawn 2.2 times taller than life, shaded with Fresnel sky reflection, translucent crests, whitecaps and haze. The panel tracks the envelope along the whole stretch and compares the measured chance of each wave height with the Rayleigh law of a linear sea. The groups evolve about four times faster than the crests, so a focusing event that takes minutes at sea plays out in seconds.
Try it. Click the sea to plant a Peregrine breather at that distance. Drag the sliders to change the significant wave height and the strength of the nonlinearity (zero gives a purely linear sea). Click the view, then use the up and down arrows for the sea state, N to switch the nonlinearity off and on, space for a breather and R for a new random sea.
Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.
Build a rogue wave simulator with JavaScript and the HTML canvas element, showing how a giant wave can grow out of an ordinary sea through nonlinear focusing. 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.
- Use the focusing nonlinear Schrodinger equation in dimensionless form, i A_t + 0.5 A_xx + |A|^2 A = 0, for the envelope A(x, t) of a wave group on a periodic domain of 1024 points. Write a small radix-2 FFT and solve it by split-step Fourier: half a step of the nonlinear phase rotation A *= exp(i |A|^2 dt / 2), a full linear step in Fourier space multiplying each mode by exp(-i k^2 dt / 2), then the other nonlinear half step.
- Start from a uniform wave train with a little random noise and watch the modulational instability break it into tall, short bursts.
- Draw the sea side on: the surface is Re(A exp(i (k0 x - omega0 t))) with a carrier of about ten wavelengths across the screen, filled with a deep blue gradient below a grey sky.
Once that works, make it beautiful:
- Add the Peregrine breather, A = [1 - 4 (1 + 2 i t) / (1 + 4 x^2 + 4 t^2)] exp(i t), started at t = -2 so a wave three times taller than its neighbours rises out of nowhere and sinks back.
- Make the water look real rather than neon: a lighter, slightly green tint where crests are tall and thin, foam on breaking crests, and a hazy horizon.
- Count wave heights across the domain and plot the chance of exceeding each height on a log scale next to the Rayleigh curve exp(-2 h^2), with a slider for the strength of the nonlinearity.
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 random JONSWAP sea, a 3D ray-marched view from a ship, or the higher-order Dysthe equation.