As I was reading Qiskit textbook and there is this problem ... How can I swap a $|+\rangle$ to a $|-\rangle$
-
2$\begingroup$ Just prepare a qubit (let ie be $q_0) $in the state $|+\rangle$, another qubit (let it be $q_1$) in the state $|-\rangle$ and swap them ($SWAP(q_0, q_1)$). If you are looking for something else provide more detailed explanantion please. $\endgroup$– OhadOct 2, 2022 at 12:19
-
$\begingroup$ what if I don't want to use SWAP gate instead I want to use only CNOT gate to swap these state? $\endgroup$– RayhanOct 2, 2022 at 12:47
-
1$\begingroup$ $SWAP(0,1) = CNOT(0,1) \circ CNOT(1,0) \circ CNOT(0,1)$. See algassert.com/post/1717 $\endgroup$– OhadOct 2, 2022 at 13:07
-
5$\begingroup$ It is unclear to me if you are talking about "swap" in the sense of swapping two qubits or just "swap" in the sense transform a single qubit state from $|+\rangle$ to $|-\rangle$. in the latter case, just apply a $Z$ gate. $\endgroup$– MauricioOct 2, 2022 at 14:19
-
4$\begingroup$ Also please add a link to the chapter Qiskit Textbook. $\endgroup$– MauricioOct 2, 2022 at 14:20
1 Answer
So here is the chapter of the Qiskit textbook the OP has linked https://qiskit.org/textbook/ch-gates/more-circuit-identities.html#swapping.
There are many equivalent circuits that will swap two qubit registers simply because two equal CNOTs in sequence act as an identity map. Therefore one possibility might be simply to increase the given examples before in the textbook $$CNOT_{01}CNOT_{10}CNOT_{01}$$ and $$CNOT_{10}CNOT_{01}CNOT_{10}$$ to virtually anything such as $$CNOT_{01}CNOT_{10}CNOT_{10}CNOT_{10}CNOT_{01}CNOT_{01}CNOT_{01}.$$
I imagine that this is suggested as an exercise given that some error mitigation schemes use this fact to trace errors in two-qubit gates. Strictly speaking, this is a different circuit that also swaps to qubit registers equivalently.
This is why I don't think the question is "How can I swap" because this is answered by the two circuits before, which are the CNOT representations of the SWAP gate. Essentially, the SWAP gate is capable of swapping registers. Also, it is easily generalized to any multi-qubit register.