Alternating minimization stuff