Measurement
Collapse isn't mystical — it's a rule. The rule has two parts, and the second one depends on which question you ask.
The standard story about quantum measurement goes like this: “the wavefunction collapses.” Then the storyteller waves a hand vaguely and you're supposed to nod along. This is a bad story. It doesn't tell you which outcome you get, how often, or — and this is the part that breaks most people's intuition — what counts as a measurement at all.
Here is the real rule, in two parts. (1) Born:
the probability of measuring outcome k is
|⟨k|ψ⟩|² — the squared magnitude of the amplitude
sitting in front of the basis state you're asking about.
(2) Projection: once you've gotten outcome
k, the state is |k⟩. The other
amplitudes vanish. Same particle, different state — you changed
it by looking at it.
That's it. No consciousness, no observers, no philosophy. A measurement is any interaction that correlates a quantum amplitude with a classical record, and the rule above tells you what the record will say and what the state looks like afterwards. The only knobs are: which state you started in, and which basis you measure in.
Press a gate, then measure
Start from |0⟩. The probability bars show one
outcome with probability 1. If you measured right now, you would
get 0. Every single time. Forever.
P(|0⟩) = …, P(|1⟩) = …
…
Try this: press Run 100×
without touching any gates. The little histogram below the
button fills up with 100 zeros and zero ones. The simulator runs
a real measurement 100 times against the current state, and the
Born rule says P(0) = 1, so… every roll comes back
0. The randomness is mathematically there; it just
isn't doing anything when one outcome has probability 1.
Re-runs the circuit you've built (current gates, then a measurement) 100 times against fresh randomness.
Try this: press Reset, then
H, then Run 100×. The bars
split close to 50/50 — not exactly, because 100 flips of a fair
coin doesn't land on 50-50, but close. Press it a few more times
and watch the numbers wobble in the 40–60 band. That's
the Born rule meeting the law of large numbers. The wobble shrinks
like 1/√N; at 10,000 shots you'd see numbers in the
49–51 band.
Same state, different question
Here's where most quantum-curious developers get tripped up.
People talk about “measuring a qubit” as if there's
one way to do it. There isn't. Every measurement happens
in a basis — a choice of two orthogonal states you're
asking the qubit to commit to. Our buttons measure in the
computational (Z) basis: |0⟩ vs.
|1⟩. But you could equally well measure in the
X basis (|+⟩ vs. |−⟩), or
any other.
The Born rule cares which basis you picked. So does the projection step. Same state, different basis, different distribution. This is not a paradox — it's the whole point of being a vector in a 2D complex space. There are infinitely many orthogonal axes you can decompose along.
We don't have a basis-switching button up there, but we have the
next best thing: rotate the state instead of rotating the
measurement axis. Measuring H|ψ⟩ in the
Z basis is mathematically identical to measuring
|ψ⟩ in the X basis — applying H
swaps the two bases for you.
Try this: reset, press X (so
you're in |1⟩), then Run 100×.
You'll get 100 ones. Now press H and run again.
The bars split — the deterministic |1⟩ answer in
one basis is a fair coin flip in another. Nothing about the
underlying state has “become random”; you just asked
a different question of the same vector.
Open it in the sandbox
The Run-100 button above is a shortcut that recreates whatever
gate sequence you've clicked on this page. The sandbox is the
full thing: a real composer where you can drag ops around, swap
the order of H and measure, or add an
X in front and watch the histogram flip.
Open this circuit and try swapping the order of the two ops, or
removing the H entirely:
The headline observation: [measure] on |0⟩
is deterministic. [H, measure] on |0⟩ is
a fair coin. Same hardware. Same act of measuring. The only
difference is one gate sitting one column to the left.
Self-test
-
You apply
H, measure, get the outcome1, and then immediately applyHand measure again. What's the probability of getting1on the second measurement, and why? (Hint: the first measurement projected the state. The secondHis acting on the collapsed state, not the original superposition.) -
You're handed a qubit in an unknown state. You measure 100
times in the Z basis with no gate first and get 100 zeros.
Can you conclude the state was
|0⟩? (Hint: what would the superposition state|+⟩ = (|0⟩+|1⟩)/√2give you? What about the same state with a phase flip on the|1⟩component? The Z basis only sees probabilities, not phases — so which states does it actually distinguish?)
The rule, formally
Let in some orthonormal basis . The Born rule:
The projector onto outcome is . The post-measurement state, given outcome , is the projection renormalized:
That renormalization is doing the “collapse” work:
after the measurement, every amplitude except the one you
observed is zeroed out, and the surviving amplitude is rescaled
so the new vector is still a unit vector. This is exactly what
runCircuit's measurement path does in code — pick
an outcome with weight |α_k|², zero the rest,
divide by the surviving norm.
Basis dependence falls out for free. Measuring in the X basis is the same calculation with in place of . Equivalently — and this is the identity the Run-100 demo leans on — applying first and then measuring in the Z basis gives the same statistics as measuring the original state in the X basis directly.
For the math nerds
A philosophical aside that often comes up in office hours: “is the collapse real, or is it just the observer updating their beliefs?” This essay takes the pragmatic line. The post-measurement state, whatever its ultimate ontology, is the right object to plug into your next gate. Every single working interpretation of quantum mechanics — Copenhagen, many-worlds, Bohmian, QBism — agrees on the Born rule and on what follow-up gates do to the projected state. That's the part we can simulate and the part this essay is teaching.
A keyboard-only note: the Run 100× button is
reachable via Tab and activates with Enter or
Space. The histogram updates in place — its readouts
are inside <output> elements so assistive
tech announces the new counts on each run.