# How can I specify the region for every variable simultaneously in NMinimize?

I want to use NMinimize to find the unknown unitary matrix that solves a (possibly nonlinear) matrix equation. For example, the one that transforms the Pauli matrix $$\sigma^x$$ to $$\sigma^y$$:

$$\qquad U^\dagger \sigma^x U=\sigma^y$$.

Here is my code:

sx = {{0, 1}, {1, 0}}; sy = {{0, -I}, {I, 0}};
UR = Array[ur, {2, 2}]; UI = Array[ui, {2, 2}];
U = UR + I UI; Udg = Transpose[UR - I UI];
sol =
NMinimize[
Total[Total[Abs[Udg.sx.U - sy]^2 + Abs[Udg.U - IdentityMatrix[2]]^2]],
Flatten[{UR, UI}]];
Usol = U /. sol[[2]];
Round[ConjugateTranspose[Usol].sx.Usol] // MatrixForm


The output is indeed $$\sigma^y$$. The code is OK, but I want to improve it to run faster. Realizing that the elements of unitary matrix have absolute value smaller than 1, I can limit the $$ur[i,j]$$ and $$ui[i,j]$$ to be in the interval [-1, 1]. Is there a neat way to do this with NMinimize?

 Flatten[{UR, UI}] ∈ Interval[{-1, 1}]


doesn't work.

Any other improvements on my code will also be welcomed, as my research problem is much bigger; e.g., an 8$$\times$$8 unknown unitary matrix. I want to optimize the speed.

I am quite confident that the minimal U in this case can be obtained by using normal forms as follows:

{λ, V} = Eigensystem[sx];
V = Normalize /@ V;
{μ, W} = Eigensystem[sy];
W = Normalize /@ W;
U = ConjugateTranspose[W].V;

ConjugateTranspose[U].sx.U == sy


True

Important requirement to use this: The two matrices sx and sy have to be normal matrices, i.e., they have to satisfy the equations

ConjugateTranspose[sx].sx == sx.ConjugateTranspose[sx]
ConjugateTranspose[sy].sy == sy.ConjugateTranspose[sy]