# How to find the value with which I need to divide a unitary matrix such that its first component lies within the range of cosine?

In quantum mechanics, we generally deal with unitary matrices. In the IBM cloud computers and Qiskit, the general $$2\times 2$$ unitary is defined as

$$U(\theta, \phi, \lambda) = \begin{pmatrix} \cos\left(\frac{\theta}{2}\right) & -e^{i\lambda} \sin\left(\frac{\theta}{2}\right) \\ e^{i\phi} \sin\left(\frac{\theta}{2}\right) & e^{i(\lambda + \phi)} \cos\left(\frac{\theta}{2}\right) \end{pmatrix}.$$

Now say I want to find the parameters $$\theta, \phi$$ and $$\lambda$$ corresponding to the unitary $$\begin{pmatrix}-\frac{1}{2}+\frac{i}{2}& -\frac{1}{2}-\frac{i}{2}\\ -\frac{1}{2}+\frac{i}{2} & -\frac{1}{2}+\frac{i}{2}\end{pmatrix}.$$ Then I can't apply this code directly as the first component of the unitary does not lie in the range of $$\cos$$. So I'll first have to divide the whole matrix by $$\frac{1+i}{\sqrt{2}}$$ first, to get to

$$\begin{pmatrix}\frac{1}{\sqrt{2}} & \frac{i}{\sqrt{2}} \\ \frac{i}{\sqrt{2}} & \frac{1}{\sqrt{2}}\end{pmatrix}.$$

Note that $$|\frac{1+i}{\sqrt{2}}|=1$$ and so the two unitaries are equivalent in the quantum mechanics sense. Furthermore, now the first component $$\frac{1}{\sqrt 2}$$ lies within the range of cosine i.e. $$[-1,1]$$.

Now for any general unitary matrix how do I find the value with which I have to divide it, such that the first component lies within the range of cosine? In this case, the value was $$\frac{1+i}{\sqrt 2}$$, but how do I find that for a general $$2\times 2$$ unitary matrix?

Àccording to Wikipedia, the general form of a unitary $$Z$$ can also be written as $$Z=e^{i\varphi/2}\begin{bmatrix}e^{i\varphi_1}\cos\theta & e^{i\varphi_2}\sin\theta \\ -e^{-i\varphi_2}\cos\theta & e^{-i\varphi_1}\cos\theta \end{bmatrix}$$ where the determinant of the unitary is $$\det Z=e^{i\varphi}$$. So the required value is the principle value of $$\sqrt{\det Z}$$ multiplied by the phase factor $$e^{i\varphi_1}$$ of the first component of $$Z$$, which can be easily obtained by representing it in polar form.
I am sorry, but I cannot comment on the question. I have doubts that the matrix mentioned in the question is actually unitary: $$\begin{pmatrix}-\frac{1}{2}+\frac{i}{2}& -\frac{1}{2}-\frac{i}{2}\\ -\frac{1}{2}+\frac{i}{2} & -\frac{1}{2}+\frac{i}{2}\end{pmatrix}.$$
Maybe you meant one of the square roots of NOT: $$\begin{pmatrix}-\frac{1}{2}+\frac{i}{2}& -\frac{1}{2}-\frac{i}{2}\\ -\frac{1}{2}-\frac{i}{2} & -\frac{1}{2}+\frac{i}{2}\end{pmatrix}$$