The variational QED-CASCI problem in the photon number or coherent state representation formally involves building and diagonalizing the matrix representation of Eq. 1 or Eq. 5, respectively, in the basis of states shown in Eq. 7. The CI matrix in both representations with a maximum photon occupation of N p will read: