|q⟩ Bad Qubits

beginner · Programming · From Bits to Qubits

The States |0⟩ and |1⟩

A quantum computer stores information in qubits. Before exploring superposition, you need to know the two states a qubit can be in when you measure it — the computational basis states 0|0\rangle and 1|1\rangle.

The two basis states

In Dirac (bra-ket) notation these states are written 0|0\rangle and 1|1\rangle. Behind the notation each state is a two-dimensional complex column vector:

0=(10),1=(01).|0\rangle = \begin{pmatrix} 1 \\ 0 \end{pmatrix}, \qquad |1\rangle = \begin{pmatrix} 0 \\ 1 \end{pmatrix}.

Each entry is a probability amplitude: the probability of a particular measurement outcome equals the squared modulus of the corresponding amplitude. The top entry corresponds to outcome 00 and the bottom entry to outcome 11. For 0|0\rangle the top amplitude is 11 and the bottom is 00, giving measurement probabilities 12=1|1|^2 = 1 and 02=0|0|^2 = 0 — so a measurement is certain to return 0. For 1|1\rangle it is the other way around — measurement always returns 1.

These two vectors form an orthonormal basis for the two-dimensional Hilbert space C2\mathbb{C}^2: they are orthogonal (01=0\langle 0 | 1 \rangle = 0) and each has unit length (00=11=1\langle 0 | 0 \rangle = \langle 1 | 1 \rangle = 1).

Why column vectors?

Representing states as vectors lets us describe quantum gates as matrix multiplication. A gate UU maps a state ψ|\psi\rangle to a new state UψU|\psi\rangle by ordinary matrix–vector multiplication. Every gate in this course is an operation on the same C2\mathbb{C}^2 (or a tensor product of copies of it), so getting the column-vector picture in your head now pays off everywhere else.

Try it

Qubits always start in 0|0\rangle. Prepare the state 1|1\rangle by flipping the qubit, then press Check to confirm the simulator agrees with the column vector (01)\begin{pmatrix}0\\1\end{pmatrix}.

Run your code to see the quantum state.

After running, look at the State Vector panel. The amplitude of 0|0\rangle is 00 and the amplitude of 1|1\rangle is 11, exactly matching the column vector above.

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