In the geometrical optic limit, light rays can be seen as characteristics of the solutions of the eikonal equation:
$$|\nabla L|^2=n^2(x)$$
where $n(x)=c/v(x)$ is the refraction index.
On the other hand some texts (for instance Analytical mechanics, by Fasano & Marmi; and Methods of mathematical physics, II by Hilbert and Courant) say that eikonal equations are Hamilton-Jacobi equations. As such, I presume, there should be a Hamiltonian or Lagrangian to start with. Can the eikonal equation be derived as a Hamilton-Jacobi equation starting from the Lagrangian of the optical path length $$n(x) \mathrm{d}s~?$$