Fermat's principle explains why light rays traveling between air and water undergo bending {refraction). Imagine that we have two uniform media (such as air and water) and a light ray traveling from a source A in one medium to an observer B in the other medium (see the figure below). It is known that light travels at a constant speed in a uniform medium, but more slowly in a dense medium (such as water) than in a thin medium (such as air).
Consequently, the path of shortest time from A to B is not
necessarily a straight line, but rather some broken line path
A to P to B allowing the light to take greatest advantage of
its higher speed through the thin medium. Snell's law of
refraction states that the path of the light ray will be such
that
Show that this follows from the assumption that the path of minimum time occurs when dt/dx = 0.