  We derive an equality for non-equilibrium statistical mechanics in
finite-dimensional quantum systems. The equality concerns the worst-case work
output of a time-dependent Hamiltonian protocol in the presence of a Markovian
heat bath. It has has the form "worst-case work = penalty - optimum". The
equality holds for all rates of changing the Hamiltonian and can be used to
derive the optimum by setting the penalty to 0. The optimum term contains the
max entropy of the initial state, rather than the von Neumann entropy, thus
recovering recent results from single-shot statistical mechanics. Energy
coherences can arise during the protocol but are assumed not to be present
initially. We apply the equality to an electron box.
