Hello, I'm new to QuTiP and do not fully understand how to use its partial trace function or why I'm seemingly not able to multiply matrices of the same dimension. Here is what I am trying to do:
state0 = qt.basis(2, 0)
state1 = qt.basis(2, 1)
density_matrixA_0 = .25 * state0 * state0.dag()
density_matrixA_1 = .75 * state1 * state1.dag()
density_matrixA = density_matrix0 + density_matrix1
density_matrixB_0 = .75 * state0 * state0.dag()
density_matrixB_1 = .25 * state1 * state1.dag()
density_matrixB = density_matrix0 + density_matrix1
# I would then convert density_matrixA and B into numpy arrays here so that the multiplication below can be carried out
unitary = np.array([[1,0,0,0],[0,.5,.5,0],[0,-.5,.5,0],[0,0,0,1]])
unitary_dag = unitary.conj().T
entangled_12 = unitary*(np.kron(density_matrixA, density_matrixB))*unitary_dag
entangled_12 = qt.Qobj(entangled_12)
qubit1_trace = entangled_12.ptrace(0)
qubit2_trace = entangled_12.ptrace(1)
I am allowed to take entangled_12.ptrace(0) but the entangled_12.ptrace(1) line throws the error "Invalid selection index in ptrace" and I don't understand why. I'm guessing that I just don't understand what ptrace() is doing enough but I can't find any documentation online besides a single example of what I tried with entangled_12.ptrace(0).
I also don't understand why I'm not able to compute:
unitary*qt.tensor(density_matrixA, density_matrixB)*unitary_dag
when I instead initialize unitary as a QuTiP object. I get the error "incompatible dimensions [[4], [4]] and [[2, 2], [2, 2]]" when I try this. I'm assuming that this is because Python isn't actually taking the tensor product of density_matrixA and density_matrixB before multiplying unitary by it but, again, I'm not sure and there isn't good documentation on this online that I've found.
I'd be very grateful if anyone was able to explain what I'm doing wrong here. I haven't been able to find help from documentation online.