<s>[INST] Find a matrix for a unitary transform between matrices or prove that there is none I have hermitian matrices $A,\,B$ and would like to find a unitary matrix $U$ such that
$$UAU^\dagger=B$$
or show that there is no such matrix.
Example:
For
$$
A=\begin{pmatrix}
0 & 1 & 0 & 0\\
1 & 0 & 0 & 0\\
0 & 0 & 0 & -1\\
0 & 0 & -1 & 0
\end{pmatrix},\,
B=\begin{pmatrix}
0 & 0 & -1 & 0\\
0 & 0 & 0 & 1\\
-1 & 0 & 0 & 0\\
0 & 1 & 0 & 0
\end{pmatrix}
$$
we find
$$
U=\begin{pmatrix}
1 & 0 & 0 & 0\\
 0 & 0 & -1 & 0 \\
0 & -1 & 0 & 0\\
0 & 0 & 0 & 1
\end{pmatrix}
$$
by guesswork. A constructive method would be useful.
Next example, where I assume that no such $U$ exists, but do not know how to show it:
$$
A=\begin{pmatrix}
b & d & c & a\\
d & - b & a & - c\\
c & a & - b & - d\\
a & - c & - d & b
\end{pmatrix}
=a\cdot\sigma_x\otimes\tau_x + b\cdot\sigma_z\otimes\tau_z
+ c\cdot\sigma_x\otimes\tau_z + d\cdot\sigma_z\otimes\tau_x\\
B=\begin{pmatrix}
- b & d & - c & - a\\
d & b & - a & c\\
- c & - a & b & - d
\\- a & c & - d & - b\end{pmatrix}
=-a\cdot\sigma_x\otimes\tau_x - b\cdot\sigma_z\otimes\tau_z
- c\cdot\sigma_x\otimes\tau_z + d\cdot\sigma_z\otimes\tau_x
$$
where $\sigma_x,\,\sigma_z,\,\tau_x,\,\tau_z$ denote the Pauli matrices
$$
\sigma_0 = \tau_0 =
\begin{pmatrix}
1 & 0\\
0 & 1
\end{pmatrix},\,
\sigma_x = \tau_x =
\begin{pmatrix}
0 & 1\\
1 & 0
\end{pmatrix},\,
\sigma_y = \tau_y =
\begin{pmatrix}
0 & -i\\
i & 0
\end{pmatrix},\,
\sigma_z = \tau_z =
\begin{pmatrix}
1 & 0\\
0 & -1
\end{pmatrix}
$$
Note: I am mostly interested in $4\times4$ matrices, but $8\times8$ would be nice, too.
EDIT: Thanks to the answer of Kurt G.. Assume $a,\,b,\,c,\,d\in\mathbb{R}\backslash\{0\}$. I was aware that a solution for $d=0$ exists. I specifically included $d$ to avoid a simple solution of the form $\sigma_a\otimes\tau_b$. When $d=0$, then a solution exists independently of the other values, for example $U=\sigma_0\otimes\tau_y$
 [/INST] In the second problem, the two matrices are unitarily similar when $abcd=0$. When $abcd\ne0$, one can verify that
\begin{aligned}
\operatorname{tr}(A^4)&=4\left[(a^2+b^2+c^2+d^2)^2+4(ab-cd)^2\right],\\
\operatorname{tr}(B^4)&=4\left[(a^2+b^2+c^2+d^2)^2+4(ab+cd)^2\right].
\end{aligned}
Hence $\operatorname{tr}(A^4)\ne\operatorname{tr}(B^4)$ in this case and $A,B$ are not similar.
</s>