Quantum gates
A quantum gate is an operation that changes a qubit’s state. For a single qubit every gate is a rotation of the Bloch sphere: X, Y and Z turn it 180° around their own axes, Hadamard turns it 180° around the diagonal between X and Z, and S and T add 90° and 45° of phase.
Gates are matrices — and rotations
Mathematically, a gate on one qubit is a 2×2 matrix U that multiplies the state vector: |ψ'⟩ = U|ψ⟩. Not every matrix is allowed — it must be unitary, which means it keeps the total probability equal to 1 and can always be undone.
On the Bloch sphere that rule has a beautiful meaning: every single-qubit gate is a rotation of the sphere around some axis by some angle. Press any gate below; its rotation axis lights up in cyan while it acts.
The arrow points at the north pole, so measuring now gives 0 every time. Press a gate to rotate it, or drag the sphere to look around.
The six gates at a glance
| Gate | Axis | Angle | |0⟩ becomes | Changes P(0)? |
|---|---|---|---|---|
| X | X | 180° | |1⟩ | yes |
| Y | Y | 180° | i|1⟩ | yes |
| Z | Z | 180° | |0⟩ | no |
| H | (X + Z)/√2 | 180° | |+⟩ | yes |
| S | Z | 90° | |0⟩ | no |
| T | Z | 45° | |0⟩ | no |
Pauli-X: the quantum NOT
X swaps the two amplitudes. On the sphere it is a half turn around the X axis, which carries the north pole to the south pole. It is the direct analogue of the classical NOT gate.
Pauli-Y
A half turn around the Y axis. Like X it flips |0⟩ and |1⟩, but it also changes the phase. In fact Y = i·X·Z exactly.
Pauli-Z: the phase flip
Z leaves |0⟩ alone and flips the sign of |1⟩. On the sphere it is a half turn around the vertical axis: the poles do not move and the probabilities never change, but a state on the equator swings to the opposite side.
The Hadamard gate
The most used gate in quantum computing. It is a half turn around the diagonal axis halfway between X and Z, so it swaps the vertical axis with the X axis: poles go to the equator and back. Starting from |0⟩ it creates an equal superposition, which is why almost every algorithm begins with a layer of H gates.
The S gate
A quarter turn around the vertical axis: it adds a 90° phase to |1⟩. Two S gates make a Z.
The T gate
An eighth of a turn around the vertical axis (45° of phase). Two T gates make an S. Together with H, the T gate can approximate any single-qubit rotation, which makes it essential for universal quantum computing.
Order matters
Rotations in 3D do not commute, so neither do gates. Starting from |0⟩:
- H, then Z → |−⟩
- Z, then H → |+⟩
Try both in the widget above (press Reset between them) and compare where the arrow ends up.
Every gate can be undone
Because gates are rotations, you can always rotate back. X, Y, Z and H are their own inverses — apply them twice and you are back where you started. S needs three more S gates (or one S†), and T needs seven more T gates (or one T†). Measurement is the only step in a quantum program that cannot be reversed.
Summary
- A single-qubit gate is a unitary 2×2 matrix, and on the Bloch sphere it is a rotation.
- X, Y, Z are half turns around the three axes; H is a half turn around the X–Z diagonal.
- Z, S and T only change the phase — they spin the arrow around the vertical axis.
- Gates do not commute: their order changes the result.
Frequently asked questions
Why are quantum gates reversible?
Quantum gates are unitary matrices: they preserve the total probability, and every unitary U has an inverse U† that undoes it. On the Bloch sphere this is obvious — every rotation can be undone by rotating back. Measurement is the one operation that is not reversible.
How many different single-qubit gates are there?
Infinitely many: any rotation of the Bloch sphere, by any angle around any axis, is a valid gate. X, Y, Z, H, S and T are simply the most common named ones. Rotations by an arbitrary angle are written Rx(θ), Ry(θ) and Rz(θ).
What is a universal gate set?
A small set of gates that can approximate any quantum operation to any accuracy when combined. A standard example is {H, T, CNOT}: H and T alone can approximate any single-qubit rotation, and adding the two-qubit CNOT gate makes the set universal for any number of qubits.
What is the difference between the Hadamard gate and a NOT gate?
The NOT gate (X) swaps |0⟩ and |1⟩ — a 180° turn around the X axis. The Hadamard gate turns 180° around the diagonal between X and Z, so it moves the poles onto the equator: |0⟩ becomes the superposition |+⟩. Both are their own inverse.