|q⟩ Bad Qubits

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

Checkpoint: Controlled-Gate Puzzles

Module 11 introduced three families of two-qubit controlled gates — CNOT, CZ, and SWAP — and the identities that connect them. This checkpoint asks you to combine those tools to realize a specific target operation.

The target: a Bell-basis encoder

A natural and important two-qubit unitary is the Bell-basis encoder UBellU_\text{Bell}. It maps each computational basis state to a distinct Bell state:

00    Φ+=12(00+11),|00\rangle \;\mapsto\; |\Phi^+\rangle = \tfrac{1}{\sqrt{2}}\bigl(|00\rangle + |11\rangle\bigr), 01    Ψ+=12(01+10),|01\rangle \;\mapsto\; |\Psi^+\rangle = \tfrac{1}{\sqrt{2}}\bigl(|01\rangle + |10\rangle\bigr), 10    Φ=12(0011),|10\rangle \;\mapsto\; |\Phi^-\rangle = \tfrac{1}{\sqrt{2}}\bigl(|00\rangle - |11\rangle\bigr), 11    Ψ=12(0110).|11\rangle \;\mapsto\; |\Psi^-\rangle = \tfrac{1}{\sqrt{2}}\bigl(|01\rangle - |10\rangle\bigr).

The four Bell states form an orthonormal basis for the two-qubit space — they span the same space as the computational basis, just rotated. Because UBellU_\text{Bell} maps one orthonormal basis to another, it is unitary: UBellUBell=IU_\text{Bell}^\dagger U_\text{Bell} = I.

Reading off the circuit

To figure out what gates to use, look at the first row of the map. Starting from 00|00\rangle, the output Φ+=12(00+11)|\Phi^+\rangle = \tfrac{1}{\sqrt{2}}(|00\rangle + |11\rangle) is the Bell state built in the "CNOT on Superpositions" lesson. The recipe is:

  1. Apply HH to qubit 0, turning 0|0\rangle into +=12(0+1)|+\rangle = \tfrac{1}{\sqrt{2}}(|0\rangle + |1\rangle).
  2. Apply CNOT(01)\text{CNOT}(0 \to 1), entangling the qubits.

Let us verify that the same two-gate sequence maps the remaining basis states correctly.

Input 01|01\rangle:

01  HI  12(0+1)1=12(01+11).|01\rangle \;\xrightarrow{H \otimes I}\; \tfrac{1}{\sqrt{2}}(|0\rangle + |1\rangle)|1\rangle = \tfrac{1}{\sqrt{2}}\bigl(|01\rangle + |11\rangle\bigr).

CNOT flips qubit 1 when qubit 0 is 1|1\rangle, so 1110|11\rangle \to |10\rangle while 01|01\rangle stays:

12(01+10)=Ψ+.\tfrac{1}{\sqrt{2}}\bigl(|01\rangle + |10\rangle\bigr) = |\Psi^+\rangle. \checkmark

Input 10|10\rangle:

10  HI  12(01)0=12(0010),|10\rangle \;\xrightarrow{H \otimes I}\; \tfrac{1}{\sqrt{2}}(|0\rangle - |1\rangle)|0\rangle = \tfrac{1}{\sqrt{2}}\bigl(|00\rangle - |10\rangle\bigr),

and after CNOT (1011|10\rangle \to |11\rangle):

12(0011)=Φ.\tfrac{1}{\sqrt{2}}\bigl(|00\rangle - |11\rangle\bigr) = |\Phi^-\rangle. \checkmark

Input 11|11\rangle:

11  HI  12(0111)  CNOT  12(0110)=Ψ.|11\rangle \;\xrightarrow{H \otimes I}\; \tfrac{1}{\sqrt{2}}\bigl(|01\rangle - |11\rangle\bigr) \;\xrightarrow{\text{CNOT}}\; \tfrac{1}{\sqrt{2}}\bigl(|01\rangle - |10\rangle\bigr) = |\Psi^-\rangle. \checkmark

All four inputs produce the correct Bell state, confirming that UBell=CNOT(01)(HI)U_\text{Bell} = \text{CNOT}(0 \to 1) \cdot (H \otimes I).

The unitary grader

This exercise uses the unitary grader: it extracts the full 4×44 \times 4 matrix of your circuit and compares it to the reference. Every column of the matrix is the image of one computational basis state under your circuit, so each column must match one of the four Bell states shown above. An empty circuit, a circuit with only HH, or a circuit with only CNOT will all fail — both gates are required.

Try it

Build UBellU_\text{Bell}: apply HH to qubit 0, then CNOT with control 0 and target 1. The grader checks the whole unitary matrix.

Run your code to see the quantum state.

After running, inspect the Unitary panel: the four columns should each show two amplitudes of magnitude 120.707\tfrac{1}{\sqrt{2}} \approx 0.707 at positions {00,11}\{|00\rangle, |11\rangle\}, {01,10}\{|01\rangle, |10\rangle\}, {00,11}\{|00\rangle, |11\rangle\}, and {01,10}\{|01\rangle, |10\rangle\} (with appropriate signs), confirming the Bell-state structure of the encoder.

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