# Transforming $|01 \rangle + |10 \rangle - |11 \rangle \to |01 \rangle - |10 \rangle + |11 \rangle$ How to convert from current state: $$|\psi \rangle =\dfrac{ |01 \rangle + |10 \rangle - |11 \rangle}{\sqrt{3}}$$

into a target state

$$|\phi \rangle = \dfrac{|01 \rangle - |10 \rangle + |11 \rangle}{\sqrt{3}}$$

using only X, Z & H gates? TIA.

• Where is that screenshot from – develarist Nov 9 '20 at 7:38
• It's from QLogic game, a mobile application from GooglePlayStore. – Sscr Nov 10 '20 at 12:37

The other answer by @chrysaor4 is exactly right! I would just like to add a few additional clarification steps (that might or might not be useful)... simply because I have some time while waiting for someone doing shopping... :)

First of, we know that the Paulis $$X,Z$$ and Hadamard gate $$H$$ take the form

$$X = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} \ \ \ \ \ \ \ \ Z = \begin{pmatrix} 1 & 0\\ 0 & -1 \end{pmatrix} \ \ \ \ \ \ \ \ H= \dfrac{1}{\sqrt{2}}\begin{pmatrix} 1 & 1\\ 1 & -1 \end{pmatrix}$$

Taking the computation basis $$\{ |0 \rangle, |1\rangle\}$$ which defined as $$|0\rangle = \begin{pmatrix} 1 \\ 0 \end{pmatrix}$$ and $$|1\rangle = \begin{pmatrix} 0 \\ 1 \end{pmatrix}$$ then we can see that

$$X|0 \rangle = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} \begin{pmatrix} 1 \\ 0 \end{pmatrix} = \begin{pmatrix} 0 \\ 1 \end{pmatrix} = |1 \rangle \ \ \ \ \textrm{and} \ \ \ \ X|1 \rangle = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} \begin{pmatrix} 0 \\ 1 \end{pmatrix} = \begin{pmatrix} 1 \\ 0 \end{pmatrix} = |0 \rangle$$

similarly

$$Z|0 \rangle = \begin{pmatrix} 1 & 0\\ 0 & -1 \end{pmatrix} \begin{pmatrix} 1 \\ 0 \end{pmatrix} = \begin{pmatrix} 1 \\ 0 \end{pmatrix} = |0 \rangle \ \ \ \ \textrm{and} \ \ \ \ Z|1 \rangle = \begin{pmatrix} 1 & 0\\ 0 & -1 \end{pmatrix} \begin{pmatrix} 1 \\ 0 \end{pmatrix} = \begin{pmatrix} 0 \\ -1 \end{pmatrix} =-|1 \rangle$$

and you can also show that

$$H|0\rangle = \dfrac{|0\rangle + |1\rangle}{\sqrt{2}} \ \ \ \ \textrm{and} \ \ \ \ H|1 \rangle = \dfrac{|0\rangle - |1\rangle}{\sqrt{2}}$$

From the computations above, we have found out what each of the gates $$X,Z, H$$ do to the state $$|0\rangle$$ and $$|1\rangle$$ respectively.

Now your goal is to transform the state $$\dfrac{ |01\rangle + |10 \rangle - |11\rangle}{\sqrt{3}}$$ to the state $$\dfrac{ |01\rangle - |10 \rangle + |11\rangle}{\sqrt{3}}$$.

The transformation fixed the basis states and only changes sign on the second and third basis state. Now if you look back on the computations we did above you can see that the gate $$Z$$ is something that we would want to use. As it keep the basis state fixed and only change the sign when the state is $$|1\rangle$$.

This tells us that we should apply the $$Z$$ gate on the first qubit.

Now, applying $$Z$$ on the first qubit and do nothing on the second qubit is simply the operation $$Z \otimes I$$. Here $$I$$ is the idenity matrix so it tells us to do nothing to the second qubit. In the circuit representation, this is simply: And this operation $$Z \otimes I$$ does explicitly the following:

$$(Z \otimes I) |01\rangle = Z|0\rangle \otimes I |1\rangle = |0\rangle \otimes |1 \rangle = |0 1\rangle$$ and $$(Z \otimes I) |10\rangle = Z|1\rangle \otimes I |0\rangle = -|1\rangle \otimes |0 \rangle = -|1 0\rangle$$ and $$(Z \otimes I) |11\rangle = Z|1\rangle \otimes I |1\rangle = -|1\rangle \otimes |1\rangle = -|1 1\rangle$$

And because of linearity we have then ,

$$Z \otimes I \bigg( \dfrac{|01\rangle + |10 \rangle - |11\rangle}{\sqrt{3}} \bigg) = \dfrac{|01\rangle - |10 \rangle + |11\rangle}{\sqrt{3}}$$

Thus, the above circuit is exactly what you are looking for.

Apply a Z gate to the first qubit:

$$Z_1 (|01\rangle + |10\rangle - |11\rangle) = (Z|0\rangle)|1\rangle + (Z|1\rangle)|0\rangle - (Z|1\rangle)|1\rangle) = |01\rangle - |10\rangle + |11\rangle$$