Everything you do to a qubit before measuring is a reversible rotation of its Bloch arrow — and each one is a 2×2 matrix multiplying the state vector. This is where the linear algebra earns its keep.
↩ before you start · keep these handy
·From 0.4: a matrix acts on a vector row by row — each output = (row · input).
·From Ch. 4: a qubit is a point on the Bloch sphere; a gate moves that point.
·From Ch. 2: |+⟩ = (|0⟩ + |1⟩)/√2 is the equal superposition; total probability must stay 1.
🔑 symbol decoder · every new mark, in plain words
Uany gate, written as a matrix. The new state is |ψ′⟩ = U|ψ⟩ — “put the state through the machine.”X, Y, Zthe three Pauli gates — the elementary half-turns about the x, y and z axes.Hthe Hadamard — the gate that turns a definite |0⟩ into the even superposition |+⟩.unitarya matrix that never changes a vector’s length — it rotates without stretching. Every gate is one.1/√2≈ 0.707 — the normalizing factor that keeps an equal superposition’s squares adding to 1.ithe imaginary unit (a 90° phase turn). It appears in Y and S, which rotate phase.
§1
Tap a gate, watch the arrow move
X is the NOT gate — a half-turn about x. Z flips the phase — a half-turn about z. H, the Hadamard, builds an even superposition from a definite state. S is a quarter phase turn. Stack them and watch.
💡 everyday picture
Hold a globe in your hands and give it a turn. You never dent it or stretch it — you just rotate it, and you can always turn it straight back. That is exactly what a gate does to the Bloch arrow: a rigid rotation, length untouched (unitary), and always undoable (reversible). Measurement, by contrast, is like dropping the globe — you can’t un-drop it.
▸ applygate.circuit
last gate · {{ gateLabel }}
{{ m00 }}{{ m01 }}{{ m10 }}{{ m11 }}
recapEach gate is a reversible rotation of the Bloch arrow; stack them and the turns compose.
§2 · the mathematics
The Pauli matrices
A gate is a matrix U acting on the state: |ψ′⟩ = U|ψ⟩. To preserve total probability, U must be unitary — it rotates without stretching. The three Pauli matrices are the elementary half-turns:
X =0110
Y =0−ii0
Z =100−1
The Hadamard mixes Z and X into the workhorse that creates superposition:
4.result [1/√2, 1/√2] = |+⟩ — a definite even superposition
recapGates are unitary 2×2 matrices; the Paulis are the half-turns and H is the superposition-builder.
§3 · the mathematics
Circuits multiply
Run gates in sequence and the matrices multiply — newest on the left. A famous identity: a Z sandwiched in Hadamards is just an X.
H · Z · H = X
Try it in the playground: from |0⟩, press H, Z, H and you land where a single X would put you.
recapGates in sequence multiply as matrices, newest on the left; a Z between two H's is just an X.
⚠ common misconceptions
“A gate reads or measures the qubit.” No. A gate is a silent, reversible rotation — nothing is observed and nothing collapses. The qubit keeps its full superposition; only a measurement (Chapter 3) extracts a bit and destroys the blend.
“The order of gates doesn't matter.” Usually it does. Applying X then Z is generally not the same as Z then X — matrices don't commute. When you write the circuit as a product, the first-applied gate sits nearest the state (on the right).
“Hadamard makes the qubit random.” H produces a perfectly definite state, |+⟩ — not noise. Measuring |+⟩ is a coin flip, but the state itself is exact and reversible: a second H turns |+⟩ straight back into |0⟩, which randomness could never allow.
✓ you can now
✓apply X, Z, H and S as matrices to a state and predict how the Bloch arrow moves
✓say why every gate must be unitary — and therefore reversible
✓multiply gates in the right order and use identities like H·Z·H = X