# matrix – How to specify a region for each variable simultaneously in NMinimize

I want to use the NMinimize function to find the unknown unit matrix that solves a matrix equation (possibly nonlinear), for example the one that transforms the Pauli matrix. $$sigma ^ x$$ at $$sigma ^ y$$: $$U ^ dagger sigma ^ x U = sigma ^ y$$. Here is my code:

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

And the exit is good $$sigma ^ y$$. The code is correct, but I want to improve it so that it is faster. Realizing that the elements of the unit matrix have an absolute value less than 1, I can limit the $$ur[i,j]$$ and $$ui[i,j]$$ to be in the meantime [-1,1]. Is there a sensible way to do this in NMinimize? Something like
Flatten[{UR, UI}]$$in$$ Interval[{-1,1}] does not work.
(Any other improvement of my code will also be welcome, because my research problem is much more important, for example 8.$$times$$8 unitary matrix unknown, so I want to optimize the speed.)