🏠 Home 📘 Track 1: Quantum Basics L19 — What Is a Gate? L20 — The Hadamard Gate L21 — The CNOT Gate
L20 §4 · Build Something Real ~18 min

The Hadamard Gate —
Superposition Maker

It looks like a single letter inside a box: H. But that one symbol starts the coin spinning. It transforms a perfectly definite $|0\rangle$ into an equal mixture of $|0\rangle$ and $|1\rangle$ — and every quantum algorithm begins exactly here.

✦ One Idea The Hadamard gate turns a definite qubit into a perfect 50/50 superposition — and applying it twice returns you to exactly where you started. It is both the opening move of every quantum algorithm and its own inverse: H² = I.
Hadamard gate superposition |+⟩ state |−⟩ state unitary matrix Bloch sphere equator self-inverse H²=I
Section 01
① Hook

The Most Important Gate in Quantum Computing

🪙
Before you read — what do you already know?
Think about what a gate does to a qubit's Bloch sphere position.

In L19 you learned that every gate is a rotation on the Bloch sphere. The Hadamard gate rotates 180° around the diagonal axis between X and Z. If you start at the north pole $|0\rangle$, where does the arrow end up after H?

If you were only allowed to learn one quantum gate — just one — it would have to be the Hadamard gate.

Not because it is the most powerful on its own. But because without it, virtually no quantum computation is possible. The Hadamard gate is the gate that opens the search space. It takes a qubit sitting quietly in state $|0\rangle$ — completely definite, no quantum richness whatsoever — and transforms it into a perfect superposition where $|0\rangle$ and $|1\rangle$ are exactly equally likely.

Look at a circuit diagram for Grover's algorithm. The very first thing that happens, before any other operation, is a column of H gates applied to every qubit. Shor's algorithm. Same thing. Quantum phase estimation, the quantum Fourier transform, quantum error correction — the Hadamard gate is almost always the opening move.

📜
Named after Jacques Hadamard (1865–1963)
The gate is named for the French mathematician Jacques Hadamard, who studied the matrices now called Hadamard matrices in the 1890s — long before quantum computing existed. A Hadamard matrix has a special property: its rows are all mutually orthogonal. In quantum computing, this orthogonality is precisely what puts a qubit into equal superposition. Mathematics discovered a century before it found its quantum application.
Section 02
② Intuition

The Spinning Coin — What H Actually Does

You have met the spinning coin before in L05. Let's return to it with fresh eyes, now that you understand circuits and gates.

🪙 The Spinning Coin Analogy
Imagine a coin lying flat on a table. It is definitely heads — $|0\rangle$. It is not spinning, not ambiguous. You know exactly what it is.

Applying the Hadamard gate is like flicking the coin and setting it spinning.

The moment the coin is spinning, it is neither heads nor tails — it is genuinely both, in perfect equal proportion. If you tap the table and stop it (measurement), it will land heads 50% of the time and tails 50% of the time. But while it is spinning, it is in superposition.

The H gate does exactly this: it takes a definite qubit ($|0\rangle$ or $|1\rangle$) and starts it spinning. The result is a qubit in perfect 50/50 superposition — equally likely to be 0 or 1 when measured.

But H does something subtler than just "start it spinning." When you apply H to $|0\rangle$, you get the state physicists call $|+\rangle$ (pronounced "plus ket"). When you apply H to $|1\rangle$, you get $|-\rangle$ (pronounced "minus ket"). Both are equally balanced superpositions of 0 and 1 — but they have different phases. That difference in phase is what makes interference possible later in the circuit.

🚫
Common misconception: "H just creates randomness"
The Hadamard gate is not a random number generator. The resulting superposition has a precise, deterministic mathematical form. The randomness only appears at measurement. Before measurement, the state $|+\rangle$ is completely well-defined — as precise and determined as $|0\rangle$ itself. The coin is spinning in an exact, known way. We are not ignorant of its state. We know its state perfectly. We just know it is a superposition, not a classical value.
Section 03
③ Framework

H on the Bloch Sphere

Every qubit state is a point on the Bloch sphere. The north pole is $|0\rangle$, the south pole is $|1\rangle$, and the equator is perfect 50/50 superposition. The Hadamard gate does something beautiful and geometric: it moves the arrow from pole to equator.

Before H
|0⟩
North pole — 100% probability of measuring 0
H
After H
|+⟩
Equator, +X axis — 50% of 0, 50% of 1

When you apply H to $|1\rangle$ (south pole), the arrow swings to the opposite side of the equator — the $|-\rangle$ state, pointing along the negative X-axis. Same probabilities when measured, but a different phase — which matters enormously for interference.

Key Insight
Geometrically, the Hadamard gate is a 180° rotation around the axis halfway between X and Z on the Bloch sphere — the (X+Z)/√2 axis. This is precisely why H is its own inverse: rotating 180° twice returns you to where you started. The mathematics we see next confirms this exactly: H² = I.
Section 04
∑ Mathematics

The Mathematics — Every Step Shown

Here is the complete mathematical picture of the Hadamard gate. Every step shown — no skipped derivations, every symbol defined on first use.

The Hadamard matrix

A qubit's state is a column vector with two entries — the complex amplitudes of $|0\rangle$ and $|1\rangle$. For $|0\rangle$: $\begin{pmatrix}1\\0\end{pmatrix}$; for $|1\rangle$: $\begin{pmatrix}0\\1\end{pmatrix}$. A gate is a matrix that transforms this vector.

The Hadamard Matrix
$$H = \frac{1}{\sqrt{2}}\begin{pmatrix}1 & 1 \\ 1 & -1\end{pmatrix}$$
The factor $\frac{1}{\sqrt{2}}$ ensures probabilities stay normalised — $P(0)+P(1)=1$ after the gate. The entries 1, 1, 1, −1 create the superposition and encode the phase difference between $|+\rangle$ and $|-\rangle$. The −1 entry is what makes $H|1\rangle \neq H|0\rangle$: same probabilities, different phase.

Applying H to $|0\rangle$ — complete derivation

H applied to |0⟩
$$H|0\rangle = \frac{1}{\sqrt{2}}\begin{pmatrix}1 & 1 \\ 1 & -1\end{pmatrix}\begin{pmatrix}1\\0\end{pmatrix}$$ $$= \frac{1}{\sqrt{2}}\begin{pmatrix}1 \cdot 1 + 1 \cdot 0 \\ 1 \cdot 1 + (-1) \cdot 0\end{pmatrix} = \frac{1}{\sqrt{2}}\begin{pmatrix}1\\1\end{pmatrix}$$ $$= \frac{1}{\sqrt{2}}|0\rangle + \frac{1}{\sqrt{2}}|1\rangle \;\equiv\; |{+}\rangle$$
This is the $|+\rangle$ state. The amplitude of $|0\rangle$ is $\frac{1}{\sqrt{2}}$, so $P(0) = \left(\frac{1}{\sqrt{2}}\right)^2 = \frac{1}{2}$. Same for $|1\rangle$. Perfect 50/50. The Bloch sphere arrow moves from north pole to the +X equatorial point.

Applying H to $|1\rangle$ — complete derivation

H applied to |1⟩
$$H|1\rangle = \frac{1}{\sqrt{2}}\begin{pmatrix}1 & 1 \\ 1 & -1\end{pmatrix}\begin{pmatrix}0\\1\end{pmatrix}$$ $$= \frac{1}{\sqrt{2}}\begin{pmatrix}1 \cdot 0 + 1 \cdot 1 \\ 1 \cdot 0 + (-1) \cdot 1\end{pmatrix} = \frac{1}{\sqrt{2}}\begin{pmatrix}1\\-1\end{pmatrix}$$ $$= \frac{1}{\sqrt{2}}|0\rangle - \frac{1}{\sqrt{2}}|1\rangle \;\equiv\; |{-}\rangle$$
This is $|-\rangle$. Probabilities are still 50/50 — but the $|1\rangle$ amplitude is negative. The probabilities square the amplitudes: $\left(-\frac{1}{\sqrt{2}}\right)^2 = \frac{1}{2}$. The negative sign (phase) vanishes when you measure — but it survives inside the circuit, where it drives interference. This is the subtle power of the Hadamard gate.

Summary of H's action on all four states

InputOperationOutput stateNameP(0)P(1)
|0⟩→ H → $\tfrac{1}{\sqrt{2}}(|0\rangle + |1\rangle)$ |+⟩50%50%
|1⟩→ H → $\tfrac{1}{\sqrt{2}}(|0\rangle - |1\rangle)$ |−⟩50%50%
|+⟩→ H → $|0\rangle$ |0⟩100%0%
|−⟩→ H → $|1\rangle$ |1⟩0%100%

The bottom two rows are remarkable: H applied to $|+\rangle$ returns $|0\rangle$, and H applied to $|-\rangle$ returns $|1\rangle$. This is the self-inverse property — $H \cdot H = I$. The gate is its own inverse. Two H gates in a row cancel completely.

Proving H is unitary: H² = I

Proving H² = I (Unitarity + Self-Inverse)
$$H^2 = \frac{1}{\sqrt{2}}\begin{pmatrix}1 & 1 \\ 1 & -1\end{pmatrix} \cdot \frac{1}{\sqrt{2}}\begin{pmatrix}1 & 1 \\ 1 & -1\end{pmatrix}$$ $$= \frac{1}{2}\begin{pmatrix}1\cdot1 + 1\cdot1 & 1\cdot1 + 1\cdot(-1) \\ 1\cdot1 + (-1)\cdot1 & 1\cdot1 + (-1)\cdot(-1)\end{pmatrix} = \frac{1}{2}\begin{pmatrix}2 & 0 \\ 0 & 2\end{pmatrix} = I$$
$H^2 = I$ proves: (1) H is unitary — a valid quantum gate that preserves all probabilities. (2) Applying H twice returns the qubit to its original state exactly. This is H's self-inverse property. Every entry of the computation is shown. No steps are hidden or assumed.
Section 05
⑤ Interactive

Hadamard Explorer

Choose an input state, apply H, and watch the Bloch sphere arrow animate to its new position. Then measure — once or a hundred times — and see the probability histogram build. Everything from the sections above, made visible and manipulable.

⚗ Hadamard Gate Explorer
Choose state → Apply H → Measure · watch the arrow and histogram
INTERACTIVE
Bloch Sphere
|0⟩
|0⟩
100%
|1⟩
0%
1 — Choose input state
2 — Apply the gate
Current state|0⟩
α (amplitude of |0⟩)1
β (amplitude of |1⟩)0
H applications0
3 — Measure (collapses superposition)
0
|0⟩
0
|1⟩
Select an input state, then press Apply Hadamard Gate to watch H transform the qubit. Measure after to see the probability distribution.

Key things to observe: when you start from $|0\rangle$ or $|1\rangle$ and apply H, the measurement statistics converge to 50/50 as you take more shots. When you start from $|+\rangle$ or $|-\rangle$ and apply H, you get back to a classical state — always 100% on one outcome. That is the self-inverse property in action.

Section 06
④ Theory

H Applied Twice — The Self-Inverse Property

One of the most elegant properties of the Hadamard gate is that applying it twice does nothing. You return exactly to where you started. This might seem like a limitation — but it is a profound feature exploited in many algorithms.

|0⟩
Start
North pole
H
|+⟩
Equator
50/50 superpos.
H
|0⟩
Back to start
H² = I ✓
🪙 The Coin Analogy Revisited
You flick a coin to start it spinning (first H). The coin is now in superposition. You then flick it again in exactly the same way — the angular momentum cancels, and the coin falls back down to its original heads position (second H).

Two identical "start spinning" operations reverse each other. The Hadamard gate's self-inverse property is mathematically equivalent: H followed by H is equivalent to doing nothing at all.

This property — called self-inverse or involutory — is written formally as $H^2 = I$, where $I$ is the identity matrix (the "do nothing" gate). We proved this in Section 4. In circuit notation, if you see H · H on the same wire, they cancel completely — circuit designers use this to simplify circuits.

Why the self-inverse property matters in algorithms
In Grover's algorithm, the "diffusion operator" uses two sets of Hadamard gates — one to open the superposition, one to close it after interference. The fact that H is its own inverse makes this structure clean and elegant. In the quantum Fourier transform, Hadamard gates appear in both the forward and inverse transform. The self-inverse property means undoing the transform uses the exact same gate, just reversed.
Section 07
③ Framework

Why H Opens Every Quantum Algorithm

Recall the quantum algorithm recipe from Section 3: Initialise → Superpose → Entangle → Interfere → Measure. The Superpose step is the Hadamard gate. Without it, you cannot open the search space. Without it, you are running a classical computation on quantum hardware — wasting everything the machine can do.

If you want $n$ qubits to simultaneously explore all $2^n$ possibilities, you apply H to every qubit. Each H independently creates a 50/50 superposition. But because the qubits are part of the same system, the combined state is a superposition of all $2^n$ possible bit strings simultaneously.

H applied to all n qubits — the key opening move
$$H^{\otimes n}|0\rangle^{\otimes n} = \frac{1}{\sqrt{2^n}} \sum_{x=0}^{2^n - 1} |x\rangle$$
$H^{\otimes n}$ means H applied to each of $n$ qubits independently. $|0\rangle^{\otimes n}$ means all qubits start in $|0\rangle$. The result: an equal superposition of all $2^n$ possible states. For $n=3$: $\frac{1}{\sqrt{8}}(|000\rangle + |001\rangle + |010\rangle + |011\rangle + |100\rangle + |101\rangle + |110\rangle + |111\rangle)$. Eight states simultaneously, equal probability each. This is quantum parallelism — opened by H.

From this superposition, subsequent gates add structure — entangling qubits, adding phase differences, engineering the interference pattern that steers the computation toward the right answer. The Hadamard gate does not do this alone. But without it, the journey cannot begin.

🔭
Looking ahead — CNOT and Bell pairs
In L21 you will meet the CNOT gate — the gate that creates entanglement by linking two qubits. After that, combining H and CNOT produces your first complete quantum circuit — one that creates a Bell pair, the simplest entangled state. You have now seen what H does alone. Next you see what it does when paired with CNOT.
Lesson Summary

What You Now Know About the Hadamard Gate

  • 🪙
    H starts the coin spinning — it creates superposition
    The Hadamard gate transforms a definite qubit into a perfect 50/50 superposition. $|0\rangle$ becomes $|+\rangle = \frac{1}{\sqrt{2}}(|0\rangle + |1\rangle)$. $|1\rangle$ becomes $|-\rangle = \frac{1}{\sqrt{2}}(|0\rangle - |1\rangle)$. Both are equally likely to yield 0 or 1 when measured — but they have different phases that drive interference.
  • 🌐
    On the Bloch sphere, H moves the arrow from pole to equator
    $|0\rangle$ (north pole) → $|+\rangle$ (equator, +X). $|1\rangle$ (south pole) → $|-\rangle$ (equator, −X). Geometrically, H is a 180° rotation around the (X+Z)/√2 axis. The equator is the zone of perfect superposition.
  • H is the matrix $\frac{1}{\sqrt{2}}\begin{pmatrix}1&1\\1&-1\end{pmatrix}$
    The $\frac{1}{\sqrt{2}}$ preserves normalisation. The −1 creates the phase difference between $|+\rangle$ and $|-\rangle$. The matrix is symmetric and unitary — probabilities always sum to 1.
  • 🔄
    H is its own inverse — H² = I
    Applying H twice returns the qubit to its original state. This self-inverse property means $|+\rangle \to |0\rangle$ and $|-\rangle \to |1\rangle$. Two H gates on the same wire always cancel — circuit designers use this constantly to simplify circuits and undo Hadamard operations.
  • 🚀
    H opens every quantum algorithm through quantum parallelism
    $H^{\otimes n}|0\rangle^{\otimes n}$ creates an equal superposition of all $2^n$ states simultaneously. This is the first step of Grover's search, Shor's factoring, quantum phase estimation, and virtually every other quantum algorithm. Without H, there is no quantum parallelism.
Quick Check
How clearly does the Hadamard gate click for you now?

You know what H does alone.
Now see what happens when H meets another gate —
one that creates entanglement between two qubits.
The CNOT gate. The next essential piece.

→ The CNOT Gate — L21
Sources & Further Reading
← Previous
What Is a Gate?
L19 — Operations on qubits, Bloch sphere rotations