|q⟩ Bad Qubits

beginner · Programming · Controlled Gates: CNOT, CZ, SWAP

CNOT on Superpositions

When a CNOT gate's control qubit is in a definite basis state, its behavior is purely classical: flip the target or don't. Things change dramatically when the control is in superposition — the gate acts on both branches at once, and the result has no classical counterpart.

Linearity turns superposition into entanglement

Suppose the control starts in +=12(0+1)|+\rangle = \tfrac{1}{\sqrt{2}}(|0\rangle + |1\rangle) and the target in 0|0\rangle. The two-qubit state before the CNOT is

+0=12(0+1)0=12(00+10).|+\rangle|0\rangle = \tfrac{1}{\sqrt{2}}\bigl(|0\rangle + |1\rangle\bigr)|0\rangle = \tfrac{1}{\sqrt{2}}\bigl(|00\rangle + |10\rangle\bigr).

CNOT is a linear operator, so it acts on each term separately:

CNOT00=00,CNOT10=11.\text{CNOT}\,|00\rangle = |00\rangle, \qquad \text{CNOT}\,|10\rangle = |11\rangle.

Putting the pieces back together:

CNOT(+0)=12(00+11).\text{CNOT}\bigl(|+\rangle|0\rangle\bigr) = \tfrac{1}{\sqrt{2}}\bigl(|00\rangle + |11\rangle\bigr).

This is the Bell state Φ+|\Phi^+\rangle. It cannot be written as a product of two independent single-qubit states — the two qubits are entangled. A measurement of qubit 0 yields 0 or 1 with equal probability, but whichever outcome appears, qubit 1 is instantly found in the same state.

The recipe: H then CNOT

Preparing Φ+|\Phi^+\rangle takes exactly two gates:

  1. H on the control — turns 0|0\rangle into +|+\rangle.
  2. CNOT(control, target) — entangles the pair.

This two-gate sequence is the most common entry point to quantum entanglement and underlies protocols such as quantum teleportation and superdense coding.

Try it

Build the Bell state Φ+=12(00+11)|\Phi^+\rangle = \tfrac{1}{\sqrt{2}}\bigl(|00\rangle + |11\rangle\bigr). Apply HH to qubit 0 first, then use CNOT with control 0 and target 1. The grader checks the full state vector.

Run your code to see the quantum state.

After running, the Amplitudes panel should show 0.707\approx 0.707 for 00|00\rangle and 11|11\rangle and zero for the other two basis states — the signature of a maximally entangled pair.

Sign in on the full site to ask questions and join the discussion.