The Hamilton–Jacobi equation provides yet another formulation of classical mechanics, one which makes it mathematically analogous to wave optics. This formulation also uses Hamiltonian functions, but in a different way than the formulation described above. The paths taken by bodies or collections of bodies are deduced from a function S ( q 1 , q 2 , … … , t ) of positions q i and time t . The Hamiltonian is incorporated into the Hamilton–Jacobi equation, a differential equation for S . Bodies move over time in such a way that their trajectories are perpendicular to the surfaces of constant S , analogously to how a light ray propagates in the direction perpendicular to its wavefront. This is simplest to express for the case of a single point mass, in which S is a function S ( q , t ) , and the point mass moves in the direction along which S changes most steeply. In other words, the momentum of the point mass is the gradient of S : v = 1 m ∇ ∇ S . The Hamilton–Jacobi equation for a point mass is − − ∂ ∂ S ∂ ∂ t = H ( q , ∇ ∇ S , t ) . The relation to Newton's laws can be seen by considering a point mass moving in a time-independent potential V ( q ) , in which case the Hamilton–Jacobi equation becomes − − ∂ ∂ S ∂ ∂ t = 1 2 m ( ∇ ∇ S ) 2 + V ( q ) . Taking the gradient of both sides, this becomes − − ∇ ∇ ∂ ∂ S ∂ ∂ t = 1 2 m ∇ ∇ ( ∇ ∇ S ) 2 + ∇ ∇ V . Interchanging the order of the partial derivatives on the left-hand side, and using the power and chain rules on the first term on the right-hand side, − − ∂ ∂ ∂ ∂ t ∇ ∇ S = 1 m ( ∇ ∇ S ⋅ ⋅ ∇ ∇ ) ∇ ∇ S + ∇ ∇ V . Gathering together the terms that depend upon the gradient of S , [ ∂ ∂ ∂ ∂ t + 1 m ( ∇ ∇ S ⋅ ⋅ ∇ ∇ ) ] ∇ ∇ S = − − ∇ ∇ V . This is another re-expression of Newton's second law. The expression in brackets is a total or material derivative as mentioned above, in which the first term indicates how the function being differentiated changes over time at a fixed location, and the second term captures how a moving particle will see different values of that function as it travels from place to place: [ ∂ ∂ ∂ ∂ t + 1 m ( ∇ ∇ S ⋅ ⋅ ∇ ∇ ) ] = [ ∂ ∂ ∂ ∂ t + v ⋅ ⋅ ∇ ∇ ] = d d t .