I was trying to generate Greenberger-Horne-Zeilinger (GHZ) state for $N$ states using quantum computing, starting with $|000...000\rangle$ (N times)

The proposed solution is to first apply Hadamard Transformation on the first qubit, and then start a loop of CNOT gates with the first qubit of all the others.

I am unable to understand how I can perform CNOT($q_1,q_2$) if $q_1$ is a part of an entangled pair, like the Bell state $B_0$ which forms here after the Hadamard transformation.

I know how to write the code for it, but algebraically why is this method correct and how is it done? Thanks.


I am unable to understand how I can perform CNOT($q_1,q_2$) if $q_1$ is a part of an entangled pair, like the Bell state $B_0$ which forms here after the Hadamard transformation.

The key is to notice what happens to the computational basis states (or, for that matter, any other complete set of basis states) upon applying the relevant quantum gate(s). Doesn't matter whether the state is entangled or separable. This method always works.

Let's consider the $2$-qubit Bell state (of two qubits $A$ and $B$):

$$|\Psi\rangle = \frac{1}{\sqrt{2}}(|00\rangle + |11\rangle)$$

$|\Psi\rangle$ is formed by an equal linear superposition of the computational basis states $|00\rangle$ & $|11\rangle$ (which can be expressed as $|0\rangle_A\otimes|0\rangle_B$ and $|1\rangle_A\otimes|1\rangle_B$ respectively) and $|1\rangle_A\otimes |1\rangle_B$. We need not worry about the other two computational basis states: $|01\rangle$ and $|10\rangle$ as they are not part of the Bell state superposition $|\Psi\rangle$. A CNOT gate basically flips (i.e. does either one of the two mappings $|0\rangle \mapsto |1\rangle$ or $|1\rangle\mapsto |0\rangle$) the state of the qubit $B$ in case the qubit $A$ is in the state $|1\rangle$, or else it does nothing at all.

So basically CNOT will keep the computational basis state $|00\rangle$ as it is. However, it will convert the computational basis state $|11\rangle$ to $|10\rangle$. From the action of CNOT on $|00\rangle$ and $|11\rangle$, you can deduce the action of CNOT on the superposition state $|\Psi\rangle$ now:

$$\operatorname{CNOT}|\Psi\rangle = \frac{1}{\sqrt{2}}(|00\rangle + |10\rangle)$$


You mention in the comments that you want one of the two qubits of the entangled state $|\Psi\rangle$ to act as control (and the NOT operation will be applied on a different qubit, say $C$, depending upon the control).

In that case too, you can proceed in a similar way as above.

Write down the $3$-qubit combined state:

$$|\Psi\rangle\otimes |0\rangle_C = \frac{1}{\sqrt{2}}(|0\rangle_A\otimes |0\rangle_B + |1\rangle_A\otimes|1\rangle_B)\otimes |0\rangle_C$$ $$= \frac{1}{\sqrt{2}}(|0\rangle_A\otimes |0\rangle_B\otimes |0\rangle_C+ |1\rangle_A\otimes|1\rangle_B\otimes|0\rangle_C)$$

Let's say $B$ is your control qubit.

Once again we will simply check the action of the CNOT on the computational basis states (for a 3-qubit system) i.e. $|000\rangle$ & $|110\rangle$. In computational basis state $|000\rangle = |0\rangle_A\otimes|0\rangle_B|0\rangle_C$ notice that the state of the qubit $B$ is $|0\rangle$ and that of qubit $C$ is $|0\rangle$. Since qubit $B$ is in state $|0\rangle$, the state of qubit $C$ will not be flipped. However, notice that in the computational basis state $|110\rangle = |1\rangle_A\otimes|1\rangle_B\otimes|0\rangle_C$ the qubit $B$ is in state $|1\rangle$ while qubit $C$ is in state $|0\rangle$. Since the qubit $B$ is in state $|1\rangle$, the state of the qubit $C$ will be flipped to $|1\rangle$.

Thus, you end up with the state:

$$\frac{1}{\sqrt{2}}(|0\rangle_A\otimes|0\rangle_B\otimes|0\rangle_C + |1\rangle_A\otimes|1\rangle_B\otimes|1\rangle_C)$$

This is the Greenberger–Horne–Zeilinger state for your $3$ qubits!

  • $\begingroup$ We can use this method if we want to apply CNOT on an entangled pair. But I don't want to do that. What I want is, to take the first qubit of the entangled state $B_0$ (can't call it q1 as it is inseparable) , and apply CNOT on that (q1) and a different $|0>$ qubit. If possible please show the matrix form multiplication done. Thanks again. $\endgroup$ – Satvik Golechha Jul 16 '18 at 18:53
  • $\begingroup$ @SatvikGolechha So which one are you considering to be the control qubit (of the controlled-NOT gate): $q1$ or the "different $|0\rangle$ qubit"? The answer will depend on that. $\endgroup$ – Sanchayan Dutta Jul 16 '18 at 19:00
  • $\begingroup$ I am considering $q1$ to be the control bit. And the difficulty I'm facing is that I can't separate $q1$, and hence can't see what the CNOT gate will do to $q1$ and $|0>$. $\endgroup$ – Satvik Golechha Jul 16 '18 at 19:03
  • $\begingroup$ @SatvikGolechha Updated the answer. OK now? $\endgroup$ – Sanchayan Dutta Jul 16 '18 at 19:14
  • $\begingroup$ Thanks a bunch! Using Tensor product properties makes it all very clear, and it just fits in beautifully now. I've marked this answer as accepted. $\endgroup$ – Satvik Golechha Jul 16 '18 at 19:18

$$ \psi_1 = |0 0 0 \rangle\\ \psi_2 = (H \otimes I \otimes I) \psi_1 = \frac{1}{\sqrt{2}} (|0 \rangle + |1 \rangle) \otimes |0 0 \rangle\\ = \frac{1}{\sqrt{2}} ( |0 0 0 \rangle + |1 0 0 \rangle)\\ \psi_3 = (\operatorname{CNOT}_{12} \otimes I) \psi_2 = \frac{1}{\sqrt{2}} (|0 0 0 \rangle + |1 1 0 \rangle)\\ \psi_4 = (\operatorname{CNOT}_{13} \otimes I_{2}) \psi_3 = \frac{1}{\sqrt{2}} (|0 0 0 \rangle + |1 1 1 \rangle)\\ $$

$\operatorname{CNOT}_{ij}$ is itself an operator on $2$ qubits giving a $4\times 4$ unitary matrix. You can apply it to any state in $\mathbb{C}^2 \otimes \mathbb{C}^2$ not just those of the form $q_i \otimes q_j$. Just write the coefficients in the computational basis where you know what to do in terms of the $\operatorname{CNOT}_{ij}$ of classical reversible computing. Then just follow your linearity nose.


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.