Why we ignore off-diagonal elements in partition function? In quantum statistical mechanics, the density operator is
$$ \rho = \exp(-\beta H_0)/Z $$
where 
$$Z = \text{Tr} (\exp(-\beta H_0)) \, .$$
Why do we take the trace over only diagonal elements and ignore off diagonal elements?
 A: First of all, we do not choose to "take the trace over only diagonal elements", but rather the trace is defined that way. Note that the trace is an invariant, just as the determinant, and hence it does not depend on the basis chosen to describe the system. It means that using a different basis, which would in general change both the diagonal and the off-diagonal terms, would result in the same partition function. If we use the basis in which the operator is diagonal, we learn that its trace is just the sum of all its eigenvalues.
Now, we know that the partition function is just the sum of the Boltzmann factor of the eigenstates of the system. There is a mathematical theorem that shows that, if $E_i$ are the eigenvalues of the matrix $A$, then the eigenvalues of the matrix $\exp(A)$ are given by $\exp(E_i)$. It derives that the eigenvalues of the $\exp(-\beta H)$ operator are linked through the same relation with the eigenvalues of $H$. Computing the partition function of $\exp(-\beta H)$ thus reduces to computing its trace, as this is exactly equal to the sum of its eigenvalues.
