circuits / swap-test

SWAP Test

FEATURED

Determines the overlap between two quantum states without measuring them. Ancilla qubit reads |0⟩ if states are identical.

quantumcomputer.dev
openqasm3q3 gatesdepth323 views0 saves0 forks0 downloads
1OPENQASM 2.0;
2include "qelib1.inc";
3qreg q[3];
4creg c[1];
5h q[0];
6cswap q[0],q[1],q[2];
7h q[0];
8measure q[0] -> c[0];

Cite this circuit

MIT
quantumcomputer.dev. "SWAP Test". quantumcomputer.dev/circuits/swap-test. 2026.