# How does qiskit implement a given superposition in the actual quantum computer?

My question is phrased in 2 parts:

1. Is there a quantum circuit to implement the following 4-qubit state: $$\frac{1}{2}(|1000 \rangle + |0100 \rangle + |0010 \rangle + |0001 \rangle)$$

2. When we use the Qiskit Statevector class and pass a list of coefficients to generate a state, how does Qiskit implement the superposition? Even if it can do the superimposition on a software level, if such a state is to be initialized on an actual quantum computer, how can it be done? Is there a general circuit construction to create the following general superposed state:$$|\psi \rangle = \sum_i c_i |i \rangle$$ Where $$i \in \{0,1 \}^n$$, is one of the n-qubit computational basis state bitstrings.

Edit: I am not asking for Qiskit circuits to code up a general state. I am asking for a gate-based construction, if it exists, for general states (or how states are initialized in an actual quantum computer)

• For the first question, see here Commented Jun 27 at 16:58
• @Egretta.Thula Thanks a lot! Commented Jun 27 at 17:24
• If you're interested in the details of how to derive this type of circuit, I have a notebook with a step by step description here Commented Jun 28 at 13:55
• you can edit the post and title to clarify what you're actually trying to ask. Also note that each post should contain a single question, you can ask different questions in different posts
– glS
Commented Jun 29 at 8:50

To initialize your custom state, you can use either initialize() or prepare_state() methods from the QuantumCircuit class. In this functions you just have to give your custom statevector and the circuit will be initialized to that particular state. For example to initialize a circuit in bell state:

from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector

circuit = QuantumCircuit(2)
circuit.prepare_state(Statevector([1/sqrt(2), 0, 0, -1/sqrt(2)]), circuit.qubits)
circuit.draw()


You can also use initialize similarly. (look at the links provided)

Hope this helps!

• I think I was not clear enough with my question. I understand that there is a circuit I can "code" up on Qiskit to initialize any statevector. What I asked is: how is such a general state implemented in an actual Quantum computer, either using gates, or any other methods? Commented Jun 29 at 6:51
• If you read the documentation for StatePreparation, you can see they provide the reference for where the procedure for state preparation comes from: Shende, Bullock, Markov. Synthesis of Quantum Logic Circuits (2004) Commented Jun 29 at 11:22