|q⟩ Bad Qubits

beginner · Programming · Entanglement & Bell States

Creating Entanglement on Demand

You already know how to entangle a two-qubit register — but real quantum programs work with many qubits at once. The key insight is that the same H + CNOT recipe applies to any pair of qubits in a larger register, leaving the remaining qubits undisturbed.

Targeted entanglement in a register

Suppose you have a three-qubit register in the ground state ∣000⟩|000\rangle and you want to entangle only qubits 1 and 2. The recipe is identical to the two-qubit case: apply HH to qubit 1, then a CNOT from qubit 1 to qubit 2:

CNOT1→2 (I⊗H⊗I) ∣000⟩=∣0⟩0⊗12(∣00⟩+∣11⟩)12.\text{CNOT}_{1\to2}\,(I \otimes H \otimes I)\,|000\rangle = |0\rangle_0 \otimes \tfrac{1}{\sqrt{2}}\big(|00\rangle + |11\rangle\big)_{12}.

Qubit 0 is untouched by both gates, so it remains in ∣0⟩|0\rangle. The full three-qubit state is

12(∣000⟩+∣011⟩).\tfrac{1}{\sqrt{2}}\big(|000\rangle + |011\rangle\big).

The amplitudes on ∣001⟩|001\rangle and ∣010⟩|010\rangle are zero, and amplitude on ∣000⟩|000\rangle and ∣011⟩|011\rangle each equals 12\tfrac{1}{\sqrt{2}}, giving measurement probability 12\tfrac{1}{2} for each — a perfect Bell pair living inside a larger register.

Why qubit ordering matters

In this platform, qubit 0 is the most significant bit. So the computational-basis label for a three-qubit state reads as ∣q0q1q2⟩|q_0 q_1 q_2\rangle. When you see ∣011⟩|011\rangle, that means q0=0,  q1=1,  q2=1q_0 = 0,\; q_1 = 1,\; q_2 = 1 — qubits 1 and 2 are both 1 while qubit 0 is 0. Keep this in mind when you read the state-vector output.

Try it

Entangle qubits 1 and 2 in a three-qubit register. The grader checks the full state vector, which should have equal amplitudes on ∣000⟩|000\rangle and ∣011⟩|011\rangle only.

Run your code to see the quantum state.

After running, check the State tab: you should see two entries each with amplitude ≈0.707\approx 0.707, confirming the Bell pair is resident in the larger register.

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