diagonalization of the Hamiltonian use analytical method instead of lapack