I am bit confused with calculating the overall state of a quantum gate and the individual wire states.

For example, lets say there are two Qubits, where Q1 is in $\frac{1}{\sqrt{2}}(\vert 0\rangle + \vert 1\rangle)$ state and Q2 is in $\vert 0\rangle$ state. Then we have CNOT gate controlled by Q1 on Q2 followed by a Hadamard gate at the Q1 gate.

Just after the CNOT gate the total state of the system is $\frac{1}{\sqrt{2}}(\vert 00\rangle+\vert 11\rangle)$.

Then applying the Hadamard gate gives us: $\frac{1}{2}(\vert 00\rangle+\vert 10\rangle+ \vert 01\rangle - \vert 11\rangle)$. As you can see, we get four possibilities of states.

What if I perform the calculations on individual wires? i.e.

  1. We perform Hadamard on the first Q1 bit, $\frac{1}{\sqrt{2}}(\vert 0\rangle + \vert 1\rangle)$ state which gives us $\vert 0\rangle$ state
  2. Then for the Q2, apply CNOT which gives $\vert 0\rangle$
  3. Then we calculate the overall state which is $\vert 00\rangle$

But then we do not get the same answer as before. Are we allowed to calculate like this or am I doing something wrong here?


  • $\begingroup$ The first and second operations don't commute, so the order you apply them in matters. $\endgroup$ – GaussStrife Sep 30 '20 at 15:08
  • $\begingroup$ Hi GaussStrife, I have made a mistake in my explanation. Actually it should be in the following order. (1) For Q2, apply CNOT which gives |1>. (2) We perform Hadamard on the first Q1 bit 1/root(2)(|0>+|1>) state which gives us back |0> state (3)Then we calculate the overall state which is |01> $\endgroup$ – radar101 Sep 30 '20 at 16:45
  • $\begingroup$ CNOT is a two qubit gate, you would need to apply NOT to Q2 to get $|0\rangle$. If you want to apply a two qubit gate to a single qubit, you need to add an ancillary one, then act on both with the unitary and then trace out the second qubit after. $\endgroup$ – GaussStrife Sep 30 '20 at 19:37

You cannot do this. I don't quite understand how you think step 1 reduces from $(|0\rangle+|1\rangle)/\sqrt{2}$ to $|0\rangle$. Perhaps you're assuming some statistical sampling of measurement outcomes. But the whole point of a quantum computation is to get interesting interference between different components, so you cannot just drop components. You need them.

  • $\begingroup$ Hi DaftWullie, thanks for the reply. I’m step 1, I am applying Hadamard to the 1/root(2)(|o> + |1>) which gives back |0> state. So basically we always have to get the combine state and apply gates when we design Quantum gates? Am I correct? $\endgroup$ – radar101 Sep 30 '20 at 14:24
  • $\begingroup$ I thought you didn't do the Hadamard until after the controlled-not? $\endgroup$ – DaftWullie Sep 30 '20 at 14:57
  • $\begingroup$ CNOT is before Hadamard. I was actually trying to apply the gates individually for each Qubit and then as a final step combine the both Qubit states. Since I am applying the gates individually for each Qubit, CNOT is first applied to the second Qubit and then Hadamard is applied to the 1st Qubit. Then combine the both states. So it seems like this approach is in correct. I should always combine the states and then apply the gates. Am I correct? $\endgroup$ – radar101 Sep 30 '20 at 16:02

The point is that the CNOT gate with qubit 1 as control and qubit 2 as target and the Hadamard gate on qubit 1 (and identity gate on qubit 2) do not commute. The order you do them in does matter! In your second circuit, you are doing the Hadamard before the CNOT.

This non-commutativity can be explicitly verified by showing that the matrices

$$CNOT = \begin{pmatrix} 1& 0& 0 & 0 \\ 0& 1& 0 & 0 \\ 0& 0& 0 & 1 \\ 0& 0& 1 & 0 \end{pmatrix}$$


$$H\otimes I = \begin{pmatrix} 1& 0& 1 & 0 \\ 0& 1& 0 &1 \\ 1& 0& -1 & 0 \\ 0& 1& 0 & -1 \end{pmatrix}$$

do not commute.

  • $\begingroup$ Hi rnva, there is a mistake in my second explanation. I am actually doing CNOT on the second Qubit and then apply Hadamard on the first Qubit. So my question is, instead of applying the tensor product between the two Qubit and then apply the gates, I want to apply the gates on individual Qubits and then in the final step apply the tensor product. Is this is a correct approach? $\endgroup$ – radar101 Sep 30 '20 at 17:35
  • $\begingroup$ The CNOT cannot be applied on an individual qubit - it is a two qubit gate. Since the control qubit is in superposition, the second qubit must be entangled with the first qubit. It is not $\vert 1\rangle$ as you are trying to claim. $\endgroup$ – rnva Sep 30 '20 at 17:40
  • $\begingroup$ Thanks for the explanation. So in this case after a CNOT it is entangled and as a result we must apply gates on the entire system in the following subsequent gates. Lets say if there is no CNOT, and some other gates applied to each Qubit (No entangled Qubits). Does it make sense to calculate the overall state by using tensor product? $\endgroup$ – radar101 Sep 30 '20 at 18:13
  • $\begingroup$ Yes, if you only have single qubit gates, then each register (or wire as you call it) is independent and your approach is fine. $\endgroup$ – rnva Sep 30 '20 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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