Circuit workbench: build a small circuit, predict it, run it
Predict what each gate will do, put it on a wire, and watch the result change at once.
You'll need Superposition and How quantum gates work first. Skip to Build freely
The lab didn't load, so reload the page to try again; the answers, the maths and the sources below work without it.
Challenge 1 of 5
Make a qubit that reads 1 every time
Gates drag one onto a wireGates tap one, then tap a slot
Qubits
Drag a gate onto a wire, or tap a gate and then a slot.
Qubit A at the start
| Result | Chance as a bar | Amplitude | Chance | Readings |
|---|---|---|---|---|
| 0 | +1.00 | 100% | ||
| 1 | 0.00 | 0% | ||
| 010 | 0.00 | 0% | ||
| 011 | 0.00 | 0% | ||
| 100 | 0.00 | 0% | ||
| 101 | 0.00 | 0% | ||
| 110 | 0.00 | 0% | ||
| 111 | 0.00 | 0% |
- solid: amplitude +
- striped: amplitude −
- bar length: chance
The qubit starts as 0.
Goal: one qubit, starting as 0, that reads 1 every time.
In this simulation every gate and every reading is perfect.
Circuit on qubit A, with no steps yet. The qubit starts as 0 and is measured at the end.
The four gates
- H turns a plain 0 or 1 into an even blend, and turns that blend back.
- X swaps 0 and 1.
- Z flips the sign of the amplitude of 1 and leaves 0 alone.
- The controlled flip (CNOT) acts on two qubits: it flips its target only where its control is 1.
Check yourself
One qubit starts as 0. The circuit is X, then H. What are the chances of 0 and 1?
Answer
Half each. X makes a plain 1, and H turns a plain 1 into an even blend, this time with a negative amplitude on 1. The sign doesn't change the chances.
Two circuits on one qubit: H alone, and H then Z. Both read 0 or 1, half each. Are they the same state? How could you tell?
Answer
No. After H, Z the amplitude of 1 is negative. Add one more H to each: H, H reads 0 every time, and H, Z, H reads 1 every time.
Two qubits start as 00. The circuit is a controlled flip (A controls, B is flipped), then H on A. Do the two qubits always match?
Answer
No. The controlled flip comes first, while A is still a plain 0, so it does nothing. H then blends A alone: 00 or 10, half each. The order of the steps matters.
One qubit: X, then Z. The bar for 1 is striped, with an amplitude of −1.00. Has the Z changed anything you could measure?
Answer
No. There's only one non-zero amplitude, so its sign is the sign of the whole state. Flipping every sign together changes nothing you could measure, now or later.
More recall questions on these ideas are in the lessons: How quantum gates work and Superposition.
Show the maths
- The state of n qubits is a list of 2n amplitudes, one for each result: 2, 4 or 8 numbers here. At the start the all-0s result has amplitude 1 and the rest have 0. Each result has an amplitude, which can be negative, and a chance, which is the amplitude squared. Amplitudes are shown to two decimals: 0.71 squares to a half, 0.50 to a quarter and 0.35 to an eighth.
- H on a qubit takes each pair of results that differ only in that qubit, with amplitudes a (where it's 0) and b (where it's 1), and replaces them with (a + b)/√2 and (a − b)/√2.
- X on a qubit swaps a and b in each such pair. Z replaces b with −b.
- The controlled flip swaps the two amplitudes in each pair of results that differ only in the target, but only for the results where the control is 1.
- Chances: the chance of a result is its amplitude squared, and the chances always add up to 1.
- With these four gates every amplitude stays a real number: 0, or plus or minus 1, 1/√2 (about 0.71), 1/2 or 1/√8 (about 0.35). Some other gates need complex numbers, which this page leaves out.
- The pair that always matches: H on A gives (|00⟩ + |10⟩)/√2. The controlled flip then turns |10⟩ into |11⟩, giving (|00⟩ + |11⟩)/√2. One more controlled flip onto C gives (|000⟩ + |111⟩)/√2.
What this page leaves out
- Most gates. With these four gates, every result that can happen is equally likely. Other gates tilt the chances, for example to 85% and 15%.
- The overall sign. The bars show the amplitudes exactly as the circuit produces them. Flipping every sign together would change nothing you could measure, now or later, so a state and its all-signs-flipped twin are the same state.
- Errors. Every gate and every reading here is perfect. On real hardware each gate adds a small chance of error, for the reasons in Why qubits are so fragile.
- Size. Three qubits and six steps are far too few to show any advantage over an ordinary computer. A laptop can follow every circuit on this page exactly, which is why the page can check your answers.
- Saving, sharing and code. You can't save a circuit, share it or turn it into code: this is a small, ideal teaching workbench. Nothing you build is kept.
- It's a calculation, not an experiment. The page works out each state with quantum theory's rules and draws each run with an ordinary random number generator. Nothing runs on a quantum computer.
Where to go next
- What circuits are for: How a quantum algorithm works.
- The pair from challenge 4, tested against a coin toss: Build an entangled pair.
- How a sign you can't see changes a result: Interference: split, turn, recombine.
The page runs entirely in your browser. Your circuits, your predictions and your results aren't stored, and this page's own code doesn't send them anywhere. Cloudflare Web Analytics runs on every Plain Quantum page and measures how each page loads and responds, including to clicks and key presses; see Privacy. The model is tested automatically: every state these circuits can reach is checked against an exact calculation.
Sources and further reading
Tags show the kind of source (how sources are chosen and checked). Spotted an error? Report a correction.
- BookQuantum Computation and Quantum Information (10th anniversary edition)Michael Nielsen and Isaac Chuang, Cambridge University Press, 2010