Visual walkthrough — Snell's law — derivation from Fermat's principle
We are answering one question: a beam of light leaves point , must arrive at point , and along the way it crosses from a "fast" material into a "slow" material. Which route does it take?
Step 1 — Draw the stage and name every distance
WHAT. We place point in the top material and point in the bottom material. A flat horizontal line — the boundary — separates them. Light must start at and end at ; the only thing it gets to choose is where it crosses the boundary. Call that crossing point , and call its horizontal position .
WHY. Before we can talk about "the best path" we must be able to describe any path with a single number. That number is . Slide left and right and you generate every straight-in, kinked-out path light could take. So is the one free dial.
PICTURE. Look at the figure. The vertical drop from to the boundary is ; the vertical drop from the boundary to is ; the total horizontal gap from to is . These three (, , ) are fixed — they are set by where and sit. Only (marked in coral) is free to slide.

Step 2 — Measure the length of each leg with a right triangle
WHAT. The path has two straight pieces: in the top medium, and in the bottom medium. We need their lengths.
WHY. Light's travel time depends on how far it goes in each material (and how fast it moves there). So we must turn the geometry into two honest distances.
PICTURE. Drop a vertical line from to the boundary. It has height . The horizontal run to is . Those two sides are at a right angle, so , the foot of the vertical, and form a right triangle. The slanted path is its hypotenuse.
The bottom leg is the same idea. Its vertical drop is ; its horizontal run is whatever is left over after , namely :

Step 3 — Turn lengths into a travel time
WHAT. We convert each distance into the time light spends on it.
WHY. Fermat's principle (see Fermat's Principle) says light takes the route of least time, not least distance. So time is the thing we must build and then make as small as possible.
PICTURE. Speed in a medium is , where is light's speed in vacuum and is the refractive index (bigger = slower medium). Time is distance ÷ speed:
That product is the optical path length. Adding both legs:
- ::: the indices of the two media (how much each slows the light).
- ::: vacuum light speed — a constant, the same in both terms.
- ::: total travel time, written as a function of our one dial .

The green curve in the figure is plotted against . Notice it has a lowest point — a valley. Light lives at the bottom of that valley.
Step 4 — Find the bottom of the valley
WHAT. We locate the that makes smallest.
WHY this tool. How do you find the bottom of a smooth valley without eyeballing it? At the very bottom the curve is momentarily flat — its slope is zero. The derivative is that slope. So the machine-precise way to say "least time" is:
This is exactly the idea in Calculus — minimization and stationary points: a minimum is where the tangent line goes horizontal.
PICTURE. In the figure the tangent line to the time-curve is drawn at three places. On the left slope it tilts down, on the right it tilts up, and at the bottom it is perfectly level — that flat tangent marks the winning .

Step 5 — Actually take the derivative
WHAT. We compute term by term.
WHY the chain rule. Each leg is a square root of "(something with )". To differentiate a function-inside-a-function you peel it in layers — that is the chain rule. For the outer layer is , the inner layer is :
The bottom leg has inside; the inside's derivative is , which drags a minus sign out front:
Putting both into :

The figure shows the two competing "urges": nudging right adds time in the top leg but subtracts time in the bottom leg. Balance is where they cancel.
Step 6 — Recognise the sines hiding in the fractions
WHAT. Those two ugly fractions are secretly sines of the two angles.
WHY. In each right triangle from Step 2, define the angle from the normal (the dashed vertical line perpendicular to the boundary). Trigonometry says
For the top triangle the side opposite the angle-from-normal is the horizontal run , and the hypotenuse is . So:
- ::: angle between the incoming ray and the normal (top medium).
- ::: angle between the outgoing ray and the normal (bottom medium).
PICTURE. The figure highlights, in each triangle, the opposite side (coral) over the hypotenuse (lavender) — that ratio is the sine. These are the exact fractions from Step 5.

Step 7 — Substitute, cancel, and read the law
WHAT. Replace the fractions with the sines, then clean up.
WHY. This is the payoff: our balance equation becomes a statement purely about the two angles and the two media.
Starting from Step 5 and substituting the sines from Step 6:
Every term carries a . Since , multiply through by and it vanishes:

Step 8 — The degenerate & edge cases (nothing left unshown)
Every scenario must be covered. Here they are, each read straight off the law.
Case A — Straight-in (). If light hits head-on, , so , forcing . Light goes straight through, no bending. (Its speed still changes — only the direction is unbent.)
Case B — Same medium (). The law collapses to , so : no boundary effect, a plain straight line. This is the sanity check.
Case C — Rare → dense (). , so — bends toward the normal.
Case D — Dense → rare (). Now , so — bends away from the normal.
Case E — The breaking point (Total Internal Reflection). In Case D, as grows, climbs toward its ceiling of . The angle where (i.e. , the refracted ray skimming along the surface) is the critical angle :
Push past and the law demands , which no real angle satisfies — refraction is impossible, so all the light reflects back: Total Internal Reflection.

The one-picture summary
Everything above, compressed into a single frame: the free crossing point , the two right triangles, the time-valley with its flat bottom, and the balanced sines that become Snell's law.

Recall Feynman retelling — the whole walk in plain words
Light wants to get from to in the least time. The only choice it has is where to cross the boundary — call that spot . Slide around and the trip takes different amounts of time, because the fast material and the slow material trade off differently for each crossing point. Plot that trip-time against and you get a smooth valley. Light sits at the bottom of the valley, and the bottom of a valley is where the ground is flat — where the slope (the derivative) is zero. Working out that flatness condition, each leg of the trip contributes a fraction that is nothing but the sine of its angle-from-straight-up. Balancing the two legs gives . And that little rule quietly explains everything: head-on light doesn't bend, entering slow glass bends you toward the perpendicular, and leaning too far while leaving glass makes escape impossible so the light bounces back — total internal reflection.
Connections
- Snell's law — derivation from Fermat's principle (parent)
- Fermat's Principle
- Optical Path Length
- Refractive Index
- Calculus — minimization and stationary points
- Critical Angle
- Total Internal Reflection
- Reflection — law from Fermat's principle
- Huygens' Principle and Snell's Law