I am trying to implement the partial trace operation on IBMs quantum computer. I am simulating the depolarising channel with the following code
#aim here is to build the decoherence channel p=0.1; z=0.5+0.5*math.sqrt(1-p); desiredvec=[ math.sqrt(1-z), math.sqrt(z)] circuit2 = QuantumCircuit(4,3); circuit2.initialize(desiredvec,0) circuit2.initialize(desiredvec,1) circuit2.initialize(desiredvec,2) circuit2.cx(0,3) circuit2.h(3) circuit2.s(3) circuit2.cx(1,3) circuit2.h(3) circuit2.s(3) circuit2.cx(2,3) circuit2.h(3) circuit2.s(3) circuit2.draw()
I would now like to trace out all but qubit 3 as it is the only qubit I am interested in. I can get around this by just ignoring the other qubits but I would rather not do this. Is there any easy way to trace out unwanted qubits?
Or equivalently is there a way to initalise the qubit in a mixed state so that the extra ancillary qubits aren't needed in the first place?