In short: Quantum gates are the reversible, unitary operations that rotate qubit states inside a quantum circuit. A handful of them — the single-qubit X and H, and the two-qubit CNOT — combine into universal gate sets that can approximate any quantum computation. This guide explains what each gate does, why unitarity matters, and how gates assemble into circuits.
Quantum gates are the elementary operations of a quantum computer, the direct analogue of AND, OR and NOT in classical logic. But where a classical gate flips bits that are strictly 0 or 1, a quantum gate acts on a qubit — a two-level system whose state is a superposition α|0〉 + β|1〉, with complex amplitudes constrained by |α|² + |β|² = 1. A gate transforms those amplitudes.
Mathematically, every quantum gate on n qubits is a 2n × 2n unitary matrix. Applying a gate means multiplying the qubit’s state vector by that matrix. Because unitary operations preserve the total probability (the length of the state vector), quantum gates are always reversible — a crucial difference from classical gates like AND, which throw information away.
The two most important single-qubit gates illustrate the two things gates do: flip and mix.
The Pauli-X gate is the quantum bit-flip. It swaps the amplitudes of |0〉 and |1〉, so X|0〉 = |1〉 and X|1〉 = |0〉. Its matrix is simply the off-diagonal pair [[0,1],[1,0]]. On the Bloch sphere — the geometric picture of a single qubit — X is a 180° rotation about the x-axis.
The Hadamard gate is the gate that creates superposition, which is why almost every quantum algorithm begins with it. It maps |0〉 to the equal superposition (|0〉 + |1〉)/√2 and |1〉 to (|0〉 − |1〉)/√2. Measuring either of those states gives 0 or 1 with equal 50% probability. Apply H twice and you return exactly to where you started, because H is its own inverse.
Single-qubit gates alone cannot build interesting computation — you need a two-qubit gate that lets qubits interact. The workhorse is the controlled-NOT (CNOT). It has a control qubit and a target qubit: if the control is |1〉, the target is flipped by an X; if the control is |0〉, nothing happens. Its 4×4 matrix permutes the basis so that |10〉 ↔ |11〉 while |00〉 and |01〉 stay put.
The CNOT’s real power appears when the control is in superposition. Run H on the first qubit and then CNOT: the pair ends up in (|00〉 + |11〉)/√2 — a Bell state. The two qubits are now entangled: measuring one instantly determines the other, no matter the distance between them. This two-gate sequence is the canonical entanglement circuit.
Every gate being unitary has deep consequences. First, no information is lost mid-circuit: unlike a classical AND gate, a quantum gate can always be run backwards. Second, gates are norm-preserving, so amplitudes never blow up or vanish — the probabilities always sum to 1. Third, unitarity is exactly what lets interference work: amplitudes can add constructively or cancel destructively, which is how algorithms like Grover’s amplify the right answer.
Measurement is the one step that is not a gate — it is an irreversible collapse that extracts a classical bit and destroys the superposition. Everything before measurement is a product of unitary gates.
You do not need infinitely many distinct gates. A universal gate set is a finite collection whose products can approximate any unitary to arbitrary precision. Common universal sets include:
The Solovay–Kitaev theorem guarantees that such sets reach any target gate efficiently — the number of gates grows only poly-logarithmically in the precision you demand. A quantum circuit is then just a time-ordered sequence of these gates drawn left to right, with one horizontal wire per qubit, ending in measurements. Compiling a high-level algorithm means decomposing its ideal unitary into gates the hardware actually supports.
Real projects and industry tool flows, with certification.
Explore CourseTron Courses →Because they are unitary matrices, and every unitary has an inverse (U†). Reversibility is not a design choice — it falls out of the fact that quantum evolution conserves probability. Only measurement is irreversible.
On basis states they behave identically: both flip 0 and 1. But X also acts linearly on superpositions and rotates the full Bloch sphere, so it can transform states a classical NOT has no way to represent.
CNOT alone on classical inputs just copies a controlled flip. The entanglement appears when the control qubit is first put into superposition with H — the CNOT then correlates the two qubits into a state that cannot be written as two independent qubits.
A finite universal set — for example {H, T, CNOT} — suffices. The Solovay–Kitaev theorem shows any unitary can be approximated to precision ε using only about O(logc(1/ε)) gates from the set.
Related: qubit basics · Glossary · all courses.