Quake waves curve through a cutaway Earth, leaving the shadows that revealed its core.
An earthquake sends P and S waves through a simplified PREM Earth, with speeds rising through the mantle, dropping in the liquid outer core and rising again in the inner core. Each ray is integrated with the ray equation inside a layer and refracted or reflected at every boundary by Snell's law, and rays grazing the core are found by bisection so the shadow edges are exact. P waves bend sharply into the core and leave a gap from about 100 to 145 degrees; S waves cannot cross liquid at all, so nothing arrives past about 100 degrees, which is how seismologists learned the outer core is liquid. Wavefronts sweep outward while synthetic seismograms, built from each arrival's time and geometric spreading, are drawn station by station like a chart recorder.
Try it. Click the globe to place a quake. Switch between P waves, S waves or both, and toggle the liquid outer core and the inner core to see the Earth that might have been: a solid core lets S waves through, and with no inner core the faint arrivals Inge Lehmann found in the shadow vanish. Keys: P, S, B, L, I, the arrows and Space.
Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.
Build an interactive diagram of earthquake waves traveling through the Earth with JavaScript and the HTML canvas element. 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, stays sharp on high-DPI screens, and resizes with the window. Draw a cutaway Earth as concentric circles: crust, mantle (down to 2,891 km), liquid outer core (to 5,150 km) and inner core, in muted museum-diagram colors on a dark background.
- Give each layer a P wave speed that changes linearly with depth: mantle 8 to 13.7 km/s, outer core 8.1 to 10.4, inner core 11 to 11.3.
- From a quake at the top of the globe, launch about 150 rays at takeoff angles from straight down to horizontal. Step each ray in small increments with the ray equation: the direction turns toward the slower side in proportion to the speed gradient. When a step crosses a layer boundary, cut it at the boundary and refract with Snell's law (the component of the slowness vector along the boundary stays the same).
- Draw the rays as thin colored lines: mantle rays blue, rays through the core yellow.
Once that works, make it beautiful:
- Animate the waves: store the travel time along each ray, draw each ray only up to the current time, and connect neighboring ray tips into glowing wavefronts.
- Find where no rays reach the surface and mark the shadow zone with an arc and a label.
- Add S waves (about 55 percent of the P speed in solid rock, zero in the liquid core) and reflect them off the core, so their shadow covers the whole far side.
- Let me click anywhere on the globe to move the quake.
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 panel of synthetic seismograms recorded at stations around the globe, a toggle that makes the outer core solid, or showing the faint inner core arrivals Inge Lehmann discovered in the shadow zone.