Quantum Computing (QC) pioneer Vazirani has graciously long provided some nice videos on an intro to QC. E.g. in "2 qubit gates + tensor product" (2014) he introduces the tensor product w.r.t. QC gates. I was generally able to follow this video but think there was one subtle point glossed over and I would like an expert to expand on it. We were discussing the tensor product in a QC meetup and the question came up if its commutative. As Wikipedia states, the tensor product is not commutative. But when combining two qubits in a gate operation, Vazirani however does not mention whether order makes any difference. In his diagrams, there is total visual symmetry across the 2 qubits. Or maybe the tensor product is commutative over unitary matrices which QC is limited to? Can someone sort out/ unpack some of these ideas?


2 Answers 2


The tensor product is not commutative, i.e. in the computational basis, $$X\otimes Z=\left( \begin{array}{cccc} 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & -1 \\ 1 & 0 & 0 & 0 \\ 0 & -1 & 0 & 0 \\ \end{array} \right)$$ while $$Z\otimes X=\left( \begin{array}{cccc} 0 & 1 & 0 & 0 \\ 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & -1 \\ 0 & 0 & -1 & 0 \\ \end{array} \right).$$ The two-qubit CNOT gate depicted in the video is not symmetric w.r.t. the two qubits (one is control, the other is target). However, the ordering of the subsystems (e.g. the qubits) is arbitrary and you can understand $X_A \otimes Z_B = Z_B \otimes X_A$, where the indices denote the subsystem. It happens quite frequently that people change the order of the subsystems to whatever order is convenient at that moment.


I'll add a bit to the other answer.

State of a two qubit system is written as $|\psi_1\rangle\otimes|\psi_2\rangle$ where $|\psi_1\rangle$ is the state vector of the first qubit and $|\psi_2\rangle$ is the state vector of the second qubit (it is upto you to decide which one will be called "first" and which one will be called "second"). The order is important, as the first member of the product is always considered to be the state of the first qubit.

$$|\psi_{\text{state}}\rangle=|\psi_1\rangle\otimes|\psi_2\rangle=|\psi_1\psi_2\rangle\quad (\text{Tensor Product})$$

However, after choosing the initial convention of the order (i.e. "first" and "second" qubit) if you're changing ordering of the subsystems, as M.Stein says, you have to mention that explicitly. You can't just suddenly write it as $|\psi_2\rangle\otimes|\psi_1\rangle$. Also, another reason why you can't change order directly is because Tensor product is not-commutative, as M.Stein already mentioned with a nice example.

A tensor product of that form can be also written as $a|00\rangle + b|01\rangle + c|10\rangle + d|11\rangle$ (where $a,b,c,d\in \Bbb{C}$). Keep in mind that even here, the first entry $\alpha$ in $|\alpha\beta\rangle$ (where $\alpha,\beta\in\{0,1\}$) is the state of the first qubit. For example when you're measuring the first qubit in the $|0\rangle,|1\rangle$ basis you'll end up with either the state $\frac{a|00\rangle+b|01\rangle}{\sqrt{|a|^2+|b|^2}}$ or the state $\frac{c|10\rangle+d|11\rangle}{\sqrt{|c|^2+|d|^2}}$. Notice that, in these two possible results, the first result explicitly implies that the first qubit turns out to be $0$ in that case, while the second possible result implies that the first qubit turns out to be $1$ in that particular case. As you can see, maintaining that order of tensor product is important, to keep track of the actual changes to the qubit system during quantum computing.


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.