Hamiltonians representing equations of motion with damping due to friction