Necessary and sufficient condition for $\text{tr}\log(A+iB)+\text{tr}\log(A-iB)$ to be real? Assume $A$ and $B$ are square matrices which allow $\log(A+iB)$ and $\log(A-iB)$ to be well defined. What are the necessary and sufficient conditions on $A$ and $B$ to make the aforementioned trace to be real valued?
Edit: A sufficient condition is that $A$ and $B$ are self-adjoint and commute, with $A$ being positive definite, since then $A+iB$ is a normal matrix. Hence, if $A+iB$ has an eigenvalue $\lambda_n$, $A-iB$ has an eigenvalue $\lambda_n^*$. Hence the trace expression is
$$\text{tr}\log(A+iB)+\text{tr}\log(A-iB)=\sum_n\log(|\lambda_n|^2)\in\mathbb{R}$$
$A$ being positive definite is to avoid any potential branch cut issues with the logarithm. I am trying to understand whether this is also a necessary condition, or if there are some less restrictive properties of $A$ and $B$ which allow the trace in question to be real.
 A: Assume that $\Vert A+iB - I\Vert <1$ and $\Vert A-iB - I\Vert 
<1$, which is the common condition for the corresponding matrix logarithms to be defined (see Thm 2.8 in Hall, Lie Groups, Lie Algebras, and Representations, 2015).  Then, it is the case that (Thm 2.8 in Hall):
$$\exp({\ln (A+iB)}) = A+iB,\qquad \exp({\ln (A-iB)}) = A-iB \tag{1} $$
We will also use that for all matrices $X$ (Thm 2.12 in Hall):
$$\det(\exp(X)) = \exp({\mathrm{tr} X})\tag{2}$$
Finally, we will use that $\det X \det Y =\det XY$ for all matrices $X$ and $Y$. We write $^*$ for complex conjugate and $^\dagger$ for conjugate transpose.
Combining $(1)$ and $(2)$ implies
\begin{align}
&\exp[{\mathrm{tr} \ln (A+iB) + \mathrm{tr} \ln (A-iB))}] \\
&=\exp[{\mathrm{tr} \ln (A+iB) ]\exp[\mathrm{tr} \ln (A-iB))}] \\
&= \det[\exp({\ln (A+iB)}) ]\det[\exp({\ln (A-iB)) }]\\
&= \det(A+iB)\det (A-iB)\\
&= \det((A+iB)(A-iB))
\end{align}
It is clear that ${\mathrm{tr} \ln (A+iB) + \mathrm{tr} \ln (A-iB))}$ is real if and only if $$\det((A+iB)(A-iB))=\det(A^2 +i(BA-AB)+B^2)$$ is real and strictly positive.  Some simple sufficient conditions for this to be the case:

*

*If $A$ and $B$ are real-valued, then $A+iB=(A-iB)^*$, so $$\det(A-iB)=\det((A+iB)^*)=(\det(A+iB))^*$$
and therefore $\det(A+iB)\det(A-iB)=\vert \det(A+iB)\vert^2$.


*If $A$ and $B$ are self-adjoint, then $A^\dagger=A$ and $(iB)^\dagger=-iB$ (since $iB$ is skew-adjoint), so
$$\det(A-iB)=\det(A^\dagger+(iB)^\dagger)=\det((A+iB)^\dagger)=(\det(A+iB))^*$$
and therefore $\det(A+iB)\det(A-iB)=\vert \det(A+iB)\vert^2$.
Example where $B$ is neither real nor self-adjoint, and the product of determinants is not positive: consider the 1-by-1 matrices $A=1/2$ and $B=i$. Then, $\det(1/2-1)\det(1/2+1)=-3/4$.
