Hamiltonian formalism for general variational problems | Synapse