Quantum Gate Reference
A catalog of the workhorse gates — single-qubit rotations and the multi-qubit controlled gates — with their matrices and exactly what they do.
Every quantum circuit is built from a small set of reusable gates. This lesson is a reference: each single-qubit gate is a unitary matrix acting on the amplitude vector of , and each multi-qubit gate is a permutation (or sign change) on the computational basis states.
Pick a gate and an input below to see its matrix and the resulting amplitudes. Watch how , , and paint a phase onto an amplitude without changing its probability.
Hadamard: maps |0⟩→|+⟩ and |1⟩→|−⟩, creating equal superposition.
All amplitudes here are real, so the bars fully describe the state up to a sign.
Single-qubit gates
Pauli gates
The three Pauli gates are the fundamental single-qubit errors and also useful operations in their own right.
- (NOT / bit flip): swaps the amplitudes of and .
- (bit-and-phase flip): combines a bit flip with a phase, using imaginary entries.
- (phase flip): leaves alone and negates the amplitude.
Hadamard
The Hadamard gate creates and destroys superposition. It maps the basis states to the even mixes and :
Because , applying it twice returns the original state — the two branches interfere and recombine.
Phase gates: S and T
The and gates rotate the phase of the amplitude. They do nothing visible to a single measurement, but they are essential for interference and for building arbitrary rotations.
Note the relationships and : is a phase, a phase, and a phase. The set generates the Clifford group; adding the non-Clifford gate makes the set universal for single-qubit operations.
A global phase like multiplying the whole state is undetectable. Only a relative phase — a different phase on than on — changes physics, and it does so by steering later interference.
Multi-qubit gates
Multi-qubit gates act on basis states. We order two-qubit states as , with the left bit as the control where relevant.
CNOT (controlled-NOT)
flips the target qubit when the control is , and does nothing when the control is :
| input | output |
|---|---|
| $ | 00\rangle$ |
| $ | 01\rangle$ |
| $ | 10\rangle$ |
| $ | 11\rangle$ |
It is the entangling gate behind the Bell state: .
CZ (controlled-Z)
applies a to the target when the control is — in practice it just flips the sign of . It is symmetric: control and target are interchangeable.
| input | output |
|---|---|
| $ | 00\rangle$ |
| $ | 01\rangle$ |
| $ | 10\rangle$ |
| $ | 11\rangle$ |
Conjugating with Hadamards on the target turns one into the other: .
SWAP
exchanges the states of the two qubits, leaving the matching basis states and fixed:
| input | output |
|---|---|
| $ | 00\rangle$ |
| $ | 01\rangle$ |
| $ | 10\rangle$ |
| $ | 11\rangle$ |
A decomposes into three CNOTs in alternating directions.
Toffoli (CCNOT)
The Toffoli gate is a doubly-controlled NOT on three qubits (): it flips the target only when both controls are . Every basis state is unchanged except the last two, which are swapped:
| input | output |
|---|---|
| $ | 110\rangle$ |
| $ | 111\rangle$ |
| all others | unchanged |
Toffoli is universal for classical reversible computation — it can build AND, NAND, and fan-out — so it bridges classical logic into the reversible quantum world.
Takeaways
- Single-qubit gates are unitaries: flips bits, flips phase, does both, and creates superposition.
- and add and phases to ; with you can approximate any single-qubit gate, and is the non-Clifford piece.
- A relative phase is invisible to one measurement but governs interference; a global phase is never observable.
- CNOT and CZ are the entangling two-qubit gates (related by Hadamards on the target), SWAP exchanges two qubits, and Toffoli (CCNOT) is universal for reversible classical logic.