Single-Qubit Circuit Patterns
Five small patterns cover most work on one qubit: prepare, rotate, shift phase, undo, and change basis before measuring. Gate order matters, so it pays to learn them as patterns. Single gate facts on their own are easy to misuse.
Why learn patterns instead of gates?
Single gates are easy to memorise and easy to misuse. Short patterns with names are easier to debug. Each one has a job and a result you can check. It is like learning chess openings instead of just how each piece moves.
Here are the five worth knowing:
- Prepare: set a known starting state on purpose. Then your guesses about the start are visible in the circuit.
- Rotate: move some amplitude between 0 and 1 by a chosen amount. An amplitude is the number you square to get an answer's chance.
- Phase: change the sign (or angle) of an amplitude. On its own this changes no chance at all. It is invisible alone, but it decides what happens later.
- Undo: apply a gate's inverse, the gate that reverses it. The state goes back to exactly what it was. This is a built-in self-test.
- Basis change before measurement: turn the question you want to ask into the standard "0 or 1?" readout.
- Worked example: how does the undo pattern (H then H) work?
- Run the undo pairINTERACTIVE
- Worked example: how does a hidden sign show up (H, Z, H)?
- Compare: one sign flip in the middleINTERACTIVE
- How does the rotate pattern RY(θ) work?
- Try this: what if I replace the second H with X?INTERACTIVE
- Why measure in the right basis?
You’ve read the opening of chapter 3. Pro unlocks the other 7 sections — plus every chapter of every course, with circuits you can run right on the page. That’s $11.99 a month, about the price of a coffee, or $99.99 a year (save 30%). The first chapter of every course, and the whole math course, stay free.