From the laws of reflection & refraction to variational principles

Magenta text and ⬤ are draggable elements

The laws of reflection and refraction of light are at the origin of the variational principles.
These variational principles explain that physical laws are built considering a physical quantity (action, entropy...) should be extremum (minimum, maximum - I don't know examples of saddle points) during the transformation between two states.
Variational principles can be applied to all fields of the physics : geometrical optics (see P. Fermat and below), classical mechanics (L. Euler, J.-L. Lagrange, P. L. M. Maupertuis, W. R. Hamilton), elctromagnetism, quantum mechanics (see e.g. R. P. Feynman)...

Reflection: the least path principle

The first known demonstration of the law of reflection in geometrical optics is due to Hero of Alexandria, who lived during the first century. His geometrical demonstration is based on a least path principle.
H denotes the projection of a source point A on an interface plane and H' the projection on the interface plane of a point B on the path of the reflected. O is the position of the reflection at the interface (⬤). The shortest path from A to B including a reflection on the interface is such that :
- the reflected ray of light (or sound) is in the same plane than the incident ray (i.e. the screen plane containing AOH and AOH'),
- for non-oriented angles :
$\definecolor{theta_1}{RGB}{0,188,212}
\textcolor{theta_1}{\theta_1} = \definecolor{theta_2}{RGB}{13,71,161}
\textcolor{theta_2}{\theta_2}$
or $\definecolor{theta_1}{RGB}{0,188,212}
\textcolor{theta_1}{\theta_1} - \definecolor{theta_2}{RGB}{13,71,161}
\textcolor{theta_2}{\theta_2} = 0$.
If A' denotes the image source of A with respect to the interface, A'B is thus a straight line.
Check by yourself below.

Drag ⬤ to modify the path between point A and point B.
The path length between A and B is pixels
$\definecolor{theta_1}{RGB}{0,188,212}
\textcolor{theta_1}{\theta_1} - \definecolor{theta_2}{RGB}{13,71,161}
\textcolor{theta_2}{\theta_2} =$ deg.

Notice that, assuming the celerity of light (or sound) is constant in the medium, this least path obviously corresponds to the fastest path, including a reflection, between A and B.

Refraction: moving to the least time principle

Experimentally, it is clear that light does not follow the least path principle (a straight line) when it propagates from one medium (e.g. air) to another one (e.g. water or glass).

The first written document where a graphical construction of the law of refraction is reported is probably the manuscript by Ibn Sahl (c. 940 - c. 1000) discussing how lenses modify light rays. However, the refraction law is also known as the Snell-Descartes law after the independent works by Willebrord Snel von Roijen (aka Willebrord Snellius / Snell) (1580-1626) and René Descartes (1596-1650).
The tentative demonstration proposed by R. Descartes of the law (in his current form : $n_1 \sin \definecolor{theta_1}{RGB}{0,188,212}
\textcolor{theta_1}{\theta_1} = n_2 \sin \definecolor{theta_2}{RGB}{13,71,161}
\textcolor{theta_2}{\theta_2}$) is based on an analogy between the propagation of light and the propagation of a projectile or a mechanical vibration in different media. This work, done at a time when the nature of light was far from being known, was not considered as a rigorous demonstration by various of his contemporaries. Pierre de Fermat (c. 1607 - 1665) was one of these unconvinced contemporaries (partly because Descartes assumed that the celerity of light increases with the density of the medium it propagates throughout).
P. Fermat decided to find a proof of the refraction law based on a different reasoning compared to Descartes. His work, a first approach of what will become the differential calculus, ended up with a "principle of natural economy" or a "least travel time principle" (which will become the "principle of least action" or, as known today : the "principle of stationary action").

n_{1} = 1.0n_{2} =

Drag ⬤ to modify the path between point A and point B.
Click & drag the value of n_{2} to change the refraction index of the bottom medium. The travel time from A to B is seconds
(assuming the celerity of waves in medium 1, where n_{1}=1, is 1 pixel / second) n_{1} sin $\definecolor{theta_1}{RGB}{0,188,212}
\textcolor{theta_1}{\theta_1}$ - n_{2} sin $\definecolor{theta_2}{RGB}{13,71,161}
\textcolor{theta_2}{\theta_2}$ =

Below is a demonstration using differential calculus which was developed later than Snell, Descartes or Fermat works, by Newton and Leibniz.

H and H' are defined as the projections of A and B on the interface.
HH' is denoted by $l$.
AH is denoted by $h$ and BH' by $h'$
HO is denoted by $x$ (O is the position of ⬤).

Using Pythagoras theorem, one can writes :
\[
\begin{align}
AO^2 &= h^2+x^2 \\
OB^2 &= h'^2 + (l-x)^2
\end{align}
\]
The time duration required for a wave to travel from point A to point B is then :
\[
t = \frac{1}{c}\left(n_1 \sqrt{h^2+x^2} + n_2 \sqrt{h'^2+(l-x)^2}\right)
\]
$t$ is extremum (minimum, maximum or a saddle point) when $\partial t/\partial x = 0$.

Noting that :
\[
\begin{align}
\sin \theta_1 &= \frac{\displaystyle x}{\sqrt{h^2+x^2}} \\
\sin \theta_2 &= \frac{\displaystyle (l-x)}{\sqrt{h'^2 + (l-x)^2}}
\end{align}
\]
$\partial t/\partial x = 0$ can be written as :
\[
n_1 \sin \theta_1 = n_2 \sin \theta_2
\]
or :
\[
n_1 \sin \theta_1 - n_2 \sin \theta_2 = 0
\]

This condition corresponds to a minimum time duration for the wave travel ($\partial^2 t/\partial x^2 \gt 0$).

n1n2n_{1} = n_{2} =

Change the values of the refraction indices n in this Descartes' construction to see what's going on. You will see that for some values of $n_1$ and $n_2$, $n_2$ being lower than $n_1$, no refraction can occurs, only reflection is possible.

Multiple refractions : towards the principle of stationary action

The value of the reflection index $n$ of a medium also depends on the temperature of this medium. For example, the reflection index of "hot" air differs from the one of "lukewarm" or "cold" air creating refraction between "hot", "lukewarm" and "cold" air.
Due to these multiple refractions inside a medium, light propagates along curved paths creating mirages (cf. images below where only a few different refraction indices are reported for the sake of clarity).

The time $dt$ required by the light to go from a point of coordinates $(x, z)$, $x$ being a latitude or longitude and $s$ being the elevation, to a point of coordinates $(x+dx, z+dz)$ with a refraction which only depends on the elevation $z$ is :

The time required by the light to travel from $A$ to $B$ through multiple media (or one medium like air but with multiple temperature layers) is thus ($\dot{z}(x)$ denoting $dz(x) / dx$) :

\[
T = \frac{1}{c} \int_A^B n(z) \sqrt{1+\dot{z}(x)} \ dx
\]

with initial and final conditions as $z(x=x_0)=z_0$ and $z(x=x_1)=z_1$.

On the other hand, the variational calculus by Euler-Lagrange for one variable $x$ consists in finding the function(s) $z(x)$ for which integral $I$ (a function of function(s) i.e. a functional) is extremal ($\delta I = 0$)

\[
I = \int_A^B \mathcal{L} \Big(\dot{z}(x),z(x),x\Big) dx
\]

where $\mathcal{L}$ is a known function called the Lagrangian.
$A$ and $B$ are known endpoints and $\dot{z}(x) = dz(x)/dx$
This problem is exactly the one discussed above for multiple refractions.

Searching for $\delta I = 0$ for all infinitesimal variation of $\delta z$ (with $\delta z(A)=\delta z(B)=0$), implies, after an integration by parts :