|q⟩ Bad Qubits

intermediate · Programming · Multi-Qubit Registers & State Simulation

The 2ⁿ State Vector

Classical computers store nn bits and that gives nn independent pieces of information — add a bit, add a slot. A quantum register works very differently: nn qubits require a state vector with 2n2^n complex amplitudes. This exponential growth is both the source of quantum computing's potential power and the reason classical simulation becomes infeasible quickly.

One qubit, two amplitudes

A single qubit lives in a two-dimensional complex Hilbert space. Any pure state can be written

ψ=α0+β1,α,βC,α2+β2=1.|\psi\rangle = \alpha|0\rangle + \beta|1\rangle, \qquad \alpha, \beta \in \mathbb{C}, \quad |\alpha|^2 + |\beta|^2 = 1.

The two numbers α\alpha and β\beta are the amplitudes: complex numbers whose squared magnitudes give measurement probabilities via the Born rule.

Two qubits, four amplitudes

When we combine two qubits the joint state lives in the tensor-product space C2C2C4\mathbb{C}^2 \otimes \mathbb{C}^2 \cong \mathbb{C}^4. The computational basis is now {00,01,10,11}\{|00\rangle, |01\rangle, |10\rangle, |11\rangle\} and the general state is

ψ=α0000+α0101+α1010+α1111,|\psi\rangle = \alpha_{00}|00\rangle + \alpha_{01}|01\rangle + \alpha_{10}|10\rangle + \alpha_{11}|11\rangle,

with four amplitudes satisfying x{0,1}2αx2=1\sum_{x \in \{0,1\}^2} |\alpha_x|^2 = 1.

Notice the index xx runs over all 2-bit strings. For two qubits that is 22=42^2 = 4 strings.

nn qubits: 2n2^n amplitudes

The pattern continues. For an nn-qubit register the computational basis is all nn-bit strings x{0,1}nx \in \{0,1\}^n, so there are exactly 2n2^n basis states and 2n2^n amplitudes:

ψ=x{0,1}nαxx,xαx2=1.|\psi\rangle = \sum_{x \in \{0,1\}^n} \alpha_x |x\rangle, \qquad \sum_x |\alpha_x|^2 = 1.

Each amplitude αxC\alpha_x \in \mathbb{C} encodes how much probability amplitude "sits on" the basis state x|x\rangle. The exponential arises directly from the tensor-product structure: each new qubit introduces a factor of 2 because the new degree of freedom can independently be in 0|0\rangle or 1|1\rangle in superposition with everything else.

Why this matters for algorithms

An nn-qubit gate applies a 2n×2n2^n \times 2^n unitary matrix to the state vector. A quantum algorithm can, in a single step, manipulate all 2n2^n amplitudes simultaneously — a kind of massive parallelism. However, measurement collapses the state to a single nn-bit string, so the art of quantum algorithm design is arranging interference so that the useful outcomes have large amplitudes by the time we measure.

Classical versus quantum information content

It is tempting to say nn qubits "store" 2n2^n values. This is misleading: you can only extract nn classical bits per measurement. The exponential structure lives in the pre-measurement superposition and is accessible only through interference. Algorithms like Grover's and the Quantum Fourier Transform exploit this structure without trying to read out all 2n2^n amplitudes directly.

Try it

Return the number of complex amplitudes required to describe a 3-qubit state vector.

Run your code to see the quantum state.

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