|q⟩ Bad Qubits

beginner · Programming · The Qubit State Vector & Dirac Notation

The |+⟩ and |−⟩ States

Two of the most important states in quantum computing are not ∣0⟩|0\rangle or ∣1⟩|1\rangle but equal superpositions of them. They appear constantly in algorithms, error correction, and teleportation, and they have their own names: ∣+⟩|+\rangle and ∣−⟩|-\rangle.

Expanding |+⟩ and |−⟩ in the computational basis

Written explicitly in the {∣0⟩,∣1⟩}\{|0\rangle, |1\rangle\} basis:

∣+⟩=12(∣0⟩+∣1⟩),∣−⟩=12(∣0⟩−∣1⟩).|+\rangle = \frac{1}{\sqrt{2}}\big(|0\rangle + |1\rangle\big), \qquad |-\rangle = \frac{1}{\sqrt{2}}\big(|0\rangle - |1\rangle\big).

Both states are unit vectors: the probabilities of the two outcomes sum to one,

∣12∣2+∣12∣2=12+12=1.\left|\frac{1}{\sqrt{2}}\right|^2 + \left|\frac{1}{\sqrt{2}}\right|^2 = \frac{1}{2} + \frac{1}{2} = 1.

They differ only in the relative sign of the ∣1⟩|1\rangle amplitude. That sign is invisible to a single measurement in the computational basis — both give outcome 0 or 1 with probability 12\frac{1}{2} each — but it becomes observable when the states are made to interfere with one another, for example by applying a second Hadamard gate.

Preparing these states with the Hadamard gate

The Hadamard gate HH has the matrix

H=12(111−1).H = \frac{1}{\sqrt{2}}\begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}.

Applying it to the column vectors for ∣0⟩|0\rangle and ∣1⟩|1\rangle immediately recovers the definitions above:

H∣0⟩=12(11)=∣+⟩,H∣1⟩=12(1−1)=∣−⟩.H|0\rangle = \frac{1}{\sqrt{2}}\begin{pmatrix}1\\1\end{pmatrix} = |+\rangle, \qquad H|1\rangle = \frac{1}{\sqrt{2}}\begin{pmatrix}1\\-1\end{pmatrix} = |-\rangle.

So starting from the ground state ∣0⟩|0\rangle, a single Hadamard puts the qubit into ∣+⟩|+\rangle.

Try it

Prepare the qubit in the ∣+⟩|+\rangle state. The simulator will compare your circuit's state vector to the expected amplitudes 12\frac{1}{\sqrt{2}} and 12\frac{1}{\sqrt{2}}, so the starting ∣0⟩|0\rangle alone will not pass.

Run your code to see the quantum state.

After running, inspect the State Vector panel: you should see two amplitudes both equal to ≈0.707=12\approx 0.707 = \frac{1}{\sqrt{2}}, with identical signs — that is ∣+⟩|+\rangle.

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