to evolve a 4x4 density matrix I use this method:

rhoafter = np.dot(np.dot(gate,rhobefore),np.conjugate(gate.T))

And I want to find the gate from rhobefore and rhoafter density matrices. Based on if C = np.dot(A,B) then A= np.linalg.solve(B.T, C.T).T
I end with this equation:

mygate = np.linalg.solve(rhobefore.T,(np.linalg.solve((np.conjugate(gate.T)).T, rhoafter.T).T).T).T

But mygate and gate, that must be equal( or equivalent ) are on the left and the right, and I don't know how get the gate from there. Is there a method in Qiskit or cirq to do this task?.

  • $\begingroup$ The solution is not unique. Suppose $\rho=|0\rangle\langle0|$ is left unchanged by $U$. Then $U$ must be $\begin{pmatrix}1&0\\0&\mathrm{e}^{\mathrm{i}\varphi}\end{pmatrix}$, with no constraint on $\varphi$ apart from being real. Thus, there's a whole continuum of gates that are solution of this problem. $\endgroup$
    – Tristan Nemoz
    Commented Jul 13, 2023 at 21:09
  • $\begingroup$ But there is another problem, for inverting dot with linalg.solve, because if rhobefore is not invertible, then the solution is an equivalent gate matrix only for that case, not for example the cx(0,1) matrix that is valid for all rhos. If i test with random rhobefore matrixs it returns fine the cx(0,1) gate,because all are invertible, but rhos from qiskit random_statevector are not invertible. So quantum rho's are annoying matrices $\endgroup$ Commented Jul 13, 2023 at 23:06
  • $\begingroup$ But traced rho's are invertible, so it's a matter to apply a search(random or numba loops) on gate array variable from the equation in the post .The gate result will be the one with the closest distance between mygate and gate. So it looks to be possible $\endgroup$ Commented Jul 14, 2023 at 1:43


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.