I am a little confused about where I am going wrong when computing the action of the following circuit:

enter image description here

My understanding is that the CNOT gate acts on the second qubit as a control and the first qubit as a target. However, we can flip the CNOT so that it is acting as a control on the first qubit and target on the second qubit by introducing $H \otimes H$ before and after the CNOT gate.

Now the circuit looks like:

enter image description here

I work through the circuit as follows:

Original states:

$$T|+\rangle = \frac{|0\rangle + w |1\rangle}{\sqrt{2}}$$ $$|\psi\rangle = \alpha |0\rangle + \beta |1\rangle$$

Action of $H \otimes H$ on the states:

$$H T|+\rangle = \frac{(1 + w)|0\rangle + (1-w)|1\rangle}{2}$$

$$H|\psi\rangle = \frac{(\alpha + \beta)|0\rangle + (\alpha - \beta)|1\rangle}{\sqrt{2}}$$

Action of CNOT on the resulting states:

$$CNOT(1 \rightarrow 2): \frac{1}{2 \sqrt(2)}( (1+w)(\alpha + \beta)|00 \rangle + (1+w)(\alpha - \beta)|01 \rangle + (1-w)(\alpha + \beta)|10 \rangle + (1-w)(\alpha - \beta)|11 \rangle )$$

Action of $H \otimes H$ on the resulting state:

$$(H \otimes H)(T|+\rangle \otimes |\psi \rangle) = \frac{1}{\sqrt{2}} \alpha |00\rangle + \beta |01\rangle + w\alpha |10\rangle + w\beta |11\rangle $$

But then, if I measure this state, I do not get $T|\psi\rangle$ (when I measure the first qubit) or $TS|\psi\rangle$ (when I measure the second qubit) as the circuit suggests?

Instead I get $\frac{1}{\sqrt{2}}(\alpha |0\rangle + \beta |1\rangle)$ when I measure the first qubit and $\frac{1}{\sqrt{2}}(w\alpha|0\rangle + w\beta|1\rangle)$ when I measure in the second qubit.

Can anyone identify what I am doing wrong here?

  • 2
    $\begingroup$ As the answer says (although expressed slightly differently) I think you've just expanded the two-qubit state before applying the controlled-not without ever applying the controlled-not, which will change $10\leftrightarrow 11$. $\endgroup$
    – DaftWullie
    Commented Mar 25 at 13:23

2 Answers 2


When applying the CNOT(1 $\rightarrow$ 2) you got confused in the last row. The $(1-\omega)|1\rangle$ flips the second qubit so $(\alpha+\beta)|0\rangle$ turns into $(\alpha+\beta)|1\rangle$ (and the same for the other term). So the resulting state is $(1-\omega)(\alpha - \beta)|10\rangle + (1-\omega)(\alpha+\beta)|11\rangle$.

  • $\begingroup$ Thank you, I understand my mistake. Although, where did the factor of $\frac{1}{\sqrt{2}}$ go? $\endgroup$
    – am567
    Commented Apr 16 at 9:39

After the second $H\otimes H$ operator, once the mistake with the CNOT is corrected, the qubits should be in this state:

$$\frac{1}{\sqrt{2}}\left(\alpha\left|00\right\rangle + \beta\omega\left|01\right\rangle + \alpha\omega\left|10\right\rangle + \beta\left|11\right\rangle\right)$$

Once the first (leftmost) qubit is measured, the second qubit is either directly in state $\alpha\left|0\right\rangle + \beta\omega\left|1\right\rangle$ if $|0\rangle$ came out (in which case you do not need to apply the classically-controlled $S$ correction to the second qubit) or it is in state $\alpha\omega\left|0\right\rangle + \beta\left|1\right\rangle=\alpha\left|0\right\rangle + \beta\omega^{-1}\left|1\right\rangle$ and in that case you need to apply $S$ to retrieve the correct state.

  • $\begingroup$ why isn't it in the state $\frac{1}{\sqrt{2}} (\alpha |00\rangle + \beta w |01 \rangle + \alpha w |10 \rangle + \beta |11 \rangle)$? $\endgroup$
    – am567
    Commented Apr 16 at 9:38
  • 1
    $\begingroup$ I omitted this constant out of habits, but you are certainly correct. $\endgroup$
    – AG47
    Commented Apr 16 at 9:42

Your Answer

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