Fermat’s principle of least time can be roughly stated as, *“The path taken
between two points by a ray of light is the path that can be traversed in the
least time”* (From Wikipedia). Fermat used this observation to derive the
laws of reflection and refraction of light.

## Reflection of light

The law of reflection of light states that the angle at which a ray is incident
on a reflective surface is equal to the angle at which it is reflected from the
surface. In other words, in the following diagram (light travels from $A$
to $O$ to $B$), ${\theta}_i = {\theta}_r$.

Let’s try to derive this law from Fermat’s principle. The total distance that
the ray of light has to travel from $A$ to $B$ with
one reflection at $O$ is

$
L = \overline{AO} + \overline{OB}
$

$
= \sqrt{a^2 + x^2} + \sqrt{b^2 + {\left( l - x \right)}^2}
$

Now since the speed of light is constant, minimizing the time taken by light to
take the path $AOB$ is equivalent to minimizing the path itself.
To do this, we set $\frac{dL}{dx} = 0$.

$
\frac{dL}{dx} = 0
$

$
\implies \frac{d}{dx} \left( \sqrt{a^2 + x^2} + \sqrt{b^2 + {\left( l - x \right)}^2} \right) = 0
$

$
\implies \frac{2x}{2\sqrt{a^2 + x^2}} +
\frac{2 \left( l - x \right) \left( -1 \right)}{2\sqrt{b^2 + {\left( l - x \right)}^2}} = 0
$

$
\implies \frac{x}{\sqrt{a^2 + x^2}} =
\frac{\left( l - x \right)}{\sqrt{b^2 + {\left( l - x \right)}^2}}
$

$
\implies \sin{ {\theta}_i } = \sin{ {\theta}_r }
$

$
\implies {\theta}_i = {\theta}_r \, \blacksquare
$

$
$

## Refraction

The law of refraction of light, or Snell’s Law states that the ratio of
the sines of the angles of incidence and refraction is equal to the inverse
ratio of the indices of refraction of the two media.

With reference to the image above, Snell’s Law can be mathematically stated as,

$
\frac{\sin {\theta}_i }{\sin {\theta}_r } = \frac{n_2}{n_1}
$

Now to prove this using Fermat’s principle.

We know that,

$
\text{index of refraction of a medium} = \frac{ \text{speed of light in vacuum} }{ \text{speed of light in the medium} }$

Let the speeds of light in our media be $v_1 = \frac{c}{n_1}$ and
$v_2 = \frac{c}{n_2}$. Now the total time taken by light to
travel from $A$ to $B$ with a refraction at
$O$ is

$ t = \frac{ \overline{AO} }{v_1} + \frac{ \overline{OB} }{v_2} $

$ = \frac{ \overline{AO} \times n_1 }{c} + \frac{ \overline{OB} \times n_2 }{c} $

$ = \frac{ n_1 \sqrt{ a^2 + x^2 } }{c} + \frac{ n_2 \sqrt{ b^2 + {\left( d - x \right) }^2 } }{c} $

To minimize $t$, we’ll set $\frac{dt}{dx} = 0$

$ \frac{d}{dx} \left( \frac{ n_1 \sqrt{ a^2 + x^2 } }{c} + \frac{ n_2 \sqrt{ b^2 + {\left( d - x \right) }^2 } }{c} \right) = 0$

$
\implies \frac{1}{c} \frac{d}{dx} \left( { n_1 \sqrt{ a^2 + x^2 } } + { n_2 \sqrt{ b^2 + {\left( d - x \right) }^2 } } \right) = 0
$

$
\implies \frac{2 x n_1}{ 2 \sqrt{ a^2 + x^2 } } + \frac{ 2 \left( d - x \right) n_2 \left( -1 \right) }{ 2 \sqrt{ b^2 + {\left( d - x \right) }^2 } } = 0
$

$
\implies n_1 \frac{x}{ \sqrt{ a^2 + x^2 } } = n_2 \frac{ \left( d - x \right) }{ \sqrt{ b^2 + {\left( d - x \right) }^2 } }
$

$
\implies n_1 \sin {\theta}_i = n_2 \sin {\theta}_r
$

$
\implies \frac{\sin {\theta}_i }{\sin {\theta}_r } = \frac{n_2}{n_1} \, \blacksquare
$