Stable numerical algorithms for equilibrium systems