# Similarity of unitary matrix [closed]

How to check if two 2x2 unitary matrices are similar using python..Is there a speacial function for it

I don't quite know if there is a thing in Python for this, but two $2\times 2$ matrices (not necessarily in $U(2)$) are similar if and only if all of the following hold:

1. $\operatorname{tr} A=\operatorname{tr} B$

2. $\det A=\det B$

3. one of the following holds:

• $\operatorname{tr}^2 A-4\det A\ne 0$
• $\operatorname{tr}^2 A-4\det A=0$ and $A=\frac{\operatorname{tr A}}2I=B$
• $\operatorname{tr}^2 A-4\det A=0$, $A\ne \frac{\operatorname{tr A}}2I$ and $B\ne \frac{\operatorname{tr A}}2I$

It must be noted, however, that since unitary matrices are always diagonalizable, $A,B\in U(2)$ together with $(1)\land(2)$ already imply $(3)$.

• So if I have two matrices in SU(2) is condition 1 sufficient to prove they are similar? Also does two similar matrix always diagonalize to the same diagonal matrix . – Debarghya Kundu Jun 12 '18 at 17:20
• Yes to both claims. – Saucy O'Path Jun 12 '18 at 20:12
• Thanks Saucy O'Path – Debarghya Kundu Jun 13 '18 at 4:09