A quantum gate is the quantum-computing equivalent of a classical logic gate. It takes a qubit (or several) in one state, and produces a qubit in a different state. The state changes deterministically: the same gate applied to the same input always gives the same output.
The cleanest way to picture a single-qubit gate is as a rotation on the Bloch sphere. Click any of the gates in the interactive above and watch the arrow swing to its new position.
Quantum vs. classical gates
Three differences you should know:
- Inputs can be in superposition. A classical gate sees a 0 or a 1. A quantum gate sees the whole superposition at once and operates on every part of it simultaneously.
- Every quantum gate is reversible. They're all unitary matrices, which are always invertible. Classical AND, OR, and NAND lose information and can't be undone. Quantum gates can.
- There's a continuous space of them. Classical gates are discrete (you're either AND-ing or you're not). Single-qubit quantum gates are described by 2×2 unitary matrices, a continuous family of operations.
The common gates
You only need a handful of single-qubit gates to do everything single-qubit gates can do:
- H (Hadamard): creates superposition. The most-used gate.
- X (Pauli-X): quantum NOT. Flips
|0⟩↔|1⟩. - Y (Pauli-Y): 180° rotation about the y-axis.
- Z (Pauli-Z): phase flip. Leaves
|0⟩alone, sends|1⟩to−|1⟩. - S: 90° rotation about the z-axis. Adds a quarter-turn of phase to
|1⟩. - T: 45° rotation about the z-axis. Adds an eighth-turn of phase.
A gate is a unitary matrix
The thing that makes something a valid quantum gate is that its matrix is unitary: U · U† = I (the matrix times its conjugate-transpose is the identity). That property is what guarantees the gate preserves total probability and is reversible.
For a single qubit, a gate is a 2×2 unitary. For two qubits, it's 4×4.
with |a|² + |c|² = 1, |b|² + |d|² = 1, and the columns orthogonal.
Two-qubit gates
Single-qubit gates can't create entanglement. To do that you need a two-qubit gate. The most important is the CNOT (controlled-NOT): it flips the second qubit only if the first qubit is in |1⟩.
Combine CNOT with the single-qubit gates above and you can build any quantum operation, on any number of qubits, to any desired precision. That's what people mean when they say {H, T, CNOT} is a universal gate set.
Related concepts
- Hadamard gate: the gate that creates superposition.
- Pauli gates (X, Y, Z): the three basic rotations.
- Quantum measurement: the one non-gate thing you can do to a qubit.
- The Bloch sphere: the picture gates rotate.
Frequently asked questions
What is a quantum gate in simple terms?
A quantum gate is an operation that rotates a qubit on the Bloch sphere. It takes a quantum state in and gives a different quantum state out, always the same rotation for the same gate. Quantum algorithms are sequences of these gates, just like classical programs are sequences of NAND, AND, and OR.
How are quantum gates different from classical logic gates?
Classical gates take bits (0 or 1) and produce bits. Quantum gates take qubits, which can be in superposition, and the gate operates on the whole superposition at once. Also, every quantum gate is reversible: you can always undo it. Many classical gates (like AND) lose information and aren't reversible.
How many different quantum gates are there?
Mathematically, infinitely many: any unitary 2×2 matrix is a valid single-qubit gate, and there's a continuous space of them. In practice, real quantum hardware implements a small universal gate set (often {H, T, CNOT}) and combines them to build whatever operation an algorithm needs.
What are the most important single-qubit quantum gates?
The five gates you'll see most often: H (Hadamard) creates superposition; the three Pauli gates X, Y, Z are 180° rotations about each axis (Pauli-X is the quantum NOT); and S and T add 90° and 45° of phase respectively. Combine them and you can approximate any single-qubit operation.
What about two-qubit gates?
The most common two-qubit gate is CNOT (controlled-NOT). It flips the target qubit only when the control qubit is in |1⟩. CNOT is what creates entanglement between qubits; without it, single-qubit gates can't generate any.
Are quantum gates always reversible?
Yes. Every quantum gate is described by a unitary matrix, and unitary matrices are always invertible. The only place irreversibility enters is during measurement, which isn't a gate.
Is the Hadamard gate the most important quantum gate?
It's certainly the most-used. Almost every quantum algorithm starts with a Hadamard on every qubit to create a uniform superposition over all inputs. Without that opening move, there's no quantum parallelism to exploit.
Get Qubi
Run quantum gates with your hands.
Qubi is a real model qubit you can hold. Apply H, X, Y, Z, S, T, and see the state change in your hand.