A qubit you can turn
One qubit, six gates and a measurement. The arrow shows the state. Gates rotate it; measuring makes it pick a pole.
gates
measure
Try this
- Press H, then measure once. The arrow jumps to the top or the bottom. Measure again: it stays put.
- Reset, press H, then measure 100 copies. You get roughly 50 of each, but rarely exactly 50.
- Press H, Z, H. Where does it end up? Now try H, H. Two Hadamards undo each other.
- Use the θ slider to set 60°. Predict P(1) before you measure 100 copies. (Hint: sin²(θ/2).)
- Press H, then S four times. The phase goes round once and P(0) never changes. Phase is invisible to this measurement, but not to the next gate.
the physics ✎
A qubit's state can be written |ψ⟩ = cos(θ/2)|0⟩ + eiφ sin(θ/2)|1⟩. The two angles place it on a sphere, the Bloch sphere: |0⟩ at the top, |1⟩ at the bottom, and equal superpositions around the equator.
P(0) = cos²(θ/2), P(1) = sin²(θ/2)
Every single-qubit gate is a rotation of this sphere. X is a half-turn about the x axis, Z about z, and H about the axis halfway between x and z. Measuring gives 0 or 1 at random with those probabilities and leaves the qubit at the pole it landed on.
"Measure 100 copies" prepares the same state 100 times and measures each copy once, which is what a real quantum computer does when it runs a circuit for many shots.