|q⟩ Bad Qubits

beginner · Programming · Two Qubits & Tensor Products

Superposition Across Two Qubits

With a single qubit the Hadamard gate creates two equal possibilities; with two qubits we can reach four at once. This lesson shows how independent Hadamard gates expand a two-qubit register into a uniform superposition of all four basis states.

Starting from ∣00⟩|00\rangle

A two-qubit register initialised to ∣00⟩|00\rangle has state vector (1000)T\begin{pmatrix}1 & 0 & 0 & 0\end{pmatrix}^T in the ordering ∣00⟩,∣01⟩,∣10⟩,∣11⟩|00\rangle, |01\rangle, |10\rangle, |11\rangle (qubit 0 is the most significant bit). Applying HH to qubit 0 alone gives the product state

(H⊗I)∣00⟩=12(∣00⟩+∣10⟩).(H \otimes I)|00\rangle = \frac{1}{\sqrt{2}}\big(|00\rangle + |10\rangle\big).

Now apply HH to qubit 1:

(H⊗H)∣00⟩=12(∣0⟩+∣1⟩)⊗12(∣0⟩+∣1⟩).(H \otimes H)|00\rangle = \frac{1}{\sqrt{2}}\big(|0\rangle + |1\rangle\big) \otimes \frac{1}{\sqrt{2}}\big(|0\rangle + |1\rangle\big).

Expanding the tensor product gives

(H⊗H)∣00⟩=12(∣00⟩+∣01⟩+∣10⟩+∣11⟩).(H \otimes H)|00\rangle = \frac{1}{2}\big(|00\rangle + |01\rangle + |10\rangle + |11\rangle\big).

Each of the four basis states carries amplitude 12\tfrac{1}{2}, so the Born-rule probability for each outcome is ∣12∣2=14\left|\tfrac{1}{2}\right|^2 = \tfrac{1}{4}.

Why use two independent Hadamards?

Because the two qubits do not interact — there is no entanglement here — the operation decomposes as H⊗HH \otimes H. In circuit notation this is simply a Hadamard on qubit 0 followed (or preceded, since they commute) by a Hadamard on qubit 1. The order does not matter because single-qubit gates on different qubits always commute — this is a consequence of the tensor-product structure of the operators, independent of the entanglement of the state.

Try it

Apply a Hadamard gate to each qubit so the register ends in the uniform superposition 12(∣00⟩+∣01⟩+∣10⟩+∣11⟩)\tfrac{1}{2}(|00\rangle + |01\rangle + |10\rangle + |11\rangle). The grader checks the full statevector, so every amplitude must be correct.

Run your code to see the quantum state.

After running, inspect the amplitudes tab: all four entries should read ≈0.500\approx 0.500, and the probabilities tab should show four equal bars at 25%25\% each.

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