The general action identity is
Treating as independent and comparing coefficients gives
Choose a complete integral of the Hamilton-Jacobi equation,
Then , and Hamilton's equations become . Completeness and local invertibility are needed: a solution with too few independent parameters cannot generate an arbitrary trajectory.