If I have a one gate circuit like in the following image:
I can calculate the density matrix by following steps:
However, I want to do it for the Toffoli gate circuit:
and I am confused with the initial density matrix. How to write an initial density matrix for 3 qubits?
I used qiskit to compute it and I used the following code:
qc_AB = QuantumCircuit(3)
qc_AB.h(2)
qc_AB.cx(1,2)
qc_AB.tdg(2)
qc_AB.cx(0,2)
qc_AB.t(2)
qc_AB.cx(1,2)
qc_AB.tdg(2)
qc_AB.cx(0,2)
qc_AB.cx(0,1)
qc_AB.h(2)
qc_AB.t(0)
qc_AB.tdg(1)
qc_AB.cx(0,1)
qc_AB.draw()
rho_AB = qi.DensityMatrix.from_instruction(qc_AB)
rho_AB.draw('latex', prefix='\\rho_{AB} = ')
According the qiskit my initial density matrix is here:
How to calculate it by hand? I am not sure this initial density matrix is correct or not...