|q⟩ Bad Qubits

beginner · Programming · From Bits to Qubits

Introducing the Qubit

A classical bit holds exactly one of two values — 0 or 1. A qubit is the quantum analogue: a physical two-level system whose state is described by a complex vector rather than a single digit.

Two levels, complex amplitudes

Any isolated two-level quantum system can serve as a qubit: the spin of an electron, the polarisation of a photon, or the energy levels of a trapped ion. What matters is that exactly two orthogonal basis states exist. Following Dirac notation we call them 0|0\rangle and 1|1\rangle (read "ket zero" and "ket one"), represented as column vectors

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

The most general pure state of a qubit is a superposition

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

subject to the normalisation constraint α2+β2=1|\alpha|^2 + |\beta|^2 = 1. The numbers α\alpha and β\beta are probability amplitudes: when the qubit is measured, the Born rule assigns probability α2|\alpha|^2 to outcome 0 and β2|\beta|^2 to outcome 1.

The computational basis

The two special states 0|0\rangle and 1|1\rangle form the computational basis. They are the quantum analogues of the classical bit values 0 and 1, and they are the only states that give a certain, repeatable measurement outcome. Any other single-qubit pure state has α>0|\alpha| > 0 and β>0|\beta| > 0 simultaneously, meaning neither outcome is certain before measurement.

Try it

Our simulator initialises every qubit in 0|0\rangle. Apply the Pauli-X gate — the quantum equivalent of a classical NOT — to flip the qubit from 0|0\rangle to 1|1\rangle. Verify that the resulting state vector matches 1=(0,1)T|1\rangle = (0, 1)^T.

Run your code to see the quantum state.

After running the circuit, the amplitude of 0|0\rangle drops to 0 and the amplitude of 1|1\rangle rises to 1. The X gate is the simplest evidence that a qubit obeys the same linear rules as a full quantum state vector — even when the state stays in the computational basis.

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