Quantum Computing

A Comprehensive Guide to Quantum Gates

In classical computing, we build every operation from simple binary logic gates like AND, OR, and NOT. In quantum computing, the role of logic gates is played by quantum gates – unitary transformations on one or more qubits. These are the elementary “moves” that a quantum computer can perform on quantum data. Just as classical gates compose to implement arbitrary Boolean functions, quantum gates compose to implement arbitrary unitary operations. However, quantum gates have striking differences from classical ones: they are reversible (all quantum gates correspond to invertible unitary matrices), they can create superposition and entanglement, and there are infinitely many possible single-qubit gates (since a qubit’s state is a continuous point on the Bloch sphere).

Let’s tour the most common quantum gates: we’ll start with single-qubit gates – including the Pauli gates, Hadamard, phase gates (S and T), and rotation gates – and then move to two-qubit gates like CNOT, controlled-phase, SWAP, and $i$SWAP, and finally three-qubit gates like the Toffoli and Fredkin.

Single-Qubit Gates: Manipulating One Qubit at a Time

A single qubit’s state can be visualized as a point on the Bloch sphere, and single-qubit gates correspond to rotations of this Bloch vector. These gates change the amplitudes and relative phase of the basis states $$|0\rangle$$ and $$|1\rangle$$. In matrix form, a single-qubit gate is a 2×2 unitary matrix. Here are the most important ones:

  • Pauli X, Y, Z gates: These are the quantum analogues of the classical NOT and related operations, and correspond to 180° rotations about the x, y, and z axes of the Bloch sphere. Their matrices (in the $${|0\rangle,|1\rangle}$$ basis) are: $$X = \begin{pmatrix}0 & 1\\ 1 & 0\end{pmatrix}$$, $$\quad Y = \begin{pmatrix}0 & -i\\ i & 0\end{pmatrix}$$, $$\quad Z = \begin{pmatrix}1 & 0\\ 0 & -1\end{pmatrix}$$. The X gate flips $$|0\rangle \leftrightarrow |1\rangle$$, acting just like a classical NOT on the computational basis. If a qubit is in state $$|0\rangle$$, $$X$$ will take it to $$|1\rangle$$, and vice versa. Geometrically, it’s a half-turn around the Bloch sphere’s X-axis, taking the “north pole” to the “south pole.” The Z gate flips the phase of the $$|1\rangle$$ state: $$Z|0\rangle = |0\rangle$$, $$Z|1\rangle = -|1\rangle$$. It’s a 180° rotation about the Z-axis, leaving the poles $$|0\rangle$$ and $$|1\rangle$$ in place but rotating the |1⟩ state vector to point in the opposite direction (assigning it a -1 phase). This earns Z the nickname “phase-flip” gate – if a qubit is in a superposition $$(\alpha|0\rangle + \beta|1\rangle)$$, Z transforms it to $$(\alpha|0\rangle – \beta|1\rangle)$$. The Y gate flips the state like X but also introduces a phase: $$Y|0\rangle = i|1\rangle$$, $$Y|1\rangle = -i|0\rangle$$. This is a 180° rotation about the Y-axis. Essentially, $$Y = i X Z$$ (up to a global phase $$i$$), combining a bit flip and a phase flip. All Pauli gates are their own inverses (each squared is the identity) , and they anti-commute with each other ($$XZ = -ZX$$, etc.) . These properties are central in quantum error correction and stabilizer theory. Use cases: X is used to flip qubit states (for example, to set a qubit to $$|1\rangle$$, you can apply X to $$|0\rangle$$). Z is used to apply a phase kick – it leaves $$|0\rangle$$ unchanged but can change the sign of the $$|1\rangle$$ component, which is useful in algorithms and forming controlled-Z gates. Y is less frequently used directly, but is important in certain operations or can be composed from X and Z. Bloch sphere visualization: X rotates the Bloch vector 180° around the x-axis (if the qubit was at the north pole |0⟩, X sends it to the south pole |1⟩). Z rotates 180° around the z-axis (so it sends the state on the equator at +X direction, |+⟩, to the state at −X direction, |−⟩, effectively swapping those, and similarly |+𝑖⟩ to |−𝑖⟩ on the Y-axis). Y rotates around the y-axis (sending |0⟩ to i|1⟩ etc., which on the sphere means pointing opposite in the complex plane).
  • Hadamard (H) gate: The Hadamard gate creates superposition and is one of the most widely used single-qubit gates. Its matrix is $$H = \frac{1}{\sqrt{2}}\begin{pmatrix}1 & 1\\ 1 & -1\end{pmatrix}$$. It maps $$|0\rangle$$ to $$|+\rangle := (|0\rangle+|1\rangle)/\sqrt{2}$$ and $$|1\rangle$$ to $$|-\rangle := (|0\rangle – |1\rangle)/\sqrt{2}$$. In effect, H takes a definitively-valued qubit and “splits” it into an equal superposition of 0 and 1 (up to a relative phase). Conversely, it also takes those plus/minus superposition states back to the computational basis ($$H|\pm\rangle = |0/1\rangle$$). Geometrically, H is a 180° rotation about the axis halfway between X and Z on the Bloch sphere . It thus swaps the roles of the X-basis and Z-basis. One can verify that $$HZH = X$$ and $$HXH = Z$$ – H conjugates a Z into an X and vice versa, which means applying an H before measuring in Z-basis is effectively a measurement in X-basis. Hadamard is its own inverse (aside from a global phase, $$H^2 = I$$). Use cases: H is used at the start of many algorithms to create uniform superpositions (e.g., in Grover’s algorithm, applying H to each of $$n$$ qubits yields a superposition of all $$2^n$$ basis states). It’s also used in interference steps – for example, in the simple Deutsch algorithm, H gates are used before and after a function call to create interference that reveals a global property of the function. In creating entanglement, a common pattern is H on one qubit followed by CNOT (this produces a Bell state, as we’ll see). H is also crucial in quantum error-correcting codes, as part of generating and measuring certain stabilizer states. Bloch sphere: H sends the north pole |0⟩ to the equator (pointing along +X direction) and |1⟩ to the equator (pointing along −X direction). It essentially reflects states through the X–Z diagonal plane. A neat view: if a qubit is on the equator (like |+⟩ or |−⟩), H will send it to one of the poles (|0⟩ or |1⟩). This shows how H toggles between superposition basis and computational basis.
  • Phase gates (S and T): These are single-qubit gates that impart a specific phase shift to the $$|1\rangle$$ state. The S gate (also called the phase gate or $$P(\pi/2)$$) has matrix $$S = \begin{pmatrix}1 & 0\ 0 & i\end{pmatrix}$$. It leaves $|0\rangle$ unchanged and multiplies $$|1\rangle$$ by $$i$$ (a 90° phase rotation). Equivalently, it’s $$\pi/2$$ rotation around the Z-axis on the Bloch sphere. The T gate (also called the $$\pi/8$$ gate) has matrix $$T = \begin{pmatrix}1 & 0\ 0 & e^{i\pi/4}\end{pmatrix}$$ . It’s a 45° phase shift on $$|1\rangle$$. Note that $$S^2 = Z$$ and $$T^2 = S$$ (and hence $$T^4 = Z$$) . These relationships give S and T their alternate names: S is sometimes written as $$\sqrt{Z}$$ (since $$S^2 = Z$$) , and T as $$\sqrt{S}$$ (or $$\sqrt[4]{Z}$$). Neither S nor T is Hermitian (unlike X, Y, Z, H which are their own inverses up to phase) – they are one-way phase rotations. The adjoint (inverse) gates are $$S^\dagger = \begin{pmatrix}1&0\0&-i\end{pmatrix}$$ and $$T^\dagger = \begin{pmatrix}1&0\0&e^{-i\pi/4}\end{pmatrix}$$. Use cases: S and T gates are critical in building arbitrary single-qubit rotations out of discrete gates. S is a Clifford gate (meaning if you only had Clifford gates like H, S, CNOT, the circuit is efficiently classically simulatable, but also useful for error correction). T is not a Clifford gate – and that’s exactly why it’s important. By adding the T gate to the set of Clifford gates, we get a universal set. In fact, ${H, T, CNOT}$ is a common universal gate set. The T gate’s 45° phase is what allows us to approximate any angle; circuits often count the number of T gates as a measure of complexity for error-corrected computation (since T is typically the most expensive gate in fault-tolerant implementations). In algorithms, phase gates show up in phase kickback techniques. For example, the controlled-phase rotations in the Quantum Fourier Transform are essentially these $$P(\varphi)$$ gates. In quantum error correction, the T gate is the hardest to implement fault-tolerantly, usually requiring a process called magic state distillation . This reflects the fact that T is outside the Clifford group and thus not protected by many simple codes – it’s the “magic” ingredient enabling quantum advantage . S gate, on the other hand, is often easy to implement (e.g., it might just be a frame change in superconducting qubits). Bloch sphere: S and T rotate the state vector about the Z-axis. If a qubit is in state $$|+\rangle = (|0\rangle+|1\rangle)/\sqrt{2}$$ (on the equator at 0° phase), applying S will shift it to $$|+i\rangle = (|0\rangle + i|1\rangle)/\sqrt{2}$$ (on the equator at +90°). T would rotate it by 45°, to an intermediate point. If the qubit were at the poles (|0⟩ or |1⟩), these phase gates won’t change the visible state (they just add global phase or 180° phase to |1⟩ in case of Z which is a double S). So phase gates are “invisible” on computational basis states but crucial when states are superposed.
  • Rotation gates (Rx, Ry, Rz): These denote continuous rotations about the Bloch sphere axes by a given angle. For example, $$R_x(\theta) = \exp(-i\theta X/2)$$ yields a rotation by angle θ around the X-axis: $$R_x(\theta) = \begin{pmatrix}\cos(\theta/2) & -i\sin(\theta/2)\\ -i\sin(\theta/2) & \cos(\theta/2)\end{pmatrix}$$. Similarly, $$R_z(\theta) = \begin{pmatrix}e^{-i\theta/2} & 0\ 0 & e^{i\theta/2}\end{pmatrix}$$ (which is a phase shift by θ on |1⟩ relative to |0⟩). Indeed $$R_z(\pi/2) = S$$ and $$R_z(\pi/4) = T$$ up to a global phase. $$R_y(\theta)$$ would be a rotation about Y. Rotation gates allow arbitrary single-qubit transformations. In practice, many quantum SDKs use a parameterized rotation gate (like RZ(φ) or a general U(θ,φ,λ) in IBM’s Qiskit which is essentially $$R_z(φ) R_x(θ) R_z(λ)$$). Use cases: Any single-qubit gate can be decomposed into rotations (Euler angles). For example, a general recipe is that any single-qubit unitary $$U$$ can be written as $$U = e^{i\alpha} R_z(\beta) R_y(\gamma) R_z(\delta)$$ for some angles (and global phase $$e^{i\alpha}$$ which doesn’t matter computationally). So having the ability to do arbitrary rotations (even just about two axes, like X and Z) is enough for single-qubit universality. Physical hardware often natively implements something like $$R_x(\theta)$$ or $$R_y(\theta)$$ by an analog pulse. In many superconducting qubit systems, fast $$R_z(\phi)$$ can be done as a software frame adjustment (no physical pulse needed) – effectively “free” and exact. So one strategy is: use $$R_z$$ and $$R_x$$ as needed to compile everything. In algorithms, continuous rotations appear in variational circuits and QAOA, where gate angles are parameters to be optimized. For example, in a QAOA circuit, one might apply an $$R_x(\theta)$$ on each qubit as a mixing operation. These are not predetermined like $$\pi/4$$ but rather adjustable. Bloch sphere: $$R_n(\theta)$$ means rotate the state vector by θ around axis n. If the qubit is initially |0⟩ (north pole), an $$R_x(θ)$$ will move it toward |1⟩ in the XZ-plane. For small θ, it produces a small superposition. These rotation gates generalize the idea of X, Y, Z: indeed $$R_x(\pi) = X$$ (up to phase), $$R_y(\pi) = Y$$, $$R_z(\pi) = Z$$.

To summarize the single-qubit gates: X, Y, Z perform flips and define the axes of rotation. H creates and destroys superposition, acting as a “bridge” between X and Z bases. S and T impart well-defined phase shifts (with T being crucial for universality beyond the Clifford group). And rotation gates with arbitrary angles allow fine control. With these, one can build any single-qubit operation. Next, we turn to multi-qubit gates, which allow us to create correlations and entanglement between qubits.

Two-Qubit Gates: Entangling Operations

Multi-qubit gates act on two or more qubits at once. They are responsible for creating entanglement – something impossible with single-qubit gates alone. The most important two-qubit gate is the Controlled-NOT (CNOT), but there are others like Controlled-Z (CZ), SWAP, and $i$SWAP. Two-qubit gates are generally more challenging physically, but any quantum computer must implement at least one kind of two-qubit entangling gate, since without entanglement, a quantum computer offers no advantage over a classical one.

  • Controlled-NOT (CNOT) gate: This gate has two inputs: a control qubit and a target qubit. It performs an $$X$$ (NOT flip) on the target if and only if the control is $$|1\rangle$$; if the control is $$|0\rangle$$, it does nothing. In truth table form:$
    • $|00\rangle \to |00\rangle$$ (control 0, target stays 0)$$|01\rangle \to |01\rangle$$ (control 0, target stays 1)$$|10\rangle \to |11\rangle$$ (control 1, target flips from 0 to 1)$$|11\rangle \to |10\rangle$$ (control 1, target flips from 1 to 0)
    We can summarize this as: $$|a, b\rangle \mapsto |a,, a\oplus b\rangle$$, where $$\oplus$$ is XOR. The first bit (qubit) $$a$$ is unchanged; the second bit becomes $$b$$ XOR $$a$$. In matrix form (with basis order $$|00\rangle,|01\rangle,|10\rangle,|11\rangle$$), CNOT is: $$\text{CNOT} = \begin{pmatrix} 1&0&0&0\\ 0&1&0&0\\ 0&0&0&1\\ 0&0&1&0 \end{pmatrix}$$, which indeed maps $$|10\rangle$$ to $$|11\rangle$$ and $$|11\rangle$$ to $$|10\rangle$$. Entanglement: The CNOT is crucial because if the control qubit is in a superposition, CNOT generates entanglement. For example, start with control in $$|+\rangle = (|0\rangle+|1\rangle)/\sqrt{2}$$ and target in $$|0\rangle$$. The joint state is $$\frac{1}{\sqrt{2}}(|00\rangle + |10\rangle)$$. Now apply CNOT (control = first qubit). The $$|00\rangle$$ component stays $$|00\rangle$$ (since control is 0, no flip), and the $$|10\rangle$$ component becomes $$|11\rangle$$ (control 1 flips target). The resulting state is $$\frac{1}{\sqrt{2}}(|00\rangle + |11\rangle)$$, which is one of the Bell states – a maximally entangled pair. Neither qubit has a definite value on its own, but they are perfectly correlated. If you measured the first qubit, it’s 50/50 0 or 1, but whatever it is, the second qubit will be found the same. This state cannot be factored into a product of single-qubit states, demonstrating entanglement. CNOT (along with an H to prepare the superposition) is the standard way to produce such entangled pairs in experiments. Classical analogy: If we treat $$|0\rangle$$ as bit 0 and $$|1\rangle$$ as bit 1, CNOT is like a controlled XOR gate: it flips the target bit if the control bit is 1. In reversible computing, the CNOT (also called the Feynman gate) is the basic two-bit gate since it’s reversible and can copy a bit onto another (if target starts at 0, CNOT will copy control’s value to target). In fact, the mapping $$(a,b)\to(a, a\oplus b)$$ can be seen as copying $$a$$ onto a target initialized to 0 (if $$b=0$$). However, quantum mechanically, we cannot clone an arbitrary unknown qubit state; CNOT can only copy a classical bit or entangle a quantum state – it doesn’t violate the no-cloning theorem because if the control is in superposition, the result is entanglement rather than two independent copies of information. Use cases: CNOT is ubiquitous. Any multi-qubit quantum circuit typically uses CNOTs to entangle qubits. Many algorithms require entangling operations; for instance, in quantum adders, CNOTs are used for carry operations. In error correction, CNOTs copy syndrome information from data qubits to ancilla qubits. The Toffoli and other multi-control gates are built using multiple CNOTs. In fact, it’s known that {single-qubit gates + CNOT} is a universal gate set for quantum computing. That means any quantum operation can be composed from CNOT and one-qubit rotations. The Solovay-Kitaev theorem and other results ensure we can approximate any unitary to arbitrary accuracy with these. So, CNOT is as central to quantum circuits as NAND or XOR is to classical circuits. Circuit symbol: A CNOT is drawn as a line connecting a ● (on the control qubit’s line) and an ⊕ (on the target’s line). The ⊕ indicates the target is flipped. Sometimes it’s labeled “CNOT” or “CX”. It’s worth noting that CNOT is its own inverse (apply it twice, it undoes itself). It’s also a Clifford gate.
  • Controlled-Z (CZ) gate: This is another common two-qubit gate, similar to CNOT but instead of flipping the target bit, it flips the target qubit’s phase (applies a Z) if the control is 1. In truth table terms, $$|11\rangle$$ gets a phase -1 (since Z on the target gives a – to $$|1\rangle$$), while $$|00\rangle,|01\rangle,|10\rangle$$ are unchanged. Matrix of CZ (in same basis order) is diag(1,1,1,-1). It is equivalent to CNOT up to conjugating by Hadamards on the target: $$CZ_{(c,t)} = H_t, CNOT_{(c,t)}, H_t$$. Conversely, $$CNOT = H_t, CZ_{(c,t)}, H_t$$. Many quantum hardware platforms (like some superconducting qubits) implement CZ natively because of how the interaction works, and convert to CNOT in software. Entanglement: CZ also creates entanglement from superpositions. For example, if control is $$|+\rangle$$ and target $$|+\rangle$$, after CZ the state becomes $$\frac{1}{\sqrt{2}}(|00\rangle + |11\rangle)$$ (because $$|10\rangle$$ and $$|01\rangle$$ get a phase flip which in this case causes destructive cancellation for those terms, leaving only $$|00\rangle+|11\rangle$$). So CZ can produce the same Bell states as CNOT (just in different input conditions). Use cases: CZ is often used in algorithms that are symmetric in 0/1 (since a CNOT has an asymmetry in control vs target roles, but CZ is symmetric aside from which qubit is control). For example, some error correction circuits prefer CZ for certain syndrome measurements. In quantum simulations, CZ gates appear in phase interaction terms. And in the quantum supremacy circuits by Google, a gate called “iSWAP-like” plus a partial CZ was used , essentially combining an entangling swap and a phase. If one has a CZ available, one can always sandwich it with H on target to get a CNOT as needed, so it’s often interchangeable in discussions of universal gate sets. Both CNOT and CZ are Clifford gates when considered with single-qubit Cliffords (H and S).
  • SWAP gate: SWAP simply exchanges the states of two qubits. It’s a three-controlled-NOT construction: $$\text{SWAP}(q_1,q_2) = CNOT(q_1,q_2); CNOT(q_2,q_1); CNOT(q_1,q_2)$$. In basis form: $$|a,b\rangle \to |b,a\rangle$$. The matrix is: $$\text{SWAP} = \begin{pmatrix} 1&0&0&0\\ 0&0&1&0\\ 0&1&0&0\\ 0&0&0&1 \end{pmatrix}$$, which indeed sends $$|01\rangle$$ to $$|10\rangle$$ (the 2nd and 3rd basis vector swap). Use cases: The SWAP gate doesn’t create entanglement by itself (it just permutes qubits). But it’s vital in quantum computing when you need to move qubit states around. Real hardware often has a limited connectivity graph – SWAP gates are used to route qubits, effectively exchanging quantum data between two wire lines. For example, if qubit A needs to interact with qubit C but they’re not adjacent, the compiler might insert SWAPs to move the state of A over to an adjacent position. Each SWAP is three CNOTs, so it’s costly, but necessary for flexibility. In algorithms, SWAP can sometimes appear logically (e.g., swapping two registers), but usually it’s a tool for circuit mapping. Conceptually, SWAP is symmetric and its own inverse (swap twice = original). There is also a √SWAP gate (the square-root of SWAP) which is an entangling gate – applying √SWAP twice yields a full SWAP. √SWAP is universal with single qubit gates (because √SWAP is entangling) . In some quantum dot systems, √SWAP is a naturally occurring gate. But standard circuit decomposition usually sticks with CNOT or CZ as the entangler and uses multiple of them for a SWAP if needed.
  • iSWAP gate: This gate swaps the two qubits and adds a phase of $$i$$ to the $$|01\rangle$$ and $$|10\rangle$$ terms that swap. Its matrix (in basis $$|00\rangle,|01\rangle,|10\rangle,|11\rangle$$) is: $$i\text{SWAP} = \begin{pmatrix} 1&0&0&0\\ 0&0&i&0\\ 0&i&0&0\\ 0&0&0&1 \end{pmatrix}$$, meaning $$|01\rangle \to i|10\rangle$$, $$|10\rangle \to i|01\rangle$$, and $$|00\rangle,|11\rangle$$ remain. Essentially, it’s like a SWAP but when 0 and 1 pass through each other, a phase $$i$$ is gained. The iSWAP is entangling (a single iSWAP can create entanglement from certain input states). In fact, a √iSWAP (square-root of iSWAP) is used as the two-qubit entangling gate in Google’s Sycamore processor (Sycamore gate is roughly √iSWAP plus a Z-phase). A full iSWAP gate is basically two √iSWAPs. Use cases: Some physical interactions naturally implement iSWAP. For example, in superconducting qubits with capacitive coupling, an iSWAP operation (exchange of excitations) can occur. In ion traps, the Molmer-Sorensen gate is more akin to an XX interaction (which can be turned into something like iSWAP or √iSWAP with appropriate basis choice). The reason iSWAP has that $$i$$ phase is related to the physics of a SWAP operation arising from a Hamiltonian like $$H \propto (X \otimes X + Y \otimes Y)$$, which yields an iSWAP unitary. For quantum algorithm design, one typically doesn’t use iSWAP at the logical level – you’d convert iSWAP to CNOTs or vice versa – but knowing about it is important for understanding hardware gate sets. iSWAP is also a Clifford if combined appropriately with single-qubit rotations (actually, iSWAP itself is not Clifford because it includes an i-phase which is non-Clifford; however, $$(iSWAP)^2 = -SWAP$$ which is Clifford since SWAP is just permutation, global phase -1 aside). A related gate is the Controlled phase (CPHASE): applying a phase to |11⟩. Actually CZ is a CPHASE(π). A generic controlled phase CPHASE(θ) would do $$|11\rangle \to e^{iθ}|11\rangle$$. That’s like a partial CZ. These appear in QFT circuits with various θ. They can be built with a CNOT sandwiching a single-qubit Rz(θ).

In summary of two-qubit gates: CNOT (CX) is the workhorse for entanglement and universal computing . It has a clear classical interpretation and is used in everything from algorithmic oracles to error correction circuits. CZ is effectively the same in computational power, just a different form (phase flip instead of bit flip) . SWAP is crucial for moving qubit states around and is composed of CNOTs. iSWAP (and √iSWAP) are hardware-friendly gates used in some architectures . All two-qubit entangling gates can be converted into each other with appropriate single-qubit rotations. Having at least one entangling two-qubit gate along with the set of single-qubit gates ensures the gate set is universal (able to approximate any unitary).

Three-Qubit Gates: Toffoli and Fredkin

Three-qubit gates are less commonly used but important conceptually. The primary examples are the Toffoli gate (CCX) which is a controlled-controlled-NOT, and the Fredkin gate (CSWAP) which is a controlled-SWAP.

  • Toffoli (CCNOT) gate: The Toffoli has two control qubits and one target qubit. It flips the target bit if and only if both control qubits are 1 . In other words, it implements the Boolean function $$target \leftarrow target \oplus (control_1 \wedge control_2)$$. Truth table snippet: it leaves states unchanged unless the first two qubits are $$|11\rangle$$, in which case $$|110\rangle \leftrightarrow |111\rangle$$ (flips the third qubit). The matrix is 8×8, but basically it’s identity on all basis states except that $$|110\rangle$$ goes to $$|111\rangle$$ and $$|111\rangle$$ goes to $$|110\rangle$$. The Toffoli gate is important because, if you restrict to just classical input states, it can function as a universal reversible logic gate (it’s a reversible version of AND with an extra output line). In fact, any classical circuit can be embedded in a quantum circuit using Toffoli gates and ancilla bits. Toffoli was introduced in the 1980s in the context of reversible computing. Use cases: In quantum algorithms, Toffoli gates often appear when implementing classical arithmetic or Boolean functions within a quantum circuit. For instance, in Shor’s algorithm’s modular exponentiation circuit, Toffolis are used to perform controlled addition (they help compute carries in adders). Toffoli is also used in some error correction routines and in some oracles for Grover’s algorithm (where multiple control conditions need to be satisfied to flip a target “flag” qubit). Because Toffoli involves 3 qubits, it is typically decomposed into multiple one- and two-qubit gates in hardware. A standard decomposition uses 6 CNOT gates plus some single-qubit rotations (the optimal known uses 8 T gates as well, since Toffoli is non-Clifford when considered with no ancillas). One possible breakdown: $$\text{Toffoli}(c_1,c_2;t)$$ can be done with an ancilla via a couple of CNOTs and T gates, or without ancilla using a specific sequence of CNOT, T, $$T^\dagger$$, and H gates. For practical circuits, minimizing Toffoli count or cost is a big part of quantum circuit optimization if implementing classical logic. Importantly, a Toffoli combined with single-qubit H gates is enough to get universality: it’s known that $${ \text{Toffoli}, H}$$ is a universal gate set. Intuitively, Toffoli can implement any classical reversible function, and H can create superpositions and interference. However, this is more of theoretical interest; actual fault-tolerant gate sets prefer Clifford+T over Toffoli because Toffoli is a heavier gate to do fault-tolerantly (it can be done via multiple T gates anyway).
  • Fredkin (CSWAP) gate: The Fredkin gate has one control and two target qubits. If the control qubit is 1, it swaps the other two qubits; if the control is 0, it does nothing. So it’s a controlled-SWAP. Like Toffoli, it’s a universal reversible gate for classical computing (since Fredkin can also be used to construct circuits; Fredkin and Toffoli are in fact equivalent in computational power – each can be built from the other with ancillas). However, Fredkin is not as “universal” in quantum sense because it’s in the class of “conservative” logic (it preserves the number of 1s). Fredkin’s truth: if control = 0, (q1,q2) stay as is; if control = 1, (q1,q2) are swapped. Matrix is 8×8, mostly identity except the sub-block where control=1 has a swap on the other two. Use cases: Fredkin is less common in quantum algorithms. One place it conceptually appears is in certain quantum algorithms for sorting or for simulating reversible logic directly. Historically, Fredkin was proposed for reversible computing implementations (the Fredkin gate is named after Ed Fredkin). In the quantum realm, any Fredkin can be decomposed into CNOT and Toffoli gates (or CNOT and single-qubit gates) – for example, a Fredkin can be done with two Toffolis: use the control and one target to control a NOT on the other target, etc. Experimental demonstrations of Fredkin gates have been done in photonics and ion traps as a proof of concept. But it’s not used as often in mainstream quantum algorithm circuits compared to CNOT or Toffoli. One thing to note: Fredkin (CSWAP) does not by itself generate entanglement if the two target qubits are both basis states (because swapping |ab⟩ vs |ba⟩ is just a permutation). But if the target qubits are in a superposition with each other, CSWAP can entangle the control with whether the two qubits are swapped or not. For example, $$\frac{1}{\sqrt{2}}(|0\rangle_c|01\rangle_{t1t2} + |1\rangle_c|01\rangle_{t1t2})$$ – actually that specific state wouldn’t change because swapping |01⟩ yields |10⟩ which for indistinguishable superposition might produce entanglement. In any case, Fredkin is not in the Clifford group (it’s as hard as Toffoli in terms of T-count).

Universality of Gate Sets

Universal gate set means a set of gates from which one can approximate any unitary transformation on $$n$$ qubits to any desired accuracy. In classical logic, {NAND} is universal for boolean functions. In quantum, no single-qubit gate (finite set) can be exactly universal because there’s a continuum of unitaries – but a combination of discrete gates can be approximately universal. A common universal set is {H, T, CNOT} . Here H and T generate arbitrary single-qubit unitaries (H and T can approximate any rotation since T gives 45° increments of phase), and CNOT provides entanglement to expand to multi-qubit operations. Another perspective: Clifford gates alone (generated by H, S, CNOT) are not universal because they can be efficiently simulated classically . The addition of any one non-Clifford gate (like T or CCZ or Toffoli) makes the set universal. This is why T is called the magic gate for universality – it breaks out of the Clifford constraint. The Solovay-Kitaev theorem guarantees that even a small set of gates that generate a dense subgroup (like {H,T} for single qubit) will allow approximation of any target gate with polynomial overhead in log(1/ε).

Alternate universal sets: {X, Z, √X (or H), CNOT} works as well. {RX(π/2), RZ(π/2), CNOT} is another common choice (IBM’s basis is typically U1, U2, U3 which are combinations of rotations, plus CNOT). As mentioned, {Toffoli, H} is universal (though not used in practice for synthesis). Even a single three-qubit gate can be universal: the Deutsch gate (a certain 3-qubit continuous family) is known to be universal by itself. But in standard models, we stick to two-qubit entanglers and one-qubit rotations.

From a practical standpoint, gate universality means we can compile high-level algorithms to the specific primitive gates a hardware supports. For example, Google’s Sycamore uses √iSWAP and CZ; IBM uses CNOT and U3 (arbitrary single). Both are universal sets. Another example: {CZ, H, T} is universal as well (since CZ and CNOT are interchangeable by H on target).

Which gates are universal? – Strictly speaking, no finite set of exactly implemented gates can produce every possible unitary exactly, but sets like {H, T, CNOT} are approximate universal (arbitrary precision). If one allows continuous parameters, {Rz(θ), Rx(π/2), CNOT} is exactly universal because Rz(θ) is a continuous family.

Why universality matters: It means any quantum algorithm can be expressed with those gates. For example, Shor’s algorithm or Grover’s algorithm ultimately can be broken down to sequences of H, T, and CNOT (lots of them!). This is analogous to how any classical computation can be broken into AND, OR, NOT gates.

In conclusion, quantum gates are the language through which quantum algorithms are expressed. Single-qubit gates allow us to prepare superpositions and manipulate phases. Multi-qubit gates allow us to create entanglement and conditional operations. The interplay of these gates leads to rich phenomena like interference and entangled states that give quantum computers their edge. Understanding common gates like the Pauli rotations, Hadamard, CNOT, etc., is fundamental for designing and reading quantum circuits. And knowing that a certain small set of gates is universal reassures us that we don’t need an endless zoo of gates – just a well-chosen “basis” and we can build anything. As quantum hardware matures, the specific native gate sets might differ (one machine might naturally do CZ, another iSWAP), but since all these sets are universal, they can all execute the same quantum algorithms with suitable compilation. Quantum gates thus form the toolkit for all quantum computation, much like logic gates do for classical computation.

Marin Ivezic

I am the Founder of Applied Quantum (AppliedQuantum.com), a research-driven professional services firm dedicated to helping organizations unlock the transformative power of quantum technologies. Alongside leading its specialized service, Secure Quantum (SecureQuantum.com)—focused on quantum resilience and post-quantum cryptography—I also invest in cutting-edge quantum ventures through Quantum.Partners. Currently, I’m completing a PhD in Quantum Computing and authoring an upcoming book “Practical Quantum Resistance” (QuantumResistance.com) while regularly sharing news and insights on quantum computing and quantum security at PostQuantum.com. I’m primarily a cybersecurity and tech risk expert with more than three decades of experience, particularly in critical infrastructure cyber protection. That focus drew me into quantum computing in the early 2000s, and I’ve been captivated by its opportunities and risks ever since. So my experience in quantum tech stretches back decades, having previously founded Boston Photonics and PQ Defense where I engaged in quantum-related R&D well before the field’s mainstream emergence. Today, with quantum computing finally on the horizon, I’ve returned to a 100% focus on quantum technology and its associated risks—drawing on my quantum and AI background, decades of cybersecurity expertise, and experience overseeing major technology transformations—all to help organizations and nations safeguard themselves against quantum threats and capitalize on quantum-driven opportunities.
Share via
Copy link
Powered by Social Snap