# How to prepare mixed states using IBM quantum experience?

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.

• If you ignore the measurement result ($c1$), the $q0$ qubit is in the mixed state. Jan 29 '20 at 15:09
• 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? Jan 30 '20 at 14:23
• 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. Jan 30 '20 at 17:41
• okay, but what is the use of CNOT? Also, according to you, we are just pretending a superposition (pure) state as mixed? Jan 31 '20 at 14:34

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.h(0)
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])


• 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? Jan 30 '20 at 14:25
• See example above. Jan 31 '20 at 12:18
• 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 Jan 31 '20 at 14:41
• You need the latest master branch: github.com/Qiskit/qiskit-terra/archive/master.zip Jan 31 '20 at 14:44