# How to construct an $n\times n$ unitary matrix taking an arbitrary $|\psi\rangle$ to a target state $|\phi\rangle$?

I came across Lecture 12 here https://viterbi-web.usc.edu/~tbrun/Course/ that does this but I was not able to understand. An example would be very helpful

• Does this answer help? quantumcomputing.stackexchange.com/a/8863/15820 Jun 8 at 18:03
• Use householder transformation Jun 8 at 18:16
• you can simply write the operator $|\psi\rangle\!\langle\phi|$ and complete it to be a unitary. This can be done by completing in an arbitrary way $|\phi\rangle$ and $|\psi\rangle$ into orthonormal bases, call them $\{|\phi_i\rangle\}$ and $\{|\psi_i\rangle\}_i$ with $\psi_1=\psi$ and $\phi_1=\phi$. Any corresponding unitary $U=\sum_i |\psi_i\rangle\!\langle\phi_i|$ sends the input to the output. I'm pretty sure this was already asked and answered on the site, but I can't find the post right now
– glS
Jun 8 at 23:39
• – glS
Jun 8 at 23:49

I didn't go through the attached pdf. But if you want to find a unitary matrix $$U$$ that maps a quantum state $$|\psi \rangle$$ to $$|\phi\rangle$$ then you can use the Householder transformation as I commented. Here the two vectors have the same length (they are unit vectors) because we are thinking of them as a quantum state, so there will always exist a Householder transformation that can do this.

For example: If you want to find a unitary, $$U$$, that maps $$|00\rangle = \begin{pmatrix} 1 \\ 0 \\ 0 \\ 0 \end{pmatrix}$$ to $$|11\rangle = \begin{pmatrix} 0\\0\\0\\1\end{pmatrix}$$ then you can construct it as: $$U = I - 2vv^T$$ where $$v$$ is the normalized vector of $$|00\rangle - |11\rangle = \begin{pmatrix} 1 \\ 0 \\ 0 \\ -1 \end{pmatrix}$$. That is, $$v = \begin{pmatrix} 1/\sqrt{2} \\ 0 \\ 0 \\ -1/\sqrt{2} \end{pmatrix}$$.

From here, we can write $$U$$ out explicitly as:

\begin{align} U &= \begin{pmatrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1\end{pmatrix} - 2 \begin{pmatrix} 1/\sqrt{2} \\ 0 \\ 0 \\ -1/\sqrt{2} \end{pmatrix} \begin{pmatrix} 1/\sqrt{2} & 0 & 0 &-1/\sqrt{2} \end{pmatrix} \\ &= \begin{pmatrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1\end{pmatrix} - 2 \begin{pmatrix} 1/2 & 0 & 0 & -1/2\\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ -1/2 & 0 & 0 & 1/2 \end{pmatrix} = \begin{pmatrix} 0 & 0 & 0 & 1\\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 1 & 0 & 0 & 0\end{pmatrix} \end{align}

You can check that this is infact unitary since $$U\cdot U^\dagger = I$$ and that

$$U|00\rangle = \begin{pmatrix} 0 & 0 & 0 & 1\\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 1 & 0 & 0 & 0\end{pmatrix} \begin{pmatrix} 1 \\ 0 \\ 0 \\ 0 \end{pmatrix} = \begin{pmatrix} 0 \\ 0 \\ 0 \\ 1 \end{pmatrix} = |11\rangle$$

The question now is about how to decompose this unitary matrix into a quantum circuit with certain set of gates... This can be done in different ways... look up KAK decomposition if you are interested.