# 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.
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 7, "wp-katex-eq": 0, "align": 2, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "https://quantumcomputing.stackexchange.com/questions/37606/how-to-convert-one-state-of-a-quantum-system-to-a-desired-state", "fetch_time": 1716251028000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2024-22/segments/1715971058342.37/warc/CC-MAIN-20240520234822-20240521024822-00449.warc.gz", "warc_record_offset": 423578327, "warc_record_length": 41228, "token_count": 891, "char_count": 3071, "score": 3.59375, "int_score": 4, "crawl": "CC-MAIN-2024-22", "snapshot_type": "longest", "language": "en", "language_score": 0.8877565264701843, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00032-of-00064.parquet"}