Drop the sharp interface: let the refractive index vary continuously with height (hot, thin air near a sun-baked road). What does a ray do — and why does the road look wet?
▶ Launch the interactive simulationIntegrate the exact ray equation y'' = (n'/n)(1 + y'²) (RK4) for light launched gently downward through n(y) = N0 + G·y, for a fan of launch angles. Track the invariant n(y)·sinθ along each ray, mark each ray's turning point, and compare the analytic turning height y_t = (C − N0)/G with the integrated trajectory's lowest point.
SNELL-IN-LAYERS as a conservation law — across each infinitesimal layer n sinθ is unchanged, so n(y)·sinθ = C holds along the whole curving ray (verified to ~1e-12), the optical analogue of conserved horizontal momentum; the ray turns where n(y_t) = C (a total internal reflection spread over a thickness) and arcs back UP before reaching the ground — the inferior mirage, the sky refracted into your eye from below