• Fundamentals
  • Also: quantum logic gate

Quantum Gate

A basic operation applied to qubits that transforms their quantum state, the quantum analogue of classical logic gates, but always reversible.

Quantum gates are the elementary operations that manipulate qubits in a quantum circuit. They are the quantum analogue of classical logic gates (AND, OR, NOT), but with a critical difference: every quantum gate is reversible. Running a quantum gate backward restores the original state exactly. This reversibility is not optional; it is mathematically required by quantum mechanics.

This constraint means that quantum computation is fundamentally different from classical computation, where most gates (AND, OR) discard information and are irreversible.

The details

A quantum gate acting on nn qubits is represented by a 2n×2n2^n \times 2^n unitary matrix UU. The requirement UU=IU^\dagger U = I is what enforces reversibility: the inverse of UU is simply UU^\dagger (the conjugate transpose).

Single-qubit gates: Act on one qubit at a time, represented by 2×22 \times 2 unitary matrices.

  • Hadamard (H): Creates equal superposition from basis states. H=12(1111)H = \frac{1}{\sqrt{2}}\begin{pmatrix}1 & 1 \\ 1 & -1\end{pmatrix}
  • Pauli-X: Bit flip, the quantum NOT gate. X=(0110)X = \begin{pmatrix}0 & 1 \\ 1 & 0\end{pmatrix}
  • Pauli-Z: Phase flip. Z=(1001)Z = \begin{pmatrix}1 & 0 \\ 0 & -1\end{pmatrix}
  • S gate: 90°90° phase rotation. S=(100i)S = \begin{pmatrix}1 & 0 \\ 0 & i\end{pmatrix}
  • T gate: 45°45° phase rotation. T=(100eiπ/4)T = \begin{pmatrix}1 & 0 \\ 0 & e^{i\pi/4}\end{pmatrix}

Two-qubit gates: Act on pairs of qubits, represented by 4×44 \times 4 matrices.

  • CNOT: Flips the target if the control is 1|1\rangle. The primary entangling gate.
  • CZ: Applies a ZZ gate to the target if the control is 1|1\rangle.
  • SWAP: Exchanges the states of two qubits.

Three-qubit gates:

  • Toffoli (CCNOT): Flips the target if both controls are 1|1\rangle. Can implement any classical Boolean function reversibly.

Universal gate sets: A gate set is universal if any quantum computation can be approximated to arbitrary precision using only gates from that set. The set {H,T,CNOT}\{H, T, \text{CNOT}\} is a widely used universal gate set. The T gate is critical; without it, circuits using only H, X, Y, Z, S, and CNOT (the Clifford gates) can be simulated efficiently by classical computers.

from qiskit import QuantumCircuit

qc = QuantumCircuit(2)
qc.h(0)        # Hadamard
qc.t(0)        # T gate
qc.cx(0, 1)    # CNOT (entangling)
qc.s(1)        # S gate
print(qc.draw())

Why it matters for learners

Quantum gates are the vocabulary of quantum algorithms. Every algorithm is a circuit: a sequence of gates chosen to manipulate probability amplitudes so that the correct answer has high probability at measurement.

Understanding which gates are cheap versus expensive on real hardware matters enormously. Single-qubit gates are fast and relatively low-noise. Two-qubit gates are slower and noisy; on current superconducting hardware, CNOT error rates (0.11%0.1-1\%) are 10 to 100 times worse than single-qubit error rates. Minimizing CNOT count is therefore a primary goal of circuit optimization.

The T gate has special significance for fault tolerance. In the surface code, T gates require expensive “magic state distillation” procedures, consuming many logical qubits and many rounds of error correction. Counting T-gates in a circuit is a standard way to estimate its fault-tolerant resource cost.

Common misconceptions

Misconception 1: Classical AND and OR gates have quantum equivalents. AND and OR are irreversible (they discard input information), so no direct quantum version exists. The Toffoli gate computes AND reversibly by storing the result in an ancilla qubit while preserving both inputs. Universal classical computation can be implemented with Toffoli gates alone.

Misconception 2: You can use any unitary matrix as a quantum gate. Any unitary matrix is theoretically a valid quantum gate. In practice, physical hardware can only implement a specific native gate set (e.g., IBM uses single-qubit rotations and CX; IonQ uses XX-rotation gates). Other gates must be decomposed into the native set, which increases circuit depth.

Misconception 3: Quantum gates are deterministic. The gates themselves are deterministic (they apply a specific matrix to the state vector). The randomness comes only at measurement, when the Born rule collapses the state to a probabilistic outcome. Gate operations before measurement are entirely deterministic transformations of complex amplitudes.

See also