Quantum ComputingGatesUniversity
AQAAPOntarioNSWCBSEGCE O-LevelMoECAPS

SWAP Gate (CNOT Equivalent) Calculator

Number of CNOT gates required to implement a SWAP.

Use the free calculatorCheck the variablesOpen the advanced solver
This is the free calculator preview. Advanced walkthroughs stay in the app.
Result
Ready
CNOT Count

Formula first

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.

Symbols

Variables

C = CNOT Count, n = Num SWAPs

CNOT Count
Num SWAPs

Apply it well

When To Use

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.

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?

Num SWAPs4

Solve for:

Hint: Each SWAP operation is equivalent to exactly three CNOT gates.

The full worked solution stays in the interactive walkthrough.

References

Sources

  1. Nielsen, Michael A., and Isaac L. Chuang. Quantum Computation and Quantum Information.
  2. Wikipedia: SWAP gate
  3. Wikipedia: CNOT gate
  4. Nielsen, M. A., & Chuang, I. L. (2010). Quantum Computation and Quantum Information (2nd ed.). Cambridge University Press.
  5. Nielsen and Chuang Quantum Computation and Quantum Information
  6. Kaye, Laflamme, and Mosca An Introduction to Quantum Computing
  7. Mermin Quantum Computer Science: An Introduction
  8. University Quantum Computing — Gate Decomposition