Solution (source code)

= Solution

Use the Leibniz definition of the <determinant>:
$$
\det A=\sum_{\pi\in S_n}\operatorname{sgn}(\pi)\prod_{i=1}^na_{i,\pi(i)}.
$$
For the permuted-column <matrix>, $a^\sigma_{ij}=a_{i,\sigma(j)}$. Reindex the sum by $\tau=\sigma\circ\pi$. The <sign of a permutation> is multiplicative, so $\operatorname{sgn}(\pi)=\operatorname{sgn}(\sigma)\operatorname{sgn}(\tau)$. It follows directly that
$$
\det(A^\sigma)=\operatorname{sgn}(\sigma)\det A.
$$
For the <matrix transpose>, the products in its determinant are $\prod_i a_{\pi(i),i}$. Set $j=\pi(i)$ to obtain $\prod_j a_{j,\pi^{-1}(j)}$, and use $\operatorname{sgn}(\pi^{-1})=\operatorname{sgn}(\pi)$. This proves $\det(A^t)=\det A$. These facts also show that equal columns, or equal rows by transposition, force the <determinant> to be zero: exchanging the equal pair leaves the matrix unchanged but changes the determinant's sign.

Let $M_{ij}$ be the <matrix> obtained by deleting row $i$ and column $j$, with the empty determinant taken as one for $n=1$. Define the cofactor $C_{ij}=(-1)^{i+j}\det M_{ij}$ and the <adjugate matrix> by $\operatorname{adj}(A)_{ij}=C_{ji}$. Grouping the Leibniz sum according to the column chosen in row $i$ gives the cofactor expansion $\det A=\sum_k a_{ik}C_{ik}$: deleting that row and its chosen column leaves a permutation of $n-1$ entries, with sign factor $(-1)^{i+k}$. Therefore
$$
(A\operatorname{adj}A)_{ij}=\sum_k a_{ik}C_{jk}.
$$
When $i=j$ this is $\det A$. When $i\ne j$ it is the cofactor expansion along row $j$ of the matrix formed by replacing that row with row $i$; its remaining minors are unchanged, and its two equal rows give determinant zero. The column version proves the other product in the same way. Thus the <adjugate identity> is
$$
\boxed{A\operatorname{adj}(A)=\operatorname{adj}(A)A=(\det A)I,\qquad A^{-1}=\frac{\operatorname{adj}(A)}{\det A}\quad(\det A\ne0).}
$$

For the real <matrices> $C,D$, let $p(t)=\det(C+tD)$. The determinant definition makes this a real <polynomial> of <degree of a polynomial> at most $n$. Since $C+iD$ is invertible, the allowed converse implies $p(i)\ne0$, so $p$ is not the zero polynomial. It has at most $n$ real <roots of a polynomial>. Choose a real $\lambda$ outside those roots; the adjugate argument proves that $C+\lambda D$ is invertible.

Finally write the given complex <similarity transformation> as $P=C+iD$. The relation $AP=PB$, with $A,B$ real, yields $AC=CB$ and $AD=DB$ by comparing real and imaginary parts. Choose the preceding $\lambda$ and put $Q=C+\lambda D$. Then $AQ=QB$, so
$$
\boxed{Q^{-1}AQ=B\quad\text{with }Q\text{ real and invertible}.}
$$
This proves <real similarity from complex similarity> by constructing a real intertwiner, rather than requiring $C$ or $D$ separately to be invertible.