Functions of perturbed noncommuting self-adjoint operators