skip to content
Ivan's wiki
Site Tools
Search
Tools
Show pagesource
Backlinks
Recent Changes
Media Manager
Sitemap
>
Recent Changes
Media Manager
Sitemap
swap-gate
This page is read only. You can view the source, but not change it.
# SWAP gate **SWAP gate** is a two-qubit gate that exchanges the states of its two qubits. It is symmetric — neither qubit plays the role of control or target — and it is its own inverse: $\text{SWAP}^2 = I$. $$\text{SWAP} = \begin{pmatrix}1&0&0&0\\ 0&0&1&0\\ 0&1&0&0\\ 0&0&0&1\end{pmatrix}$$ $$\text{SWAP}\lvert 00\rangle = \lvert 00\rangle \qquad \text{SWAP}\lvert 01\rangle = \lvert 10\rangle \qquad \text{SWAP}\lvert 10\rangle = \lvert 01\rangle \qquad \text{SWAP}\lvert 11\rangle = \lvert 11\rangle$$ ## Decomposition into CX gates SWAP can be decomposed into three [CX gates](/cx-gate) in alternating directions: $$\text{SWAP} = \text{CX}_{1\to 2}\cdot\text{CX}_{2\to 1}\cdot\text{CX}_{1\to 2}$$ This is important in hardware where qubit connectivity is limited. When two qubits that need to interact are not physically adjacent, SWAP gates are inserted to route them together — at a cost of three CXs each. Minimizing SWAP overhead is a key concern in quantum circuit compilation. ## Square root of SWAP The $\sqrt{\text{SWAP}}$ gate satisfies $(\sqrt{\text{SWAP}})^2 = \text{SWAP}$. Unlike SWAP itself, $\sqrt{\text{SWAP}}$ can create entanglement, and together with arbitrary single-qubit gates it forms a universal gate set. It is native to several spin-qubit hardware architectures. ## List of code implementations - [SWAP gate (Qiskit)](/swap-gate-qiskit) - [SWAP gate (cuStateVec)](/swap-gate-custatevec) - [SWAP gate (CUDA-Q)](/swap-gate-cudaq)
Page Tools
Show pagesource
Backlinks
Back to top