Quantum

Quantum gates

By CourseTron Team ·  6 min read ·  Updated Oct 2026 💬 𝕏 in f
Table of Contents
    🖨  Download / Print this guide (PDF)

    In short: Quantum gates are the reversible, unitary operations that rotate qubit states inside a quantum circuit. A handful of them — the single-qubit X and H, and the two-qubit CNOT — combine into universal gate sets that can approximate any quantum computation. This guide explains what each gate does, why unitarity matters, and how gates assemble into circuits.

    What are quantum gates?

    Quantum gates are the elementary operations of a quantum computer, the direct analogue of AND, OR and NOT in classical logic. But where a classical gate flips bits that are strictly 0 or 1, a quantum gate acts on a qubit — a two-level system whose state is a superposition α|0⟩ + β|1⟩, with complex amplitudes constrained by |α|² + |β|² = 1. A gate transforms those amplitudes.

    Mathematically, every quantum gate on n qubits is a 2n × 2n unitary matrix. Applying a gate means multiplying the qubit’s state vector by that matrix. Because unitary operations preserve the total probability (the length of the state vector), quantum gates are always reversible — a crucial difference from classical gates like AND, which throw information away.

    Key fact: A matrix U is unitary when U†U = I (its conjugate transpose is its inverse). This single condition guarantees that every quantum gate conserves probability and can be undone — running the gate again with U† returns the original state.

    The single-qubit gates: X and H

    The two most important single-qubit gates illustrate the two things gates do: flip and mix.

    The X gate (quantum NOT)

    The Pauli-X gate is the quantum bit-flip. It swaps the amplitudes of |0⟩ and |1⟩, so X|0⟩ = |1⟩ and X|1⟩ = |0⟩. Its matrix is simply the off-diagonal pair [[0,1],[1,0]]. On the Bloch sphere — the geometric picture of a single qubit — X is a 180° rotation about the x-axis.

    The Hadamard gate (H)

    The Hadamard gate is the gate that creates superposition, which is why almost every quantum algorithm begins with it. It maps |0⟩ to the equal superposition (|0⟩ + |1⟩)/√2 and |1⟩ to (|0⟩ − |1⟩)/√2. Measuring either of those states gives 0 or 1 with equal 50% probability. Apply H twice and you return exactly to where you started, because H is its own inverse.

    Single-qubit gates: flip (X) and mix (H)|0⟩X|1⟩bit-flip (reversible NOT)|0⟩H(|0⟩+|1⟩)/√2equal superpositionP(0)=0.5P(1)=0.5CourseTron · coursetron.com
    X flips a basis state; H spreads |0⟩ into an equal superposition that measures 0 or 1 with equal odds.

    The CNOT gate: entangling two qubits

    Single-qubit gates alone cannot build interesting computation — you need a two-qubit gate that lets qubits interact. The workhorse is the controlled-NOT (CNOT). It has a control qubit and a target qubit: if the control is |1⟩, the target is flipped by an X; if the control is |0⟩, nothing happens. Its 4×4 matrix permutes the basis so that |10⟩ ↔ |11⟩ while |00⟩ and |01⟩ stay put.

    The CNOT’s real power appears when the control is in superposition. Run H on the first qubit and then CNOT: the pair ends up in (|00⟩ + |11⟩)/√2 — a Bell state. The two qubits are now entangled: measuring one instantly determines the other, no matter the distance between them. This two-gate sequence is the canonical entanglement circuit.

    Bell-state circuit: H then CNOTq0 |0⟩q1 |0⟩HsuperpositionCNOT (control q0, target q1)(|00⟩+|11⟩)/√2entangled Bell stateCourseTron · coursetron.com
    Read left to right: the state travels through H on q0, then the CNOT couples q0 (control, filled dot) to q1 (target, ⊕), producing an entangled Bell state.
    CNOT truth table (control, target)InputOutput|00⟩|00⟩unchanged|01⟩|01⟩unchanged|10⟩|11⟩target flipped by X|11⟩|10⟩target flipped by XOrange rows: control = 1, so the target flips.CourseTron · coursetron.com
    CNOT truth table: |00⟩ and |01⟩ are unchanged, while |10⟩ and |11⟩ swap.

    Unitary operations and reversibility

    Every gate being unitary has deep consequences. First, no information is lost mid-circuit: unlike a classical AND gate, a quantum gate can always be run backwards. Second, gates are norm-preserving, so amplitudes never blow up or vanish — the probabilities always sum to 1. Third, unitarity is exactly what lets interference work: amplitudes can add constructively or cancel destructively, which is how algorithms like Grover’s amplify the right answer.

    Measurement is the one step that is not a gate — it is an irreversible collapse that extracts a classical bit and destroys the superposition. Everything before measurement is a product of unitary gates.

    Universal gate sets and circuits

    You do not need infinitely many distinct gates. A universal gate set is a finite collection whose products can approximate any unitary to arbitrary precision. Common universal sets include:

    • {H, T, CNOT} — Hadamard, the T (π/8 phase) gate, and CNOT. The standard set for fault-tolerant machines.
    • {H, S, CNOT, Toffoli} — another common fault-tolerant choice.
    • Any two-qubit entangling gate plus a sufficient set of single-qubit rotations.

    The Solovay–Kitaev theorem guarantees that such sets reach any target gate efficiently — the number of gates grows only poly-logarithmically in the precision you demand. A quantum circuit is then just a time-ordered sequence of these gates drawn left to right, with one horizontal wire per qubit, ending in measurements. Compiling a high-level algorithm means decomposing its ideal unitary into gates the hardware actually supports.

    Learn this hands-on

    Real projects and industry tool flows, with certification.

    Explore CourseTron Courses →

    quantum gates — FAQ

    Why must quantum gates be reversible?

    Because they are unitary matrices, and every unitary has an inverse (U†). Reversibility is not a design choice — it falls out of the fact that quantum evolution conserves probability. Only measurement is irreversible.

    What is the difference between the X gate and a classical NOT?

    On basis states they behave identically: both flip 0 and 1. But X also acts linearly on superpositions and rotates the full Bloch sphere, so it can transform states a classical NOT has no way to represent.

    How does CNOT create entanglement?

    CNOT alone on classical inputs just copies a controlled flip. The entanglement appears when the control qubit is first put into superposition with H — the CNOT then correlates the two qubits into a state that cannot be written as two independent qubits.

    How many gates do I need to build any computation?

    A finite universal set — for example {H, T, CNOT} — suffices. The Solovay–Kitaev theorem shows any unitary can be approximated to precision ε using only about O(logc(1/ε)) gates from the set.

    Related: qubit basics · Glossary · all courses.

    Advertisement