QuantumSims
Drag to orbit · scroll or pinch to zoom · ←→↑↓ when focused

Gates

+90°

Measurement

Outcomes are |0⟩ or |1⟩.
|0⟩
0
|1⟩
0

Dashed lines mark the theoretical probabilities. Running shots does not collapse the live state.

State

α
1.000 + 0.000i
β
0.000 + 0.000i
θ
0.0°
φ
0.0°
P(0) = 1.000P(1) = 0.000
α phasor
β phasor

Arrow length is magnitude, angle is phase. Only the difference between the two angles is measurable.

Guided lessons

Qubit Playground: interactive Bloch sphere simulator

Apply gates to a single qubit, watch the state vector move, and measure it until the statistics settle.

What is a qubit?

A classical bit is either 0 or 1. A qubit is described by two complex numbers, α and β, written α|0⟩ + β|1⟩. The only constraint is that |α|² + |β|² = 1. Those squared magnitudes are the probabilities of reading 0 or 1 if you measure in the computational basis, so the constraint just says the probabilities add to one. A qubit is not "0 and 1 at the same time", and it is not a bit whose value you happen not to know yet. It is a vector, and the phases of α and β — not just their sizes — determine how it behaves when you apply further gates. That extra structure is what makes interference possible, and interference is where quantum algorithms get their leverage.

What is the Bloch sphere?

Two complex numbers have four real parameters. Normalisation removes one, and multiplying the whole state by a phase e^{iγ} changes nothing you can measure, which removes another. Two are left, so every pure single-qubit state can be written cos(θ/2)|0⟩ + e^{iφ} sin(θ/2)|1⟩ and drawn as a point on a sphere. The north pole is |0⟩ and the south pole is |1⟩; the equator holds the even superpositions, with |+⟩ and |−⟩ on the x axis and |+i⟩ and |−i⟩ on the y axis. Polar angle θ sets the measurement probabilities; azimuth φ is the relative phase. In this simulator the amplitudes are the source of truth and the sphere coordinates are derived from them, never the other way round.

What do quantum gates do?

A single-qubit gate is a 2×2 unitary matrix multiplying the amplitude vector. Unitary means it preserves total probability, which geometrically means it rotates the Bloch sphere rigidly — no stretching, no collapsing. X, Y and Z are half-turns about the three axes. H is a half-turn about the diagonal axis halfway between x and z, which is why it swaps |0⟩ with |+⟩. S and T are partial turns about the z axis, by 90° and 45°, adding phase without touching the measurement probabilities. Rx, Ry and Rz let you turn by any angle you like. Gates are reversible: every one of them has an inverse, and running a circuit backwards undoes it exactly.

What happens when you measure?

Measurement in the Z basis returns 0 with probability |α|² and 1 with probability |β|², and afterwards the state really is |0⟩ or |1⟩ — the rest of the amplitude is gone, and repeating the measurement gives the same answer. A single shot therefore tells you very little. To learn what state you had, you have to prepare it again and measure again, many times; the shot histogram here converges to the dashed theoretical lines at a rate around 1/√N, so ten thousand shots pins a probability down to roughly one part in a hundred. You can also measure along x or y instead, which asks a different question of the same state and generally gives a different distribution.

Why does H·H return to |0⟩?

Apply H to |0⟩ and you get (|0⟩ + |1⟩)/√2 — a 50/50 measurement. Apply H again and you get |0⟩ back with certainty. If H were a randomiser, a second application would leave you at 50/50, not back where you started. What actually happens is that the two paths to |1⟩ arrive with opposite signs and cancel, while the two paths to |0⟩ arrive with the same sign and add. That is interference, and it needs the signs — the phases — that a probability alone cannot carry. It is the single clearest reason a qubit is not a coin: run lesson 3 and watch the arrow travel out to the equator and back rather than smearing into randomness.

FAQ

Is a qubit just a random bit?
No. A random bit is described by one number, the probability of 1. A qubit is described by two complex amplitudes, and the phase between them is physically meaningful: it decides whether two paths to the same outcome add or cancel. H·H = I demonstrates this directly, because two coin flips never return you to certainty.
Why does the Z gate appear to do nothing to |0⟩?
Z multiplies the |1⟩ amplitude by −1. If the state is |0⟩, the |1⟩ amplitude is zero, so the result is |0⟩ times an irrelevant overall factor and the Bloch arrow does not move. Sandwich it between Hadamards, though, and H·Z·H is exactly the X gate: the phase was always there, and H converts it into something you can see.
What is the difference between global and relative phase?
Multiplying the entire state by e^{iγ} is a global phase and has no measurable consequence in any basis, so it does not move the point on the Bloch sphere. A relative phase between α and β is the azimuth φ, and it does change results — just not the Z-basis probabilities, which is why you need an H or an X-basis measurement to detect it.
How many shots do I need to estimate a probability?
The statistical error on an estimated probability falls off like 1/√N. A hundred shots gives you roughly ±5 percentage points, ten thousand gives roughly ±0.5. That is why real quantum experiments repeat a circuit thousands of times; on hardware, gate and readout errors then set a floor below which more shots do not help.
Can this simulator show entanglement?
No — entanglement needs at least two qubits, and the Bloch sphere only describes one. It is also worth saying that a single qubit is not itself a speed-up: useful quantum algorithms need many qubits, entangling gates and interference working together. Multi-qubit states are the subject of the next sim in the series.