Chances always add to one
Whatever state you build, the two probabilities must total 100%. If they do not, the amplitudes are not a qubit yet.
A qubit is not a vague idea — it is two numbers and one rule. Work through ten short lessons, each with its formula and a real calculation you can run in the console.
00 / Before you start
Symbols first, so the lessons stay plain.
01 / The lessons
Each lesson builds on the one before it.
A classical bit is 0 or 1. A qubit holds two numbers called amplitudes, written α|0⟩ + β|1⟩. Both of them can be non-zero at the same time.
|ψ⟩ = α|0⟩ + β|1⟩Watch forSquaring both amplitudes gives exactly 1. Every valid qubit obeys this.
Square an amplitude to get the chance of measuring that outcome. Do it to both amplitudes and the two chances always add up to 100%.
P(0) = |α|², P(1) = |β|²Watch forAn amplitude of 0.707 means a 50% chance. The square is what you can actually predict.
The gate that creates a superposition: it turns a definite 0 into an even mix of 0 and 1. Apply it a second time and the two halves cancel back to 0.
H|0⟩ = (|0⟩ + |1⟩) / √2Watch forEach amplitude is about 0.707. Square it and you get a fair coin.
The quantum NOT. It swaps the two amplitudes, so a state that was certainly 0 becomes certainly 1.
X|0⟩ = |1⟩Watch forThe flip moves the 1 from one amplitude to the other. The total never changes.
Z flips the sign of the |1⟩ amplitude. Nothing you measure directly changes, but that sign decides how the state interferes later.
Z(α|0⟩ + β|1⟩) = α|0⟩ − β|1⟩Watch forA negative amplitude still squares to a positive chance. The sign only shows up when amplitudes meet.
Instead of jumping between states, Ry tilts the state by an angle θ. The chance of measuring 0 follows a cosine squared.
P(0) = cos²(θ / 2)Watch forA 60° tilt leans the state toward 0: three chances in four.
Looking collapses the qubit to a single answer, 0 or 1. Run the same state many times — the "shots" — and the counts settle around the probabilities.
1024 shots × 0.5 ≈ 512Watch forProbability predicts the average, not the exact count of one run.
Any qubit state is a point on a sphere: north pole is |0⟩, south pole is |1⟩, and the equator is a perfect superposition.
θ = 2·acos(|α|)Watch for90° puts the point on the equator — the most uncertain state there is.
Amplitudes have to form a unit length. If their squares do not add to 1, the numbers are not a qubit yet, so you rescale them.
|α|² + |β|² = 1Watch for0.6 and 0.8 look random, but their squares add to exactly 1.
Amplitudes are added first and squared afterwards, so two paths can cancel each other out or build each other up. That is what separates a quantum calculation from simply adding odds.
(α₁ + α₂)²Watch forTwo equal amplitudes with opposite signs cancel to nothing — the reason H twice returns |0⟩.
02 / The two rules
Check both in the console.
Whatever state you build, the two probabilities must total 100%. If they do not, the amplitudes are not a qubit yet.
Quantum maths squares after adding, never before. Change the order and you get a different answer — that difference is interference.
03 / Word list
Keep this open while you play.
04 / Now try it