The building blocks of quantum computation - rotations, flips, and entanglement
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.
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.
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!
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.
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.
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.
X, Y, Z, and H are all their own inverses: applying them twice gives the identity. This makes them easy to undo.
XZ = −iY but ZX = iY. The sign difference matters! This is fundamentally different from classical gates where AND(a,b) = AND(b,a).