hamiltonian and lagrangian dynamics notes 6939509