If x, y, z are Cartesian coordinates and an overdot denotes differentiation with respect to s, Fermat's principle (2) may be written δ δ S = δ δ ∫ ∫ A B n r d x 2 + d y 2 + d z 2 = δ δ ∫ ∫ A B n r x ˙ ˙ 2 + y ˙ ˙ 2 + z ˙ ˙ 2 d s = 0 . In the case of an isotropic medium, we may replace n r with the normal refractive index n (x, y, z), which is simply a scalar field. If we then define the optical Lagrangian as L ( x , y , z , x ˙ ˙ , y ˙ ˙ , z ˙ ˙ ) = n ( x , y , z ) x ˙ ˙ 2 + y ˙ ˙ 2 + z ˙ ˙ 2 , Fermat's principle becomes δ δ S = δ δ ∫ ∫ A B L ( x , y , z , x ˙ ˙ , y ˙ ˙ , z ˙ ˙ ) d s = 0 . If the direction of propagation is always such that we can use z instead of s as the parameter of the path (and the overdot to denote differentiation w.r.t. z instead of s), the optical Lagrangian can instead be written L ( x ( z ) , y ( z ) , x ˙ ˙ ( z ) , y ˙ ˙ ( z ) , z ) = n ( x , y , z ) 1 + x ˙ ˙ 2 + y ˙ ˙ 2 , so that Fermat's principle becomes δ δ S = δ δ ∫ ∫ A B L ( x ( z ) , y ( z ) , x ˙ ˙ ( z ) , y ˙ ˙ ( z ) , z ) d z = 0. This has the form of Hamilton's principle in classical mechanics, except that the time dimension is missing: the third spatial coordinate in optics takes the role of time in mechanics. The optical Lagrangian is the function which, when integrated w.r.t. the parameter of the path, yields the OPL; it is the foundation of Lagrangian and Hamiltonian optics.