The Quantum Circuit Model
Reading and writing circuit diagrams — the standard way algorithms are expressed
By the end of this topic you'll be able to
Complex operations on qubits, Binney and Skinner note, can be built up by sequences of elementary gates, and such sequences are conveniently described using a graphical notation: each qubit is represented by a line, or wire, along which its state flows from left to right, and each gate applied to it is drawn as a symbol on that line.
A filled dot connected by a vertical line to another symbol marks a control qubit for a multi-qubit gate — the graphical shorthand for exactly the controlled-U construction from the previous topic. A small meter-like symbol marks a measurement, the one place in the diagram where a qubit's role changes from carrying quantum information to producing a classical bit.
Mathematically, a circuit with no measurements is simply a sequence of unitary matrices multiplied together and applied to the initial state: U_final = Uₙ···U₂U₁, read right to left because that is how matrix multiplication acts on a ket sitting to its right. 'Running the circuit' means computing this product and then applying it to |ψ_initial⟩.
Everything before a measurement is deterministic linear algebra, in the fullest sense of that phrase — the state at every intermediate step is fixed exactly by the gates applied so far, with no fuzziness anywhere in the calculation. The only randomness in the entire process is injected precisely at the measurement gates themselves.
This is also why every non-measurement gate in a quantum circuit must be reversible: a unitary matrix always has an inverse, U⁻¹=U†, so any circuit can in principle be run backwards up to the point of measurement. Classical circuits use irreversible gates such as AND constantly — you cannot recover the two inputs from the single output — but a circuit built entirely from unitary gates can never erase information; only measurement can.
The practical skill this topic is really building is the ability to trace a circuit step by step: write the state vector after each gate in turn, and predict the resulting measurement probabilities at the end. This is exactly the skill the Quantum Sandbox is built to let you rehearse interactively, checking a by-hand calculation against a live simulation column by column.
Try It Yourself
A 1-qubit circuit applies X first, then H, to the initial state |0⟩. Write the overall circuit unitary as a single matrix product, and compute the final state.
- 1Gates are applied in time order X then H, but as matrices acting on a ket, the first-applied gate sits closest to the ket — so the overall unitary is U = H·X (H is applied second, so it's written on the left).
- 2Compute X|0⟩ first: X = [[0,1],[1,0]], so X|0⟩ = (0,1) = |1⟩.
- 3Now apply H to that result: H|1⟩ = (1/√2)(|0⟩−|1⟩) = |−⟩.
- 4So the final state is |−⟩ = (1/√2)(|0⟩−|1⟩), obtained either by applying the gates one at a time to the state, or equivalently by first forming U = HX as a single 2×2 matrix and then computing U|0⟩ — both routes must agree, since matrix multiplication is associative.
The overall unitary is U = H·X, and the final state is |−⟩ = (1/√2)(|0⟩−|1⟩).
Reference
| Wire | One qubit's timeline, left (start) to right (end) | |
| Control | Marks the control qubit(s) for a multi-qubit gate | |
| Measurement | Collapses the qubit and outputs a classical bit | |
| Circuit unitary | Product of all gate matrices, applied in time order |
Quick Check
In what order do you multiply the gate matrices U₁, U₂, U₃ (applied in that time order) to get the overall circuit unitary?
Why must every gate in a quantum circuit (except measurement) be reversible?