I know that a complex matrix $n \times n$ is said to be unitary if $AA^*=A^*A=I$ or equivalently if $A^*=A^{-1}$. But I asked what if there is a random matrix and we want to turn it into an unitary matrix, please also give an example.
How to convert a random matrix to Unitary Matrix?
-
1If the random matrix has full column rank you can use the Gram-Schmidt procedure to orthonormalize its columns. If the matrix is square the result of this procedure is a unitary matrix. This is essentially the same as computing a QR factorization of the random matrix and keeping the $Q$ factor. – 2017-02-26
-
0@nadia Welcome to math stack exchange! – 2017-02-26
-
0@K.Miller Don't we need additional restrictions such as the determinant has absolute value $1$ ? – 2017-02-26
-
0The Gram-Schmidt procedure gives you an orthonormal basis, which when arragned into a matrix gives a unitary matrix. I included the normalization step in the procedure, so the determinant of the resulting matrix will have absolute value $1$. – 2017-02-26
-
0@K.Miller can you give me an example? because i'm still confused – 2017-02-27
1 Answers
If you have access to Matlab or Octave, then producing such matrices is as easy as issuing the following commands:
n = 10;
A = rand(n) + 1i*rand(n);
[U,~] = qr(A);
I recommend that you use software such as this to generate these matrices in general. For small matrices that you would like to work by hand, the Gram-Schmidt procedure is what you want. Here is a simple example involving a real $3\times 3$ matrix. Let
$$
A =
\begin{bmatrix}
1 & 1 & 1\\
1 & 0 & 2\\
0 & 2 & 1
\end{bmatrix}
$$
We are going to construct a $3\times 3$ unitary matrix $U$ from the columns of $A$. For simplicity I will first construct a matrix $\hat{U}$ with orthogonal columns, and then normalize at the end to get a unitary matrix. The first step is easy, we set the first column of $\hat{U}$ equal to the first column of $A$, i.e., $\hat{u}_1 = a_1$. The second column of $\hat{U}$ is equal to $a_2$ minus any contributions from $\hat{u}_1$, that is,
$$
\hat{u}_2 = a_2 - \frac{\hat{u}_1\cdot a_2}{\hat{u}_1\cdot \hat{u}_1}\hat{u}_1 =
\begin{bmatrix}
1\\
0\\
2
\end{bmatrix}
-
\frac{1}{2}
\begin{bmatrix}
1\\
1\\
0
\end{bmatrix}
=
\begin{bmatrix}
\phantom{-}1/2\\
-1/2\\
\phantom{-}2
\end{bmatrix}
$$
The last step is the same as the second except now we must remove from $a_3$ any contributions from $\hat{u}_1$ or $\hat{u}_2$. Thus,
\begin{align}
\hat{u}_3 &= a_3 - \frac{\hat{u}_1\cdot a_3}{\hat{u}_1\cdot \hat{u}_1}\hat{u}_1 - \frac{\hat{u}_2\cdot a_3}{\hat{u}_2\cdot \hat{u}_2}\hat{u}_2\\[1mm]
&=
\begin{bmatrix}
1\\
2\\
1
\end{bmatrix}
- \frac{3}{2}
\begin{bmatrix}
1\\
1\\
0
\end{bmatrix}
- \frac{1}{3}
\begin{bmatrix}
\phantom{-}1/2\\
-1/2\\
\phantom{-}2
\end{bmatrix}\\[1mm]
&=
\begin{bmatrix}
-2/3\\
\phantom{-}2/3\\
\phantom{-}1/3
\end{bmatrix}
\end{align}
The last step to obtain $U$ from $\hat{U}$ is to normalize the columns of $\hat{U}$. Doing so we obtain the unitary matrix
$$
U =
\begin{bmatrix}
1/\sqrt{2} & \phantom{-}1/(3\sqrt{2}) & -2/3\\
1/\sqrt{2} & -1/(3\sqrt{2}) &\phantom{-}2/3\\
0 & \phantom{-}2\sqrt{2}/3 &\phantom{-}1/3
\end{bmatrix}
$$
As you can see from this simple example, the procedure is quite tedious by hand and is best left to a computer. You can read more about the Gram-Schmidt procedure here.
-
0So, if I want to create a unitary matrix complex. Should I choose from a random of complex matrix? – 2017-02-28
-
0Yes, start with a random complex matrix. Note that since you are dealing with complex vectors any dot products $u\cdot v$ in the procedure become $u\cdot \bar{v}$, where $\bar{v}$ is the complex conjugate of $v$. – 2017-02-28
-
0Thank you very much for all your answer, it really helped me to understand the unitary matrix – 2017-02-28
-
0No problem, glad to help. – 2017-02-28