Determinant involving traceless unitary hermitian matrices

Let $$S$$ be the set of complex $$N\times N$$ matrices that are traceless, unitary and hermitian.

A friend asked me the following question, motivated by a problem in condensed matter physics:

Is it true that for every two matrices $$A$$, $$B$$ in $$S$$, the value of $$\det(A+iB)$$ is always imaginary?

Well, if a matrix is unitary and hermitian, it can only have $$\pm 1$$ as eigenvalues. To be traceless, $$N$$ must be even.

I ran a computer experiment. I wrote $$A=UDU^\dagger$$ and $$B=VDV^\dagger$$ where $$D={\rm diag}(1^M,(-1)^M)$$ and $$U$$, $$V$$ are random unitary matrices of dimension $$N=2M$$.

The result is that $$\det(A+iB)$$ seems to be indeed always imaginary, if $$N\equiv 2 \text{ mod } 4$$.

Any ideas how this could be proved?

• And if $N\equiv 0 \bmod 4$, then the determinant obviously need not be imaginary. – Christian Remling Apr 3 at 19:12
• @ChristianRemling I wouldn't mind learning why that is obvious... – thedude Apr 3 at 19:15
• The diagonal matrix $\textrm{diag}(1+i,1+i,-1-i,-1-i)$ has determinant $-4$, and then in general build the matrix from such blocks. – Christian Remling Apr 3 at 19:18
• Or, more succinctly perhaps, with $B=A$, we have $\det (A+iB)=(1+i)^N\det A$. – Christian Remling Apr 3 at 19:25
• A guess: rewrite as $\det(D + i U^*BU)$ expand as a series in $i$, and collect – Daniel McLaury Apr 3 at 22:05

Yes. It's real when $$N\equiv 0 \text{ mod } 4$$ and imaginary when $$N\equiv 2\text{ mod } 4$$.
The square of the determinant is $$\det(A+iB)^2=\det(1-1+i(AB+BA))=i^N\det(AB+BA)$$, so for either parity of $$N/2$$ we need to show the Hermitian matrix $$AB+BA$$ has nonnegative determinant. Up to unitary transformation, $$B=D$$ and $$A=\begin{pmatrix}X&Y\\Y^\dagger& -Z\end{pmatrix}$$. $$A^2=1$$ implies $$XY=YZ$$, so if $$Y$$ is invertible then $$\det X=\det Z$$ and $$AB+BA=\begin{pmatrix}2X&0\\0& 2Z\end{pmatrix}$$ has nonnegative determinant.
Let $$V$$ be the variety of all such $$A$$. By a perturbation argument, it's enough to show that for a dense subset of $$V$$, the determinant of $$Y$$ is nonzero. The unitary group is (Zariski) irreducible and $$V$$ is its image under an algebraic map, so it too is irreducible, which means that it is enough to find a single $$A$$ with invertible $$Y$$. Take $$A=\begin{pmatrix}0&I\\I& 0\end{pmatrix}$$.