  Lagrangian formalism for the Lagrangians homogeneous of degree two in
velocities is considered. It is shown that the reduced dynamics obtained by
neglecting one generalized coordinate is, in general, described by the Herglotz
extension of Lagrangian formalism. This result is applied to the propagation of
light in general gravitational field leading to the extended Fermat principle.
