frequency calculation in the diagonal