A lifeguard on the sand spots a swimmer in trouble. The straight line to the swimmer is the shortest distance, but it is not the fastest route. The lifeguard runs far faster than anyone can swim, so it pays to run a little further along the beach and spend less time in the water. Light faces the same puzzle every time it enters water or glass, and it solves it the same way.

Try it: find the fastest route

Drag the orange dot along the shoreline, or tap a spot on it. The lifeguard runs to that point, then swims straight to the swimmer. The curve underneath shows the total time for every possible entry point.

SAND · run fast WATER · swim slow lifeguard swimmer
Your time–
Fastest possible–
Straight line–
sin θ₁ ÷ run speed–
sin θ₂ ÷ swim speed–

Running speed is fixed at 7 m/s. Dotted grey: the straight line. Dotted green: the fastest route.

total time ↑ entry point along the shore →

Look at the bottom of the curve: it is flat. Near the best point, moving a metre either way costs almost nothing. That flatness matters in a minute.

What you just found

With the default speeds, the fastest route is not the straight line. It bends at the shore, with a steeper angle in the water than on the sand. If you slow the swimmer further, the best entry point slides toward the swimmer. If you set the two speeds equal, the best route becomes the straight line, because there is no reason to favour either side.

At the lowest point, the two readouts sin θ₁ ÷ run speed and sin θ₂ ÷ swim speed are equal. Each angle θ is measured from the vertical dashed line, the normal to the shore. That equality is the whole rule:

sin θ₁ / v₁ = sin θ₂ / v₂

The same rule runs light

Light travels fastest in a vacuum, at about 299,792 km/s. In any material it goes slower. The refractive index n tells you by how much: light's speed in a material is the vacuum speed divided by n. Water has n of about 1.33, so light in water moves at roughly three quarters of its top speed, near 225,000 km/s. Ordinary glass has n of about 1.5, and diamond about 2.4.

Replace speeds with 1/n in the rule above and it becomes Snell's law: n₁ sin θ₁ = n₂ sin θ₂. That is the law that tells an optician how a lens bends light, and the reason a straw looks bent where it enters a glass of water. Press the “light in air → water” button to try it: the speeds drop to the ratio 1 to 0.75 and the bend at the shore shrinks to the gentle kink that real light makes.

In 1662 the French mathematician Pierre de Fermat stated this as a principle: light travels between two points along the path that takes the least time. The lifeguard is a teaching picture for it, not something light literally does, but the mathematics is identical.

How does light know?

A ray cannot scout ahead and compare routes. The deeper answer is that light is a wave, and a wave does try every route. Every path from A to B contributes a little wave, and what you see is the sum of them all.

This is why the flat bottom of the curve matters. Away from the best path, a small change in route changes the travel time a lot, so neighbouring waves arrive out of step and cancel one another. Near the best path, neighbours take almost the same time, so their waves arrive together and add up. The path of least time is simply where the waves agree. Physicists later made this the core of quantum mechanics, in Richard Feynman's sum over paths.

One small correction to the slogan: strictly speaking, light takes the path whose time is stationary, meaning the curve is flat there. Almost always that is a minimum. In a few curved-mirror set-ups it is a maximum, which is why the textbook version says “extremal” time.

Takeaway

Nature often finds the best compromise without planning. Whenever the speed changes at a boundary, the quickest route bends, and light, sound, and a lifeguard on a beach all obey the same rule.