Quantum gates & circuits

Tensor products and controlled gates

Build a two-qubit register and follow conditional gates across its basis.

21 minCore

Intuition

Two bits have four labels. Two qubits also use four basis labels, with a complex amplitude at each label. This register convention puts q0 on the left, so exciting q0 in a two-wire register gives |10⟩.

CNOT applies X to the target for the part of the state with control value one. The control remains part of the state and evolves coherently with the target.

Learning objectives

  • Compute tensor-product coordinates
  • Read controls in a circuit
  • Trace CNOT, CZ, and SWAP

Interactive exploration

Use the controls to change the state and see its calculated readout. You can return to this experiment as you work through the derivation.

Circuit composer

q0 = leftmost bit
q0q1⊕⊕⊕
  1. CX q1 · q0
  2. CX q0 · q1
  3. CX q1 · q0
Step 3 / 3

State at step 3

4 amplitudes
BasisAmplitudeProbability
|00⟩0.0000%
|01⟩0.0000%
|10⟩1.000100%
|11⟩0.0000%

Each shot independently prepares this step’s state. A dense simulator stores 2ⁿ complex amplitudes for n wires. The composer is capped at six wires.

Mathematical foundation

The tensor product lists all pairwise products in binary order. The first factor supplies the leftmost bit.

(ab)⊗(cd)=(ac,ad,bc,bd)T\binom{a}{b}\otimes\binom{c}{d}=(ac,ad,bc,bd)^T

CNOT preserves the control bit and XORs it into the target. CZ changes the sign of |11⟩. A SWAP exchanges the two basis labels and can be built from three CNOTs with alternating controls.

CX⁡∣a,b⟩=∣a,a⊕b⟩,CZ⁡∣a,b⟩=(−1)ab∣a,b⟩\operatorname{CX}|a,b\rangle=|a,a\oplus b\rangle,\quad \operatorname{CZ}|a,b\rangle=(-1)^{ab}|a,b\rangle

Worked example

Prepare |+⟩⊗|0⟩, which places weight at 00 and 10. Under CNOT with q0 as control, 00 stays fixed and 10 becomes 11. Linearity gives equal amplitudes at 00 and 11.

CX⁡∣00⟩+∣10⟩2=∣00⟩+∣11⟩2\operatorname{CX}\frac{|00\rangle+|10\rangle}{\sqrt2}=\frac{|00\rangle+|11\rangle}{\sqrt2}

Guided experiment

Inspect the three-CNOT SWAP example. Change the basis input between |01⟩ and |10⟩, and compare intermediate and final labels.

Go to the controls
Compare with the expected result

An operation can have an equivalent implementation using a different gate sequence.

Understanding check

1. What does |0⟩⊗|1⟩ equal in Qverse’s ordering?
2. Which computational basis amplitude does CZ negate?

Next steps

Want to keep your results? Start your learning journey

Open Circuit Composer