# Initialising impure density matrices

I wish to initalise the state $$\rho=(1-\frac{p}{2})|0\rangle \langle0|+\frac{p}{2}|1\rangle\langle1|$$, where p is some measure of decoherence. This is a mixed state. There are some suggestions on here for how to implement this with ancilla qubits and extra gates. However I am now trying to run a quantum circuit with this as my initial state on the actual IBM quantum computers. The problem is that to intialise two qubits in this state requires 6 ancilla qubits using my current approach, meaning I have to use the Melbourne quantum computer which has moderately high gate error rates. It also increases my circuit depth. In order to simplify my circuit I tried something like this

r=random.choices([0,1],weights=(1-p/2,p/2),k=1)
r.append((r+1)%2)
circuit2 = QuantumCircuit(3,3);
circuit2.initialize(r,0)
circuit2.initialize(r,1)


Although this is statistically correct over many runs it does not give what I want. In each run of the quantum circuit (say 1000 shots), the same intial state is used for all 1000 shots. Is there any way I can make it so that the circuit reevaluates what the initial state should be for each shot?

I do not wish to have to set the number of shots to 1 and evaluate the circuit thousands of times, as the queue time to get my circuit evaluated would be huge.

• A general comment - you can always purify a mixed state of rank $r$ using some $r$ dimensional purifying system. Since your rank here is 2, you only need one qubit in the purifying system as explained in the answer.
– rnva
Sep 30, 2020 at 14:18

Why do you need 6 ancilla qubits? Surely you'd just produce the two-qubit state $$\sqrt{1-p/2}|00\rangle+\sqrt{p/2}|11\rangle$$ by starting with two qubits in $$|00\rangle$$, performing a single qubit unitary that maps $$|0\rangle\rightarrow \sqrt{1-p/2}|0\rangle+\sqrt{p/2}|1\rangle$$ (this is a $$Y$$ rotation of a suitable angle), and then perform a controlled-not controlled from that qubit, targeting the other. The reduced density matrix of either qubit is then what you want (but you should only use one of the two qubits in subsequent measurements etc).

• I don't think your method is equivalent. The CNOT will produce either $\sqrt{1-p/2}|00>+\sqrt{p/2}|01>$ or $\sqrt{1-p/2}|00>+\sqrt{p/2}|10>$ depending on which qubit is the target. The reduced density matrix is either the $|0>$ state or the pure state $\sqrt{1-p/2}|0>+\sqrt{p/2}|1>$. It is possible that this state produces the statistics I want but if this is true, I can simply initialise a single qubit in this manner without the need for an ancilla
– LOC
Sep 30, 2020 at 10:31
• No, it produces the two-qubit state that I said it does, one qubit of which has exactly the single-qubit density matrix you're asking for. Sep 30, 2020 at 10:58
• Okay I do not see how this is true. First of all, if I perform two single qubit unitaries each of which map $|0>$ to $\sqrt{1-p/2}|0>+\sqrt{p/2}|1>$, the two qubit state is $(1-p/2)|00>+(\sqrt{1-p/2}\sqrt{p/2})(|01>+|10>)+p/2|11>$ instead of $\sqrt{1-p/2}|00>+\sqrt{p/2}|11>$ is it not? Taking the partial trace of this after a CNOT then does not give me a mixed state
– LOC
Sep 30, 2020 at 23:35
• You perform ONE single qubit unitary, giving you the oveall state $\sqrt{1-p/2}|00\rangle+\sqrt{p/2}|10\rangle$, where the first qubit is the qubit I've applied the unitary to. THEN you apply controlled-not Oct 1, 2020 at 11:19
• Yes okay this makes sense, however this is different to your original answer, hence my confusion
– LOC
Oct 2, 2020 at 0:19