1

On a quantum circuit, how would I create an equal superposition of the states:

$$|\psi\rangle=|0011\rangle + |0101\rangle + |0110\rangle + |1001\rangle + |1010\rangle + |1100\rangle.$$

Adam Zalcman
  • 22,278
  • 3
  • 34
  • 83
user22395
  • 95
  • 5
  • related: https://quantumcomputing.stackexchange.com/a/12253/55, https://quantumcomputing.stackexchange.com/q/22164/55, https://quantumcomputing.stackexchange.com/q/14940/55 – glS Nov 07 '22 at 07:21

2 Answers2

2

The desired state may be rewritten$^1$ as $$ |\psi\rangle=|0\rangle\otimes|\overline{W}\rangle+|1\rangle\otimes|W\rangle $$ where $|W\rangle=|001\rangle+|010\rangle+|100\rangle$ and $|\overline{W}\rangle=|110\rangle+|101\rangle+|011\rangle=XXX|W\rangle$.

Thus, we can obtain $|\psi\rangle$ in three steps. First, initialize four qubits $1$,$2$,$3$ and $4$ to $|0000\rangle$. Next, apply Hadamard to qubit $1$ and a circuit$^2$ that creates the W state to qubits $2$, $3$ and $4$. Then, apply $X$ to qubits $2$, $3$ and $4$. Finally, execute three controlled-NOT gates, each controlled by qubit $1$ and having qubits $2$, $3$ and $4$ as the target, respectively.


$^1$ As in the question, we ignore normalization.

$^2$ See here for an example of such a circuit.

Adam Zalcman
  • 22,278
  • 3
  • 34
  • 83
0

While @Adam-Zalman's answer above is probably optimal, you can use Qiskit to get an answer to any state vector initialization problem.

from qiskit import QuantumCircuit
import numpy as np

qc = QuantumCircuit(4)

Create the desired state vector

vector = np.array([0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0]) / np.sqrt(6) qc.prepare_state(vector)

So we can see what the final circuit really looks like:

qc = qc.decompose(reps=10) qc.draw(fold=-1)

enter image description here

If you need to just quickly get the qubits into a particular state so that you can work on doing something else, this is the right solution. If the goal is to reach a particular solution optimally and understand how you got there, the other answer is best.

[Note: prepare_state() is the same as initialize(), except it doesn't zero the wires at the start. The result is a unitary gate.]

Frank Yellin
  • 713
  • 2
  • 8