Cheat sheet
Quantum gates cheat sheet
This sheet puts every standard quantum gate on one page, with its rule, its matrix, and what it does to the states you meet most. It prints cleanly on a single side of A4 or Letter paper, so use your browser's print command.
Write a qubit as a|0⟩ + b|1⟩. The numbers a and b are the amplitudes, and the chances of reading 0 and 1 are the squared sizes of a and b. A gate rewrites (a, b) by a fixed rule. New to this? Read Quantum gates explained first.
Single-qubit gates
| Gate | New (a, b) | Matrix, row by row | On |0⟩ | On |1⟩ | Undo |
|---|---|---|---|---|---|
| H | ((a + b) ÷ √2, (a − b) ÷ √2) | (1, 1) and (1, −1), all ÷ √2 | |+⟩ | |−⟩ | H |
| X | (b, a) | (0, 1) and (1, 0) | |1⟩ | |0⟩ | X |
| Y | (−ib, ia) | (0, −i) and (i, 0) | i|1⟩ | −i|0⟩ | Y |
| Z | (a, −b) | (1, 0) and (0, −1) | |0⟩ | −|1⟩ | Z |
| S | (a, ib) | (1, 0) and (0, i) | |0⟩ | i|1⟩ | S four times |
| T | (a, b × e^(iπ/4)) | (1, 0) and (0, e^(iπ/4)) | |0⟩ | e^(iπ/4)|1⟩ | T eight times |
Here i is the number whose square is −1, and e^(iπ/4) is about 0.71 + 0.71i. Z, S and T leave the chances alone and only turn the relative phase, by a half, a quarter and an eighth of a full turn. Their effect shows after a later gate such as H.
Two-qubit gate
| Gate | Rule | 00 | 01 | 10 | 11 |
|---|---|---|---|---|---|
| CNOT | Flips the second qubit (the target) wherever the first (the control) reads 1 | 00 | 01 | 11 | 10 |
The control is the left digit. Written as a table, CNOT swaps the last two of the four amplitudes and leaves the first two alone.
The six standard single-qubit states
| State | Amplitudes (0, 1) | Chance of 0, of 1 | How to make it from |0⟩ |
|---|---|---|---|
| |0⟩ | (1, 0) | 1, 0 | Nothing to do |
| |1⟩ | (0, 1) | 0, 1 | X |
| |+⟩ | (1, 1) ÷ √2 | ½, ½ | H |
| |−⟩ | (1, −1) ÷ √2 | ½, ½ | X, then H |
| |i⟩ | (1, i) ÷ √2 | ½, ½ | H, then S |
| |−i⟩ | (1, −i) ÷ √2 | ½, ½ | H, then S three times (or S, then Z) |
On the Bloch sphere, |0⟩ and |1⟩ sit at the top and bottom, |+⟩ and |−⟩ at the two ends of the left-right axis, and |i⟩ and |−i⟩ at the two ends of the front-back axis. Z, S and T turn the arrow about the vertical axis by a half, quarter and eighth turn. X, Y and Z are each a half turn about their own axis. H swaps the vertical axis with the left-right one.
The four Bell states
| Start | Then H on the first qubit, then CNOT | Name |
|---|---|---|
| 00 | (|00⟩ + |11⟩) ÷ √2 | Φ+ |
| 10 | (|00⟩ − |11⟩) ÷ √2 | Φ− |
| 01 | (|01⟩ + |10⟩) ÷ √2 | Ψ+ |
| 11 | (|01⟩ − |10⟩) ÷ √2 | Ψ− |
Each is a Bell state, the standard example of entanglement. The first two read 00 or 11, and the last two read 01 or 10, each half the time.
Identities worth memorising
- H, X, Y, Z and CNOT each undo themselves, so applying any of them twice does nothing.
- S twice is Z. T twice is S. T four times is Z.
- H, then Z, then H is X. H, then X, then H is Z. H, then Y, then H is −Y.
- X, then Y, then Z is the same as multiplying the whole state by i, which no measurement can see.
- Z, then X, then a factor of i, is Y.
- Order matters. On |0⟩, H then X gives |+⟩, but X then H gives |−⟩. The note The left-hand gate runs first shows both.
Reading and drawing circuits
- Time runs left to right. Each wire is one qubit, and each box is a gate.
- A dot joined by a line to a circled plus is a CNOT. The dot is the control and the circled plus is the target.
- A meter symbol at the end is a measurement, which turns the amplitudes into one plain bit per qubit.
Practise
Press each gate on the qubit page, then test yourself with Which Gate and Which Matrix. For the ideas behind the sheet, see What is superposition? and What is quantum entanglement?.
Questions people ask
What are the basic quantum gates?
The standard set is H, X, Y, Z, S, T and CNOT. H, X, Y, Z, S and T act on one qubit. CNOT acts on two.
What is the matrix for the Hadamard gate?
H is one over the square root of 2 times the table with rows (1, 1) and (1, −1). It turns |0⟩ into |+⟩ and |1⟩ into |−⟩.
What is the difference between the Z, S and T gates?
All three leave the amplitude for 0 alone and turn the amplitude for 1. Z turns it by a half turn, S by a quarter turn and T by an eighth of a turn.
Which gates undo themselves?
H, X, Y, Z and CNOT each undo themselves when applied twice. S needs four presses and T needs eight to return to the start.
How do I make a Bell state?
Start from 00, put H on the first qubit, then apply CNOT with the first qubit as the control. The result is (|00⟩ + |11⟩) ÷ √2.