I want to prepare some mixed states regarding a project that I am doing, however, I am not sure how to do that using IBM Q. Experience circuit composer. Basically, I am looking to prepare maximally mixed and non-maximally mixed quantum states. I have attached the circuit which I could come up with.enter image description here

  • $\begingroup$ If you ignore the measurement result ($c1$), the $q0$ qubit is in the mixed state. $\endgroup$
    – kludg
    Commented Jan 29, 2020 at 15:09
  • $\begingroup$ As far as I know, mixed states are basically |0> and |1> states in classical (but random) combination. So does q0 satisfy that? Also, if q0 is in a mixed state, why does that CNOT gate have any effect? Plus, can I measure a mixed state? i.e., why does the measurement change mixed state? $\endgroup$ Commented Jan 30, 2020 at 14:23
  • $\begingroup$ You can think of a mixed state as of a classical statistical mixture of pure states; if you measure $|+\rangle$ state in the standard basis and do not look at the measurement result, than you get a classical statistical mixture of $|0\rangle$ and $|1\rangle$ states, both are equally likely; this is a mixed state; the repeated measurement in the standard basis does change it, provided you do not look at the measurement result again; you can think that really the state is either $|0\rangle$ or $|1\rangle$, you just don't know. $\endgroup$
    – kludg
    Commented Jan 30, 2020 at 17:41
  • $\begingroup$ okay, but what is the use of CNOT? Also, according to you, we are just pretending a superposition (pure) state as mixed? $\endgroup$ Commented Jan 31, 2020 at 14:34

1 Answer 1


A mixed state is described by a density matrix consisting of a sum of projection operators corresponding to the possible states of the system, weighted by the classical probabilities of being in each state. The register of qubits in a quantum computer is always a state vector. A density matrix can be constructed by taking a large number of shots of a system and averaging together. Unfortunately, the measurements are only in the computational basis, so reconstructing the full density matrix requires additional work to get all of the components of the density matrix. This is known as tomography and usually scales exponentially with the number of qubits, and is thus computationally very expensive. This can however be done on simulators for reasonable sized circuits.

An example (only works on master branch at the moment):

from qiskit import *
from qiskit.quantum_info.states.utils import partial_trace
qc = QuantumCircuit(2, 2)
qc.cx(0, 1)

sim =  Aer.get_backend('statevector_simulator')
res = execute(qc, sim, shots=1).result()
state_vec = res.get_statevector()

# Remove qubit zero
partial_trace(state_vec, [0])

  • $\begingroup$ Okay, can you please show me how could I create a simple 1 qubit mixed state? Plus, how can I create a non-maximally mixed state? If I am correct, the Bloch sphere is a unit radius sphere with all the vectors lying on the surface of this. Any mixed state lies inside the Bloch sphere(i.e., distance from origin<1)... Does this mean that the probability is less than 1? $\endgroup$ Commented Jan 30, 2020 at 14:25
  • $\begingroup$ See example above. $\endgroup$ Commented Jan 31, 2020 at 12:18
  • $\begingroup$ I am afraid it is not of much help. I tried running it, but there is a NoModuleError, because of the second line. I am unable to implement it using circuit composer $\endgroup$ Commented Jan 31, 2020 at 14:41
  • $\begingroup$ You need the latest master branch: github.com/Qiskit/qiskit-terra/archive/master.zip $\endgroup$ Commented Jan 31, 2020 at 14:44

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.