Are the trace and natural logarithm interchangeable for $e^A$? In a quantum mechanics article generalized hamiltonian of particle in an infinite well with a temperature (which considered as perturbation) is as follows $$E(T) = E_{gs}(0) + k_bT \ln Tr(e^{-\beta E(0)})$$ And as a generalized question, under what conditions we can say that
$$\ln(\text{Tr}(e^A)) = \text{Tr}(\ln(e^A))$$
Thank you!
See:
https://en.wikipedia.org/wiki/Logarithm_of_a_matrix
and:
https://en.wikipedia.org/wiki/Matrix_exponential
 A: I found the condition for $A$, when one assumes that $A$ is diagonalizable matrix (note that most of the matrix from the quantum mechanical world are diagonalizable).
Consider that there is unitary operator $U$, such that $UU^\dagger = U^\dagger U=1$ and $A = U^\dagger \widetilde A\, U$, where $\widetilde A$ is diagonal matrix (made of eigenvalues)
$$ \widetilde A = \sum_i \lambda_i\, |i\rangle \langle i|. $$
I use here Dirac notation.
To calculate function of the matrix $f(A)$ one can perform the following, first diagonalize the $A$ (by solving the eigen equation $A |\psi_i\rangle = \lambda_i |\psi_i\rangle$, build matrix in eigenvector base $f(\widetilde A) = \sum_i f(\lambda_i) |i\rangle \langle i|$, and then back to original basis if required $f(A) = U f(\widetilde A) U^\dagger$.
Let's do the trick for the question equation
$$
\ln \text{Tr}\, U^\dagger\left(\sum_i \exp(\lambda_i) |i\rangle \langle i|\right) U= \text{Tr}\, U^\dagger\left(\sum_i \lambda_i |i\rangle \langle i|\right) U,$$
then using the trace cyclic property, namely $\text{Tr}\,(ABC) = \text{Tr}\,(CAB) = \text{Tr}\,(BCA)$, and unitary property $UU^\dagger = 1$
$$
\ln \text{Tr}\, \left(\sum_i \exp(\lambda_i) |i\rangle \langle i|\right) = \text{Tr}\,\left(\sum_i \lambda_i |i\rangle \langle i|\right),$$
Then after the summation, which is included in the trace
$$
\ln \sum_i \text e^{\lambda_i} = \sum_i \lambda_i
$$
One ends with
$$
\boxed{\sum_i \text e^{\lambda_i} = \prod_i \text e^{\lambda_i}}
$$
To summarize if matrix $A$ is diagonalizable, and sum and product of exponential of the eigenvalues are equal, then trace and logarithm of the matrix $A$ is interchangeable.
