Computing Library › Quantum Logic Gates
Quantum Logic Gates

Fredkin Gate (CSWAP)

The Fredkin gate is a controlled-SWAP — it exchanges two targets only when the control is |1⟩, a reversible, conservative logic primitive.

Circuit symbol

Action on basis states

Kronos motion — control room
inputoutput
|100⟩... controls swap of targetsconditional SWAP

How it works

CSWAP is universal for reversible classical computation and is the heart of the SWAP test — a routine that estimates the overlap ⟨ψ|φ⟩ between two quantum states, used across quantum machine learning.

In code (Qiskit)

python
qc = QuantumCircuit(3)
qc.cswap(0, 1, 2)  # Fredkin
three-qubitreversibleswap-test