# How to convert one state of a quantum system to a desired state?

I have a state of 3 qubits:

The first number inside the brackets gives the probability of each state, and the second number gives the phase.

\begin{align} |000\rangle &= (12.5,0^{°}),\\ |001\rangle &= (12.5,0^{°}) , \\ |010\rangle &=(12.5,0^{°}), \\ |011\rangle &=(12.5,0^{°}),\\ |100\rangle&=(12.5,0^{°}), \\ |101\rangle&=(12.5,180^{°}),\\ |110\rangle&=(12.5,180^{°}),\\ |111\rangle &=(12.5,0^{°})\,. \end{align}

and want to convert it into:

\begin{align} |000\rangle &= (12.5,0^{°}),\\ |001\rangle &= (12.5,0^{°}) , \\ |010\rangle&=(12.5,0^{°}),\\ |011\rangle&=(12.5,0^{°}),\\ |100\rangle&=(12.5,0^{°}),\\ |101\rangle&=(12.5,0^{°}),\\ |110\rangle&=(12.5,0^{°}),\\ |111\rangle&=(12.5,180^{°})\,. \end{align}

How can I do this? I have been scratching my head for a day and still haven't figured it out. Help appreciated.

• You seem to be representing phases as angles in degrees. By stating that the phase is 180 degrees do you mean that the phase is equal to $e^{i\pi}=-1$? Apr 3 at 23:32
• yes exactly that Apr 3 at 23:37
• This seems like a homework question. What have you tried so far? Apr 4 at 0:03
• I have tried adding a Z gate on the first qubit but it doesn't give me what I need. Apr 4 at 6:25
• Adding a $Z$ gate is a good start. However, you need to apply $Z$ gate for certain basis states (in other words, conditioned on some states) Apr 4 at 11:55

Here is a quantum circuit that first prepares your initial state and then transforms it to the second state.

The circuit is partitioned into 6 parts by barriers (vertical lines) for providing a better understanding. The initial state is prepared in the first three steps, the transformation to the desired state is performed in steps 4 to 6.

Note: Of course the barriers could be removed and the circuit could be optimized, e.g. two repeating H gates would be identical to the identity an could therefore be omitted.

state preparation:

1. put the 3 qubits in superposition states with the H gate on each qubit to get probabilities of 12.5% on each basis state
2. we want to rotate the state $$|110\rangle$$ by 180°. This can be done by a doubly controlled Z gate (CCZ), for which I use here the combination H CCX H. The X gate before this controlled Z operation is to invert the third qubit such that the phase is rotated when the third qubit is in the state 0. The X gate after CCZ restores this inversion. For more information on constructing a CCZ gate you can see this answer.
3. in the same fashion we rotate the state $$|101\rangle$$ by 180°.

transformation to desired state:

1. to change the phase of the $$|111\rangle$$ state we apply our CCZ (= H CCX H) gate
2. rotate the state $$|110\rangle$$. Note that this is the same operation as in step 2
3. rotate the state $$|101\rangle$$, again the same operation as in step 3

This circuit is drawn with the IBM Composer for quantum circuits. By following this link you can open the circuit, see the effect of each gate step by step and experiment by modifying the circuit.