Is there there any way to create a known quantum state in Qiskit (or any other platform) comprising of two or more than two bit?

For example if I want to create $\frac{1}{\sqrt{3}}[|00\rangle+|01\rangle+|11\rangle]$. What I want to do is to know the unitary transformation ( or the quantum circuit) to prepare this (or any valid) quantum state for me.


1 Answer 1


As Martin Vesely mentioned in the comments, you can use the initialize function to perform such a task. For instance, to create the state you desire, you can do the following:

import numpy as np
from qiskit import QuantumCircuit
from qiskit.transpiler.passes import Decompose

qc = QuantumCircuit(2)
initial_state = np.array([1, 1, 0, 1], dtype=float)
initial_state /= np.linalg.norm(initial_state)

which draws the following output:

Decomposed circuit

To know how does qiskit create this unitary, have a look at this answer.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.