If a qubit is a dot on the surface of a globe, a gate is a turn of that globe. Nothing is added, nothing is lost, and you can always turn it back.
That last bit matters. Every quantum gate can be undone.
H carries an overall factor of 1/√2 so that its columns stay unit length.
The four you will meet most
X is the flip. It swaps 0 and 1 — the quantum version of "not".
Z leaves 0 alone and flips the sign on the 1. Look straight away and nothing has changed. That sounds useless. It is the opposite of useless, and lesson seven is about why.
H is the workhorse. Give it a plain 0 and it hands back an even mixture of 0 and 1. Almost every quantum program starts by doing this to every qubit at once.
S and T are smaller sign twiddles — a quarter turn and an eighth turn. You need them because the first three cannot reach every point on the globe.
Universal set
A small group of gates that can build any other gate, the way any recipe can be written with a handful of basic steps. H, T and one two-qubit gate are enough.
The one that involves two qubits
Single-qubit gates on their own are boring — an ordinary computer can keep up with them, and they never entangle anything.
For that you need a gate where one qubit has a say over another. CNOT flips the second qubit if the first one is a 1.
Now feed it a first qubit that is a mixture of both. It does not pick. It entangles them. That is the whole of the Bell pair from lesson three.
Nothing is allowed to be forgotten
An ordinary AND gate takes two bits and gives back one. The other bit is gone — you cannot work backwards from the answer.
Quantum gates are not allowed to do that. Every one must be undoable. So if you want a quantum computer to run some ordinary calculation, you first have to rewrite it in a form that never throws anything away, usually by carrying the input along beside the answer.
Worth remembering
- A gate is a turn of the qubit, and every gate can be undone.
- X flips, Z flips a sign, H makes an even mixture, S and T make smaller sign twiddles.
- CNOT lets one qubit control another. It is how you entangle things.
- A few gates are enough to build all the rest.
- Ordinary calculations must be rewritten so nothing is thrown away.