derive Hamilton's equation of motion