# Construct Unitary Matrix when one basis transformation is known

Is there a standard method for constructing a unitary matrix $U$ to create a target vector when applied to input vector $\begin{pmatrix} 1\\ 0\\ 0\\ 0\\ \end{pmatrix}$ ?

For example, with this target state:

$\begin{pmatrix} \frac{1}{\sqrt{2}}\\ 0\\ 0\\ \frac{1}{\sqrt{2}}\\ \end{pmatrix} = U\begin{pmatrix} 1\\ 0\\ 0\\ 0\\ \end{pmatrix}$

I expect that the matrix $U$ must have the form: $\begin{pmatrix} \frac{1}{\sqrt{2}} & . & . & .\\ 0 & . & . & .\\ 0 & . & . & .\\ \frac{1}{\sqrt{2}} & . & . & .\\ \end{pmatrix}$

but I expect there to be many ways of constructing the matrix, because I haven't specified what must happen to other basis vectors when undergoing the transformation.

I know that for my example, this is a valid matrix. However, I obtained this by starting from a quantum computing circuit. I wouldn't have got to it from my original problem statement alone:

$\begin{pmatrix} \frac{1}{\sqrt{2}} & 0 & \frac{1}{\sqrt{2}} & 0\\ 0 & \frac{1}{\sqrt{2}} & 0 & \frac{1}{\sqrt{2}}\\ 0 & \frac{1}{\sqrt{2}} & 0 & -\frac{1}{\sqrt{2}}\\ \frac{1}{\sqrt{2}} & 0 & -\frac{1}{\sqrt{2}} & 0\\ \end{pmatrix}$

My motivation for the question stems from page 5 of physics paper: Information Flow in Entangled Quantum Systems

When studying algorithms whose intended inputs are qubits in unknown initial states, it may be convenient to work with other Heisenberg states $|\psi\rangle \neq |0,...,0;0\rangle$ but note, nevertheless, that by choosing any unitary matrix $U$ with the property $|\psi\rangle = U|0,...,0;0\rangle$, and setting $\hat q_a(0) = U^\dagger(\hat 1^{a-1} \otimes \hat \sigma \otimes \hat 1^{n-a})U$ instead of (5), it is always possible to choose the Heisenberg state to be $|0,...,0;0\rangle$.

I can use the unitary matrix to work out what the starting value of each quantum computing observable should be. For example $U^\dagger (\hat 1 \otimes \hat \sigma_z) U$ evaluates to $\hat \sigma_x \otimes \hat \sigma_z$. The physics paper indicates that it wouldn't have mattered which of the range of unitary matrices I had constructed; it states "by choosing any unitary matrix U". I think that if I understood why the choice of unitary matrix does not matter, it would point me to a way to shortcut this process.

• The Gram-Schmidt process? Dec 26, 2017 at 21:54
• See my answer to recent very similar question : (math.stackexchange.com/q/2565668) Dec 26, 2017 at 23:40

Jean Marie's answer already gives a specific process by which to build the matrix $$U$$ in the context of your question, but I personally gained some insight by rephrasing it in bra/ket notation (both in where the Gram-Schmidt process comes in and how the process can be generalized), so I think the following might be useful for other people finding this question.

We may take that, in the computational basis,

$$\begin{pmatrix} 1 \\ 0 \\ 0 \\ 0 \end{pmatrix} \rightsquigarrow |0^{\otimes 2}\rangle$$

(here I'm using $$|0^{\otimes 2}\rangle$$ to denote that it's a two-qubit space) and let

$$\begin{pmatrix} 1/\sqrt{2} \\ 0 \\ 0 \\ 1/\sqrt{2} \end{pmatrix} \rightsquigarrow \frac{|00\rangle + |11\rangle}{\sqrt{2}} = |\psi\rangle$$

Then, surely, because our unitary transformation must map every element of the computational basis to some other element of the Hilbert space, and in particular maps $$|0^{\otimes 2}\rangle$$ to $$|\psi\rangle$$, it must be of the form

$$\hat U = |\psi\rangle\langle 0^{\otimes 2}| + \sum_{k \neq 0} |u_k\rangle \langle k|$$

where $$|u_k\rangle$$ is some element of the Hilbert space of two qubits.

Now, we impose the condition of unitarity (recall the completeness relation):

$$U^\dagger U = I$$ $$\Leftrightarrow \left (|0^{\otimes 2}\rangle\langle\psi| + \sum_{k\neq 0} |k\rangle\langle u_k| \right)\left (|\psi\rangle\langle0^{\otimes 2}| + \sum_{k'\neq 0} |u_{k'}\rangle\langle k'| \right) = \sum_k |k\rangle\langle k|$$

Which is satisfied if

$$\langle u_k | \psi \rangle = 0 \; , \qquad \langle u_k | u_{k'} \rangle = \delta_{k,k'}$$

(You may verify this by writing out the product explicitly.)

So that, in fact, $$\{|\psi\rangle, |u_k\rangle\}$$ (for running $$k=1,\ldots,2^2-1$$) form an ortho-normal basis.

Therefore, in order to construct $$\hat U$$, start with set $$\{|\psi\rangle\}$$ and augment it to an ortho-normal basis set of your two-qubit space via the Gram-Schmidt Process. Then, assign $$u_k$$ arbitrarily to the elements of the basis that are not $$|\psi\rangle$$.

The matrix form of the operator can be obtained by calculating

$$U = \big ( \; \langle i | \hat U | j \rangle \; \big )$$

Let us continue with your example with a given first column vector $V_1$

Let us find the 3 other columns of your matrix by working in the subspace of column vectors with coordinates $x_1,x_2,x_3,x_4$ that are orthogonal to $V_1$, i.e., such that $x_1+x_4=0.$

Take any independent set of 3 vectors in $S$ and (as advised by @Lord Shark the Unknown) orthonormalize it by using Gram-Schmidt process (http://www.emathhelp.net/calculators/linear-algebra/gram-schmidt-calculator/)

More precisely, a general "independent set" of 3 vectors in $\mathbb{R^4}$ means a set with rank 3. This can be obtained in the following way :

• take a $3 \times 3$ random North-East block with non-zero determinant ; let us call it $B$.

• take the $1 \times 3$ South-East block equal to minus the first line of block $B$ (in order to fulfill condition $x_1+x_4=0$.)

Then apply Gram-Schmidt process to the 3 last columns.

• To find the 3 additional vectors that you mentioned, I see that the "NullSpace" function in Mathematica performs this task (thanks to your answer, I got a few clues on what to look for). I can then just put them (together with the original targetstate) into a Matrix. Does this tie in with your expectation? $targetstate = 1/Sqrt[2] {1, 0, 0, 1}$ $Transpose[Prepend[Orthogonalize[NullSpace[{targetstate}]], targetstate]]$ $\begin{pmatrix} \frac{1}{\sqrt{2}} & -\frac{1}{\sqrt{2}} & 0 & 0\\ 0 & 0 & 0 & 1\\ 0 & 0 & 1 & 0\\ \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} & 0 & 0\\ \end{pmatrix}$ Jan 1, 2018 at 19:37
• This definitely doesn't give the same behaviour as the unitary matrix I specified in my question when working out the Heisenberg states, but it is unitary and it does make sense to me as a valid transformation. I think that the reference that I made to the physics paper means that one has to pick an arbitrary $U$ and then have to keep hold of it and use it if you want to translate back to the state representation. Jan 1, 2018 at 19:39
• I've tried to work out where the $x_1 + x_4 = 0$ constraint has come from, but I'm afraid I don't see how it follows from the condition that the output matrix is unitary (sorry, this may well be obvious; I'm starting from a low base of linear algebra knowledge!). Is there something wrong with the matrix that I've suggested? Jan 4, 2018 at 10:06
• My bad, your matrix is completely correct. The constraint $x_1+x_4$ comes from the orthogonality condition of the 3 last vectors with the first one : $x_1*\tfrac{1}{\sqrt{2}}+x_2*0+x_3*0+x_4*\tfrac{1}{\sqrt{2}}=0$ and then symplifying by $\tfrac{1}{\sqrt{2}}$, and is fulfilled by the three last columns ! I erase my previous erroneous remark ! Jan 4, 2018 at 18:22

The Householder Transformation is commonly used to do this.