What is a quantum gate?

A quantum gate is an operation that transforms the state of one or more qubits. The analogy to classical logic gates is useful but limited: classical gates like AND and OR can discard information (two different input combinations can produce the same output), whereas quantum gates are always reversible.

Mathematically, every quantum gate is represented by a unitary matrix U satisfying U†U = I, where U† is the conjugate transpose of U. Unitarity guarantees two things: the transformation preserves the total probability (the state vector stays normalized), and the gate can always be undone by applying U†. This is not an engineering choice but a fundamental requirement of quantum mechanics.

When a gate is applied to a qubit in state |ψ⟩, the new state is simply U|ψ⟩ - matrix multiplication of the gate matrix by the state vector. For multi-qubit gates, the matrix dimension grows as 2^n where n is the number of qubits involved. A two-qubit gate is represented by a 4x4 unitary matrix; a three-qubit gate by an 8x8 matrix.

Single-qubit gates

Each single-qubit gate is a 2x2 unitary matrix. All are their own inverse except S (inverse is S†) and T (inverse is T†).

H Hadamard (H)
1/√2 · [[1, 1], [1, -1]]

Creates equal superposition from a basis state. Maps |0⟩ to (|0⟩+|1⟩)/√2 and |1⟩ to (|0⟩-|1⟩)/√2.

X Pauli-X
[[0, 1], [1, 0]]

Bit flip. Maps |0⟩ to |1⟩ and |1⟩ to |0⟩. The quantum equivalent of a classical NOT gate.

Y Pauli-Y
[[0, -i], [i, 0]]

Combined bit and phase flip. Maps |0⟩ to i|1⟩ and |1⟩ to -i|0⟩.

Z Pauli-Z
[[1, 0], [0, -1]]

Phase flip. Leaves |0⟩ unchanged, maps |1⟩ to -|1⟩. Only affects the phase of the |1⟩ component.

S Phase (S)
[[1, 0], [0, i]]

Applies a 90-degree phase shift to |1⟩. S = sqrt(Z). Two S gates are equivalent to one Z gate.

T T gate
[[1, 0], [0, e^(iπ/4)]]

Applies a 45-degree phase shift to |1⟩. T = sqrt(S). Critical for universality in the Clifford+T gate set.

Rx Rotation Rx(θ)
[[cos(θ/2), -i·sin(θ/2)], [-i·sin(θ/2), cos(θ/2)]]

Rotates the qubit state by angle θ around the X axis of the Bloch sphere.

Ry Rotation Ry(θ)
[[cos(θ/2), -sin(θ/2)], [sin(θ/2), cos(θ/2)]]

Rotates the qubit state by angle θ around the Y axis of the Bloch sphere. Used heavily in variational algorithms.

Rz Rotation Rz(θ)
[[e^(-iθ/2), 0], [0, e^(iθ/2)]]

Rotates the qubit state by angle θ around the Z axis. Often implemented as a virtual gate with no physical pulse.

Two-qubit gates

Two-qubit gates are 4x4 unitary matrices. They are the primary mechanism for creating and manipulating entanglement between qubits.

CX CNOT (CX)

Flips the target qubit if and only if the control qubit is |1⟩. The most common two-qubit gate; essential for creating entanglement.

CZ CZ

Applies a Z (phase flip) to the target qubit if the control qubit is |1⟩. Symmetric: either qubit can be treated as the control.

SWAP SWAP

Exchanges the states of two qubits entirely. Used by compilers to route interactions between non-adjacent qubits on hardware.

iSWAP iSWAP

Swaps the |01⟩ and |10⟩ components and applies an i phase factor. Native gate on some superconducting hardware.

CH Controlled-H

Applies the Hadamard gate to the target qubit only if the control qubit is |1⟩. Creates conditional superposition.

CP(θ) Controlled-Phase (CP)

Applies a phase shift of e^(iθ) to the |11⟩ component only. Used in the quantum Fourier transform.

Three-qubit gates

Three-qubit gates are 8x8 unitary matrices. They are rarely implemented as native hardware gates but appear frequently in circuit decompositions, error correction, and algorithm descriptions. They can always be decomposed into sequences of single- and two-qubit gates.

Toffoli gate (CCNOT)

The Toffoli gate has two control qubits and one target qubit. The target is flipped only when both controls are |1⟩. It is the quantum equivalent of a classical AND gate (combined with a NOT) and is significant because it makes quantum circuits classically universal: any classical reversible computation can be expressed using Toffoli gates alone. In quantum error correction, Toffoli gates are used to implement syndrome measurements and fault-tolerant logical operations. A Toffoli gate can be decomposed into 6 CNOT gates plus several single-qubit gates.

Fredkin gate (CSWAP)

The Fredkin gate has one control qubit and two target qubits. When the control is |1⟩, the two target qubits are swapped; when the control is |0⟩, both targets are unchanged. Like the Toffoli gate, the Fredkin gate is classically universal and reversible. It also has the property of conserving the number of |1⟩s in the target register, which makes it useful for quantum fingerprinting protocols and controlled SWAP tests - a standard subroutine for comparing two quantum states without measuring them directly.

Universal gate sets

A universal gate set is a finite collection of gates that can approximate any unitary operation to arbitrary precision. This matters because real quantum hardware only natively implements a small fixed set of gates. Any algorithm must be compiled down to that native gate set, and universality guarantees this is always possible.

Clifford + T

The Clifford group consists of gates that map Pauli operators to other Pauli operators under conjugation. Key Clifford gates are H, S, and CNOT. The Clifford group alone is not universal - it can be efficiently simulated classically (Gottesman-Knill theorem). Adding the T gate makes the set universal. T gates are expensive to implement fault-tolerantly, which is why minimizing T-count is an important optimization target in quantum compiling.

{H, T, CNOT}

This closely related set is explicitly universal. H creates superposition, T provides the non-Clifford rotation needed for universality, and CNOT provides entanglement. The Solovay-Kitaev theorem guarantees that any single-qubit unitary can be approximated to precision epsilon using O(log^c(1/epsilon)) gates from a universal set, where c is approximately 2. In practice this means efficient compilation is always possible.

Native hardware gate sets

Hardware vendors define their own native gate sets based on what their physical qubits support directly. IBM uses the set {CX, ID, RZ, SX, X}, while Rigetti uses CZ and XY family gates. Quantinuum's trapped-ion processors use a native two-qubit gate called ZZ. Quantum compilers automatically decompose any circuit into the target hardware's native gates, adding SWAP gates as needed for qubit routing.

Courses covering quantum gates and circuits

Courses that teach quantum gate theory, circuit design, and hands-on implementation in Qiskit, PennyLane, or other frameworks.

Frequently asked questions

What makes a quantum gate different from a classical logic gate?
Classical logic gates (AND, OR, NOT) operate on bits and can be irreversible: two inputs can produce the same output, so you cannot always reconstruct the inputs from the output. Quantum gates are always reversible because they are represented by unitary matrices. A unitary matrix has an inverse equal to its conjugate transpose, so every quantum gate can be undone exactly. This reversibility is a direct consequence of the time-reversal symmetry of quantum mechanics and is not optional. Quantum gates also differ because they operate on continuous-valued amplitudes, can create superpositions, and can act on entangled states in ways that have no classical analog.
What is the Hadamard gate used for?
The Hadamard gate (H) is the primary tool for creating superposition. Applied to |0>, it produces an equal superposition (|0> + |1>) / sqrt(2). Applied to |1>, it produces (|0> - |1>) / sqrt(2). Circuits that begin by applying Hadamard gates to all qubits initialized in |0> create an equal superposition over all 2^n computational basis states - a key step in many quantum algorithms including Grover's algorithm, quantum phase estimation, and the quantum Fourier transform. The Hadamard gate is also its own inverse: applying H twice returns the qubit to its original state.
What is a CNOT gate?
The CNOT (Controlled-NOT, or CX) gate is a two-qubit gate with one control qubit and one target qubit. If the control qubit is |0>, the target qubit is left unchanged. If the control qubit is |1>, the target qubit is flipped (X is applied to it). The CNOT gate is the canonical two-qubit gate and is essential for creating entanglement. Applying a Hadamard gate to the first qubit followed by a CNOT produces a Bell state - a maximally entangled two-qubit state. CNOT is one of the most commonly used gates in circuit implementations and is available natively on most quantum hardware.
What is a universal quantum gate set?
A universal gate set is a small set of gates from which any unitary operation on any number of qubits can be approximated to arbitrary precision. This is analogous to how NAND gates alone can implement any classical Boolean function. Two common universal sets are the Clifford+T set (H, S, CNOT, and T) and {H, T, CNOT}. The Solovay-Kitaev theorem guarantees that any single-qubit unitary can be approximated efficiently using elements from a universal set. Universality matters because hardware only implements a finite native gate set, and compilers must decompose arbitrary unitaries into sequences of those native gates.
How are quantum gates implemented physically?
The physical implementation of quantum gates depends on the hardware platform. On superconducting processors, single-qubit gates are implemented with carefully shaped microwave pulses that drive transitions between energy levels; two-qubit gates use coupling between neighboring qubits via cross-resonance or parametric modulation. On trapped-ion systems, laser pulses drive transitions between internal electronic states; two-qubit gates use the shared vibrational modes of the ion chain to mediate interactions. On neutral-atom platforms, laser pulses implement single-qubit rotations and Rydberg blockade interactions implement two-qubit gates. In all cases the goal is to apply a precise unitary transformation as quickly and accurately as possible before decoherence degrades the state.