Consider the product of gates acting on two qubits: $$ \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ \end{pmatrix} \cdot \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ \end{pmatrix} \cdot \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \\ 0 & 0 & \frac{1}{\sqrt{2}} & -\frac{1}{\sqrt{2}} \\ \end{pmatrix}. $$ This is a controlled Hadamard, then SWAP, then CNOT. On the basis $$ \begin{pmatrix} 00 \\ 01 \\ 10 \\ 11 \end{pmatrix} $$ This leaves us, before the last CNOT, in the basis, $$ \begin{pmatrix} 00 \\ 1 + \\ 01 \\ 1 - \end{pmatrix}. $$ It's hard for me to see the last CNOT as a control on a 1 state anymore. Am I missing something simple, or has the interpretation just been lost since I changed basis? I guess I'm wondering why even make the usual statement that CNOT (or any controlled gate) is used with a ''control'' and ''target'' since in some simple steps I can very rapidly move away from that interpretation. It seems like it should just be interpreted as another SWAP that just moves around the vector elements. Is my understanding of this correct? Thanks.
1 Answer
The normal interpretation of the controlled-not is certainly only relevant to the standard basis. In fact, if you choose a different basis, such as the $|\pm\rangle$ basis, then the role is entirely reversed, due to the circuit identity
So, you might complain that the name is not fair if it only applies to one particular basis. But you have to give it some name to distinguish it from the other gates, and calling it the same as you would call it in classical computation is more than reasonable.
Yes, as you say, it is a permutation matrix (I guess this is what you mean by 'swap') but that hardly distinguishes it from many other permutation matrices.
By the same token, consider the single-qubit $X$ matrix. Also called the bit-flip. In the computational basis, it flips bit values. But in a different basis, such as the Hadamard basis, it doesn't.
I should also mention that I don't think your calculation of your circuit is correct. If you start with the collection $\{|00\rangle,|01\rangle,|10\rangle,|11\rangle\}$, the controlled-Hadamard maps these to $\{|00\rangle,|01\rangle,|1+\rangle,|1-\rangle\}$, and the swap then maps them to $\{|00\rangle,|10\rangle,|+1\rangle,|-1\rangle\}$, which is not what you stated. When you apply the controlled-not on these, some of them (the latter two) will be entangled.
Let me run through one specific example: cNOT applied to $|+1\rangle$. The way that I work this out is the expand it as $(|0\rangle+|1\rangle)|1\rangle/\sqrt{2}$. I apply the controlled-not by using linearity and thinking about exactly the description of how it works on basis states: $|01\rangle\mapsto|01\rangle$ and $|11\rangle\mapsto|10\rangle$, so the output is $(|01\rangle+|10\rangle)/\sqrt{2}$.
-
$\begingroup$ Thank you. +1. That solidifies my reasoning. My middle matrix just switches the middle two entries of the vector (also a permutation). Do you mean I misused the name SWAP for that matrix? I think it's correct, no? $\endgroup$– kηivesCommented Feb 26, 2020 at 16:10
-
$\begingroup$ If you had a normal vector describing a state, then that's how you apply the swap gate. But that's not what you're conveying. You're talking about how a set of basis states transforms (hence, why I used a different notation, and did not put them in a vector). Each of those basis states is a vector and you need to work out how the swap changes that vector. $\endgroup$ Commented Feb 26, 2020 at 16:12
-
$\begingroup$ The first two gates in my question, when applied in order change $\{ |00\rangle, |01\rangle, |10\rangle, |11\rangle \}$ into $\{ |00\rangle, |1+\rangle, |01\rangle, |1-\rangle \}$. That is correct I think, and that matrix multiplication is straightforward, which is what I meant to convey. I don't think it's wrong. Maybe I'm missing something you're trying to say? That is the definition of the SWAP gate from wikipedia. $\endgroup$– kηivesCommented Feb 26, 2020 at 16:27
-
$\begingroup$ controlled-Hadamard on $|10\rangle$ gives $|1+\rangle$. If you swap it, it just swaps the state of the two qubits, so you get $|+1\rangle$. You seem to be claiming that you should get $|01\rangle$. $\endgroup$ Commented Feb 26, 2020 at 16:29
-
$\begingroup$ I'm claiming that the matrix multiplication above does what I say it does. It's a simple statement. It's a vector with four entries. Where are we differing? The middle matrix swaps the $01$ element with the $1+$ element. $\endgroup$– kηivesCommented Feb 26, 2020 at 16:32