The Hadamard Gate
Every quantum algorithm faces the same opening problem: a fresh qubit starts life as a boring,
definite |0\rangle, and nothing quantum can happen until it is coaxed
into a superposition.
The Hadamard gate is the tool that does it — the single most-used gate in the whole
subject. It is the single-qubit gate
that manufactures superposition, turning a plain basis state into a perfectly balanced blend
of both. Its matrix is
H = \tfrac{1}{\sqrt2}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}.
Feed it the two computational-basis states and out come the two Hadamard-basis
states — the balanced superpositions |{+}\rangle and
|{-}\rangle:
H|0\rangle = |{+}\rangle = \tfrac{1}{\sqrt2}\big(|0\rangle + |1\rangle\big), \qquad H|1\rangle = |{-}\rangle = \tfrac{1}{\sqrt2}\big(|0\rangle - |1\rangle\big).
Notice the only difference between the two outputs: a single minus sign — a
relative phase.
That tiny sign is where all the action will be.
Picturing it as a circuit
In a quantum circuit a qubit rides a horizontal wire from left to right, and each
gate is a labelled box it passes through. A lone Hadamard is the simplest interesting circuit there
is: a wire carrying |0\rangle into an H box, and
|{+}\rangle coming out the other side.
Worked example: apply H by matrix × vector
The gate is just a matrix, so applying it is a matrix–vector product. Take
|0\rangle = \begin{bmatrix} 1 \\ 0 \end{bmatrix}:
H|0\rangle = \tfrac{1}{\sqrt2}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}\begin{bmatrix} 1 \\ 0 \end{bmatrix} = \tfrac{1}{\sqrt2}\begin{bmatrix} 1 \\ 1 \end{bmatrix} = \tfrac{1}{\sqrt2}\big(|0\rangle + |1\rangle\big) = |{+}\rangle.
The matrix simply reads off its first column. Now
|1\rangle = \begin{bmatrix} 0 \\ 1 \end{bmatrix} reads off the
second:
H|1\rangle = \tfrac{1}{\sqrt2}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}\begin{bmatrix} 0 \\ 1 \end{bmatrix} = \tfrac{1}{\sqrt2}\begin{bmatrix} 1 \\ -1 \end{bmatrix} = \tfrac{1}{\sqrt2}\big(|0\rangle - |1\rangle\big) = |{-}\rangle.
Same two output amplitudes, but the sign on |1\rangle flips. That is how
H encodes the input bit into the phase of the superposition:
|0\rangle becomes a +, and
|1\rangle becomes a -.
H is its own inverse
The Hadamard matrix is real and symmetric, so its
conjugate transpose
is itself, and squaring it gives the identity:
H^2 = \tfrac12\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix} = \tfrac12\begin{bmatrix} 2 & 0 \\ 0 & 2 \end{bmatrix} = I.
So H is its own inverse: applying it twice returns the
qubit exactly to where it began. Read backwards, this says H also
un-makes a superposition — it maps the Hadamard basis right back onto the computational
basis:
H|{+}\rangle = |0\rangle, \qquad H|{-}\rangle = |1\rangle.
In other words H swaps the two bases
\{|0\rangle, |1\rangle\} and
\{|{+}\rangle, |{-}\rangle\}, and swapping twice is doing nothing.
Worked example: H turns a hidden phase into a readable bit
Here is the payoff. Measure |{+}\rangle in the computational basis: both
amplitudes are \tfrac{1}{\sqrt2}, so by
the Born rule
you get 0 or 1 with probability
\tfrac12 each — a fair coin. The states
|{+}\rangle and |{-}\rangle give
identical 50/50 statistics, so a raw measurement cannot tell them apart: the relative phase
is invisible.
Now apply H first, then measure. Since
H|{+}\rangle = |0\rangle, the outcome is 0
with certainty — a deterministic result, no randomness at all:
\Pr\big(0 \mid \text{measure } H|{+}\rangle\big) = |\langle 0|0\rangle|^2 = 1.
And H|{-}\rangle = |1\rangle gives 1 every
time. So H has converted the invisible relative phase into a
perfectly readable bit: the very phase that a plain measurement could not see becomes a
certain 0-vs-1 answer once you Hadamard first.
This "rotate the phase into the measurement basis" move — the seat of quantum
interference — is exactly how algorithms cash in the work they hide in phases.
- H = \tfrac{1}{\sqrt2}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}
creates superposition: H|0\rangle = |{+}\rangle and
H|1\rangle = |{-}\rangle;
- it swaps the computational basis with the Hadamard basis, encoding the input
bit as the relative phase (a + or a
-);
- it is its own inverse: H^2 = I, so
H|{+}\rangle = |0\rangle and
H|{-}\rangle = |1\rangle — a second Hadamard undoes the first;
- applying it before a measurement turns an unmeasurable phase into a deterministic
bit — the doorway to interference.
The real reason H is everywhere: put one on every qubit of an
n-qubit register that starts in
|00\ldots0\rangle, and you get an equal superposition of all
2^n bitstrings at once:
H^{\otimes n}\,|0\rangle^{\otimes n} = \tfrac{1}{\sqrt{2^n}}\sum_{x=0}^{2^n-1} |x\rangle.
A single layer of Hadamards — n gates — and the machine is now holding
every one of the 2^n possible inputs simultaneously, with just
n operations. This "spread over everything" step is the opening move of
nearly every quantum algorithm, from
Deutsch–Jozsa
to Grover's search.
The catch, of course, is that a final measurement still hands you only one of those
strings — so the art of an algorithm is arranging interference so the string you want is the one that
survives.
The tempting mistake is to think that if one H makes a fair-coin
superposition, two H's must make it "even more random". They do the
opposite. Because H^2 = I, a second Hadamard undoes the
first: H|{+}\rangle = |0\rangle, a completely certain outcome.
Quantum gates are reversible rotations, not classical coin-flips — the amplitudes
interfere, and here the |1\rangle paths cancel while the
|0\rangle paths reinforce, collapsing the superposition rather than
deepening it. Randomness only appears when you measure; stacking unitary gates never
"adds" randomness, and applying the same self-inverse gate twice is the same as doing nothing at all.