# Principle of least time

It is an experimental fact that light travels at different speeds, depending on the material it is travelling through - it's $3 \times 10^8$m/s only in a vacuum.

Fermat postulated that the path between two points taken by a light ray is the curve that minimises the total time it takes to travel between the two points. In optics, this is called the principle of least time.

We are supposing that the speed of light depends on position, $$c = c(x, y, z)$$

In principle, we can parametrize any curve in space, between two points $P, Q$ say, by the distance travelled along it, $s$, hence we can write \begin{align*}x &= x(s)\\ y &= y(s)\\ z &= z(s)\end{align*}

Also, note that we can also write the speed as $$\frac{\mathrm{d}s}{\mathrm{d}t} = c(x, y, z)$$ and so $$\mathrm{d}t = \frac{\mathrm{d}s}{c(x, y, z)}$$ which we integrate to get the total time it takes for a light ray to travel from $P$ to $Q$, $$T = \int_{P}^{Q} \frac{1}{c(x, y, z)} \mathrm{d}s$$

We would need to know what the function $c(x, y, z)$ actually is to proceed further, but we can still make the identifications for the Euler-Lagrange equations, \begin{align*}t & \to s\\ q_i & \to (x, y, z)\\ \dot{q_i} & \to (x', y', z')\\ A & \to T\\ L(q, \dot{q_i}) & \to I(x, y, z, x', y', z') = \frac{1}{c(x, y, z)}\end{align*}