Single-Qubit Gates
A classical chip computes by pushing bits through logic gates — an AND, an OR, a
NOT — little boxes that take bits in and spit new bits out. A quantum computer works the same way in
spirit: you steer a qubit by sending it through gates. But a quantum gate cannot be
just any box. Because a qubit is a
unit vector, a
gate has to move that vector without breaking the rules that make it a state — and that single
requirement pins down exactly what a gate is allowed to be.
A single-qubit gate is a 2 \times 2
unitary matrix
U. It acts on the qubit's state vector by ordinary
matrix × column-vector multiplication, transforming the amplitudes:
|\psi\rangle \;\longmapsto\; U\,|\psi\rangle, \qquad U = \begin{bmatrix} u_{11} & u_{12} \\ u_{21} & u_{22} \end{bmatrix}, \quad U^\dagger U = I.
In a circuit you draw the qubit as a horizontal wire running left to right (time flows
rightward), and the gate as a labelled box sitting on that wire. The state going in is
|\psi\rangle; the state coming out the other side is
U|\psi\rangle.
Why unitary? Two rules a gate must keep
The condition U^\dagger U = I is not decoration — it is exactly what makes
the box a legal gate. It buys two things at once.
First, normalisation is preserved. A valid state has length
1, and a unitary map is length-preserving, so
U|\psi\rangle is again a unit vector — still a genuine qubit whose
probabilities sum to 1:
\lVert U|\psi\rangle \rVert^2 = \langle\psi|U^\dagger U|\psi\rangle = \langle\psi|\psi\rangle = 1.
Second, the operation is reversible. Unitary matrices are invertible, and the inverse
is handed to you for free — it is the conjugate transpose U^\dagger. So the
undo button always exists:
U^\dagger\,(U|\psi\rangle) = (U^\dagger U)\,|\psi\rangle = I\,|\psi\rangle = |\psi\rangle.
Apply U, then apply U^\dagger, and you are exactly
back where you started. Geometrically, since U only turns a unit vector into
another unit vector, a single-qubit gate is a rotation of the
Bloch sphere
— the state's arrow swings to a new orientation on the same sphere, never shrinking or growing.
Worked example: flipping a qubit with X
The simplest interesting gate is the bit-flip, the Pauli-X matrix — the
quantum NOT:
X = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}.
Send |0\rangle = \begin{bmatrix} 1 \\ 0 \end{bmatrix} through it. Just do the
matrix multiplication — each output entry is a row of X dotted with the
column:
X|0\rangle = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}\begin{bmatrix} 1 \\ 0 \end{bmatrix} = \begin{bmatrix} 0\cdot 1 + 1\cdot 0 \\ 1\cdot 1 + 0\cdot 0 \end{bmatrix} = \begin{bmatrix} 0 \\ 1 \end{bmatrix} = |1\rangle.
The gate swapped the two amplitudes, turning |0\rangle into
|1\rangle — exactly a flip. Running the same matrix on
|1\rangle gives |0\rangle back, so
X swaps |0\rangle \leftrightarrow |1\rangle, just
as its two rows suggest.
Worked example: a gate on a superposition
Gates act on every amplitude at once, so applying one to a superposition transforms the whole
blend in a single stroke. Take the balanced state
|{+}\rangle = \tfrac{1}{\sqrt2}\!\begin{bmatrix} 1 \\ 1 \end{bmatrix} and push
it through X:
X|{+}\rangle = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}\,\tfrac{1}{\sqrt2}\begin{bmatrix} 1 \\ 1 \end{bmatrix} = \tfrac{1}{\sqrt2}\begin{bmatrix} 1 \\ 1 \end{bmatrix} = |{+}\rangle.
The bit-flip leaves |{+}\rangle completely unchanged — swapping two equal
amplitudes does nothing. (In Bloch-sphere language, |{+}\rangle sits on the
rotation axis of X, so the rotation fixes it.) Now check the promised
reversibility. Since X is real and symmetric,
X^\dagger = X, and undoing the flip on
|0\rangle means
X^\dagger\bigl(X|0\rangle\bigr) = X\,|1\rangle = |0\rangle. \quad\checkmark
We flipped, then flipped back, and recovered the original state exactly — no information lost.
- a single-qubit gate is a 2\times 2 unitary matrix
U (U^\dagger U = I);
- it acts by matrix multiplication,
|\psi\rangle \mapsto U|\psi\rangle, transforming all the amplitudes at
once;
- it preserves normalisation, so the output is still a valid qubit;
- it is reversible: U^\dagger undoes it,
U^\dagger U|\psi\rangle = |\psi\rangle;
- geometrically it is a rotation of the Bloch sphere.
The gates to come
Every named single-qubit gate is just a specific choice of the unitary U.
The workhorses ahead are the Pauli gates
(X, Y, Z — flips and phase flips), the
Hadamard gate
that builds superpositions, the
phase gates S and T,
and the continuous
rotation gates
that turn the state by any angle you like. Learn to read one gate as a matrix and you can read them
all.
On a classical chip, a NAND gate is a one-way street: given the output 1 you
cannot tell which of three input pairs produced it — information is thrown away, and that lost
information leaves as heat. Quantum gates are forbidden from doing this. Because every gate is unitary,
every gate has an inverse U^\dagger, so a quantum computation can
always be run backwards, step by step, to reconstruct exactly where it came from. Nothing is ever
overwritten or discarded. That is a profound constraint: it means all the familiar irreversible
operations must be re-engineered as reversible ones, and it is why a quantum program reads like a
sequence of rotations you could always rewind — a computer with no delete key.
Two traps. First, you cannot apply an arbitrary matrix as a gate — it must be
unitary. A matrix like \begin{bmatrix} 1 & 0 \\ 0 & 0 \end{bmatrix} would
crush |1\rangle to the zero vector, destroying normalisation; it is not a
legal gate, and no physical device can implement it. Only length-preserving (unitary) transformations
qualify.
Second, gates act by matrix multiplication, and matrices do not commute: in general
UV \neq VU. Applying V then
U gives UV|\psi\rangle — the gate nearest the
state acts first, so a circuit reads left-to-right but the matrices stack up right-to-left. Swap the
order of two gates and you can easily get a different state, so the sequence of gates is part
of the algorithm, not an afterthought.