Quantum Gates

The building blocks of quantum computation - rotations, flips, and entanglement

The Building Blocks of Quantum Computation

Quantum gates are reversible operations on qubits — the quantum analogs of classical logic gates (AND, OR, NOT). Every quantum computation is a sequence of gates applied to qubits. Unlike classical gates, quantum gates are represented by unitary matrices, which preserve the total probability of quantum states.

A small set of gates (like H, T, and CNOT) is universal — any quantum algorithm can be decomposed into these primitive operations. This is the quantum analog of how NAND gates can build any classical circuit.

Gate Catalog

Browse the essential quantum gates. Each gate has a circuit symbol, a unitary matrix, and a description of what it does to qubit states. Single-qubit gates are 2×2 matrices; multi-qubit gates operate on larger state spaces.

Pauli Gates:
Rotation:
Phase Gates:
2-Qubit Gates:

Single-Qubit Gate Explorer

Apply gates one at a time and watch the qubit state evolve. The probability bars show how likely each measurement outcome is, and the complex amplitude circles show the full quantum state including phase. Try applying H to create superposition, then Z to flip the phase, then H again — you get X!

Apply:
Start from:

Two-Qubit Gates

Two-qubit gates create correlations between qubits. CNOT flips the target if the control is |1⟩ — it's the workhorse of quantum computing. CZ applies a phase when both qubits are |1⟩. SWAP exchanges two qubits. Select different input states to see how each gate transforms the two-qubit system.

Gate:Input:

Gate Decomposition

Complex gates can be broken down into simpler primitives. SWAP decomposes into three CNOTs. CNOT can be built from CZ and Hadamards. Even the 3-qubit Toffoli gate has a decomposition into single-qubit and two-qubit gates. This is how quantum compilers translate high-level operations into hardware-native gate sets.

Decomposition:
Step:

Gate Algebra

Quantum gates follow algebraic rules — but order matters! Gate multiplication is non-commutative: XZ ≠ ZX. Build gate sequences and see the resulting matrix. Discover identities like HZH = X, SS = Z, and XX = I. The matrix view shows exactly how the arithmetic works.

Add gate:
Try:

Involutions

X, Y, Z, and H are all their own inverses: applying them twice gives the identity. This makes them easy to undo.

Non-commutativity

XZ = −iY but ZX = iY. The sign difference matters! This is fundamentally different from classical gates where AND(a,b) = AND(b,a).

Key Takeaways

  • Unitary matrices — Quantum gates preserve probability and are always reversible (unlike classical AND/OR)
  • Universal gate sets{H, T, CNOT} can approximate any unitary to arbitrary precision (Solovay-Kitaev theorem)
  • Decomposition — Complex operations break down into sequences of simple primitive gates
  • Non-commutativity — Gate order matters: AB ≠ BA in general, which is a key feature of quantum mechanics
  • Entangling gates — Two-qubit gates like CNOT can create entanglement, which is essential for quantum advantage