
The law of reflection and the law of refraction tell us how light waves behave at the boundary between two media with different indices of refraction. In 1650, Fermat discovered a way to explain reflection and refraction as the consequence of one single principle. It is called the principle of least time or Fermat's principle.
Assume we want light to get from point A to point B, subject to some boundary conditions. For example, we want the light to bounce off a mirror or to pass through a piece of glass on its way from A to B. Fermat's principle states that of all the possible paths the light might take, that satisfy those boundary conditions, light takes the path which requires the shortest time.

Consider the diagram above. We want light to leave point A, bounce off the mirror, and get to point B. Let the perpendicular distance from the mirror of both A and B be d and the shortest distance between the points be D. Assume that light takes the path shown. The length of this path is
L = (x2+d2)1/2 + ((D-x)2+d2)1/2.
Since the speed of light is the same everywhere along all possible paths, the shortest path requires the shortest time. To find the shortest path, we differentiate L with respect to x and set the result equal to zero. (This yields an extremum in the function L(x).)
.
![]()
![]()
After canceling equal terms on both sides we are left with
d2D2 = 2Dx, or x = D/2.
The path that takes the shortest time is the one for which x = D/2, or equivalently, the one for which qi = qr. Fermat's principle yields the law of reflection.
![]()
Now assume we want light to propagate from point A to point B across the boundary between medium 1 and medium 2.

For the path shown in the figure above the time required is
.
Setting dt/dx = 0 we obtain
,
or
n1sinq1 = n2sinq2.
Fermat's principle yields Snell's law.
Links:
| Fermat's principle | |
| The fastest path |