SWAP Gate (CNOT Equivalent)
Number of CNOT gates required to implement a SWAP.
This public page keeps the free explanation visible and leaves premium worked solving, advanced walkthroughs, and saved study tools inside the app.
Core idea
Overview
The SWAP gate is a two-qubit operation that exchanges the quantum states of two qubits. In most quantum hardware architectures, a SWAP operation is not a native primitive and must be decomposed into a sequence of three alternating CNOT gates.
When to use: This decomposition is used during the transpilation process when a high-level circuit requires a SWAP but the backend only supports CNOT gates. It is essential for routing qubits on hardware with limited connectivity where two qubits must be moved closer to interact.
Why it matters: Gate count is a critical metric in NISQ-era quantum computing because two-qubit gates like CNOT have higher error rates than single-qubit gates. Understanding this 3-to-1 ratio helps researchers estimate the fidelity loss and depth increase associated with qubit movement.
Symbols
Variables
C = CNOT Count, n = Num SWAPs
Walkthrough
Derivation
Formula: SWAP Gate — CNOT Decomposition
A SWAP gate can be implemented using exactly 3 CNOT gates.
- CNOT gates are available as a primitive.
- The SWAP exchanges the states of two qubits: |ab⟩ → |ba⟩.
CNOT Sequence:
Three CNOTs in the order (control=1,target=2), (control=2,target=1), (control=1,target=2) implement a full SWAP.
Verify with Basis States:
Tracing |01⟩ through the three CNOTs confirms the swap to |10⟩. The minimum CNOT count for SWAP is 3.
Result
Source: University Quantum Computing — Gate Decomposition
Free formulas
Rearrangements
Solve for
Make CNOT Count the subject
Start from the equivalence of SWAP and CNOT gates. To make CNOT Count (C) the subject, substitute the gate types with their corresponding counts.
Difficulty: 2/5
The static page shows the finished rearrangements. The app keeps the full worked algebra walkthrough.
Visual intuition
Graph
Graph unavailable for this formula.
The graph is a horizontal line representing a constant value of 3 on the Y-axis, regardless of the independent variable on the X-axis. This shape occurs because the number of CNOT gates required to implement a SWAP is a fixed mathematical identity.
Graph type: constant
Why it behaves this way
Intuition
Picture two qubits needing to exchange their quantum information, which is achieved by a specific sequence of three alternating conditional 'flips' between them.
Free study cues
Insight
Canonical usage
This equation describes a numerical relationship between the number of quantum gate operations, specifically the decomposition of a SWAP gate into CNOT gates. It does not involve physical units.
Common confusion
Students might mistakenly try to assign physical units to gate operations, but they represent discrete computational steps or transformations rather than physical quantities with dimensions.
Dimension note
The equation represents a numerical equivalence in terms of gate operations. Both SWAP and CNOT refer to specific quantum gate types, and the '3' is a coefficient indicating the number of CNOT gates needed for one SWAP
Ballpark figures
- Quantity:
One free problem
Practice Problem
A quantum compiler needs to perform 4 SWAP operations to route data across a chip. How many total CNOT gates will be required to implement these swaps?
Solve for:
Hint: Each SWAP operation is equivalent to exactly three CNOT gates.
The full worked solution stays in the interactive walkthrough.
Study smarter
Tips
- The three CNOTs must alternate their control and target orientations (e.g., CNOT(1,2), CNOT(2,1), CNOT(1,2)).
- Compilers can sometimes optimize these away if two SWAPs occur sequentially on the same qubits.
- In some architectures like trapped ions, a SWAP might be a native operation, making this decomposition unnecessary.
Common questions
Frequently Asked Questions
A SWAP gate can be implemented using exactly 3 CNOT gates.
This decomposition is used during the transpilation process when a high-level circuit requires a SWAP but the backend only supports CNOT gates. It is essential for routing qubits on hardware with limited connectivity where two qubits must be moved closer to interact.
Gate count is a critical metric in NISQ-era quantum computing because two-qubit gates like CNOT have higher error rates than single-qubit gates. Understanding this 3-to-1 ratio helps researchers estimate the fidelity loss and depth increase associated with qubit movement.
The three CNOTs must alternate their control and target orientations (e.g., CNOT(1,2), CNOT(2,1), CNOT(1,2)). Compilers can sometimes optimize these away if two SWAPs occur sequentially on the same qubits. In some architectures like trapped ions, a SWAP might be a native operation, making this decomposition unnecessary.
References
Sources
- Nielsen, Michael A., and Isaac L. Chuang. Quantum Computation and Quantum Information.
- Wikipedia: SWAP gate
- Wikipedia: CNOT gate
- Nielsen, M. A., & Chuang, I. L. (2010). Quantum Computation and Quantum Information (2nd ed.). Cambridge University Press.
- Nielsen and Chuang Quantum Computation and Quantum Information
- Kaye, Laflamme, and Mosca An Introduction to Quantum Computing
- Mermin Quantum Computer Science: An Introduction
- University Quantum Computing — Gate Decomposition