where the first term is the generalized Brillouin condition with the orbital gradient A - the second term is the requirement for MO orthonormalization with the overlap matrix S in the MO basis, and the third term is the CI condition. In the third term, N state is the number of (equally) averaged states and E ref γ is the CASSCF energy for state γ ∈ P.