Quantum
Module 3 · Single-qubit gates · Lesson 2

Your first gate: the Hadamard

One gate, two clicks, and a superposition. The moment quantum computing stops being theoretical.

10 min read · Lesson 9 of 32

A quantum gate is a transformation applied to a qubit. Give it a state and it gives you a new state. Classical computers have gates too — NOT, AND, OR — and they flip bits according to some rule. Quantum gates flip, rotate, twist, and mix qubits in ways that classical gates can’t.

We’re going to start with the single most important quantum gate: the Hadamard, written HH. It has one job: take a definite state (0|0\rangle or 1|1\rangle) and put it into a superposition.

What H does

Here’s the rule, in Dirac notation:

H0=0+12=+H|0\rangle = \frac{|0\rangle + |1\rangle}{\sqrt{2}} = |+\rangle

H1=012=H|1\rangle = \frac{|0\rangle - |1\rangle}{\sqrt{2}} = |-\rangle

Notice that HH applied to 0|0\rangle gives you +|+\rangle — the equal-superposition state you met in Lesson 2. And HH applied to 1|1\rangle gives you |-\rangle, which has the same 50/5050/50 probabilities on measurement but a different relative phase.

The gate’s matrix form is:

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

The 1/21/\sqrt{2} out front is what keeps the state normalized. The minus sign in the bottom right is where the relative phase of |-\rangle comes from.

Try it

The widget below starts with a qubit in 0|0\rangle — the north pole of the Bloch sphere. Click H and watch three things happen at once:

  1. The state vector on the Bloch sphere swings to the equator.
  2. The state-vector display updates from 0|0\rangle to (0+1)/2(|0\rangle + |1\rangle)/\sqrt{2}.
  3. The probability bars go from (1,0)(1, 0) to (0.5,0.5)(0.5, 0.5).

There it is. You just made a superposition.

Try it again: reset, apply HH, then apply HH a second time. The qubit comes back to 0|0\rangle. That’s because:

H2=IH^2 = I

HH is its own inverse — applying it twice undoes it. That’s a special property; most gates don’t have it. It means a single Hadamard is like a toggle between “definite” and “superposition” for a qubit that starts in 0|0\rangle or 1|1\rangle.

The other buttons

The widget has buttons for XX, YY, and ZZ too — the Pauli gates. You’ll meet them properly in Module 3.1, but you can already play:

Notice that ZZ doesn’t do anything visible to 0|0\rangle — the state stays at the north pole — but if you first apply HH to make a superposition, then apply ZZ, the state lands somewhere different than if you’d applied HH alone. That’s the relative phase sneaking in. It’s invisible on a definite state, but it matters once the qubit is in a superposition.

Quick check
What state does the Hadamard gate produce when applied to |0⟩?
Quick check
What is H² (the Hadamard applied twice)?

Why it matters

Every quantum algorithm you’ll ever see — Deutsch-Jozsa, Grover, Shor, VQE, everything — starts with a layer of Hadamards. The very first move is almost always: “put the qubits into a uniform superposition over all possible inputs.”

That’s because superposition is the raw material quantum computers work with. A single qubit in +|+\rangle is “both answers at once” in a very loose sense. An array of nn qubits all in +|+\rangle is a superposition over 2n2^n possible bitstrings — a vast number even for modest nn.

You’ve now seen how to create that starting state: one Hadamard per qubit. The interesting part — what you do with that superposition to get a useful answer — is the subject of Module 7.

What you’ve learned

In these five lessons you’ve gone from “I’ve heard about qubits” to:

That’s the foundation. Every quantum computing concept builds on top of what you now know. Module 2 wraps up with global vs. relative phase, and Module 3 fills out the rest of the single-qubit gates. Module 4 introduces a second qubit, and that’s where things get really strange.

Until then — play with the widgets. Go back to Lesson 2.2 and try to reason about what each button on the Bloch sphere explorer is doing in terms of amplitudes. The picture and the math belong together, and the more you see the same idea in both forms, the more natural it becomes.