Hamilton's equations can be derived by a calculation with the Lagrangian ⁠ L ⁠, generalized positions q, and generalized velocities ⋅ q, where ⁠ i = 1 , … … , n ⁠. Here we work off-shell, meaning ⁠ q i ⁠, ⁠ q ˙ ˙ i ⁠, ⁠ t ⁠ are independent coordinates in phase space, not constrained to follow any equations of motion (in particular, q ˙ ˙ i is not a derivative of ⁠ q i ⁠). The total differential of the Lagrangian is: d L = ∑ ∑ i ( ∂ ∂ L ∂ ∂ q i d q i + ∂ ∂ L ∂ ∂ q ˙ ˙ i d q ˙ ˙ i ) + ∂ ∂ L ∂ ∂ t d t . The generalized momentum coordinates were defined as ⁠ p i = ∂ ∂ L / ∂ ∂ q ˙ ˙ i ⁠, so we may rewrite the equation as: d L = ∑ ∑ i ( ∂ ∂ L ∂ ∂ q i d q i + p i d q ˙ ˙ i ) + ∂ ∂ L ∂ ∂ t d t = ∑ ∑ i ( ∂ ∂ L ∂ ∂ q i d q i + d ( p i q ˙ ˙ i ) − − q ˙ ˙ i d p i ) + ∂ ∂ L ∂ ∂ t d t .