Home▸Quantum Computing▸Quantum Swap Test: State Overlap Estimator

Quantum Swap Test: State Overlap Estimator (2D)

Interactive 2D statevector simulator of the quantum swap test — a genuine 3-qubit circuit (ancilla + register A + register B) simulated amplitude by amplitude through Hadamard, controlled-SWAP and Hadamard, then sampled shot by shot to show the measured overlap estimate converge onto the true fidelity |⟨ψ|φ⟩|².

Quantum Computing2DAdvanced60 FPS📱 Mobile-adapted🔥 Fire⇄ 3D version
2d-quantum-machine-learning-computer-science ↗ Open standalone

Quantum machine learning algorithms need a way to measure "how similar" two data points are once they've been encoded as quantum states — that's exactly what the swap test provides. This 2D simulator builds the real joint statevector of three qubits — two data registers, A and B, each set from its own Bloch-circle angles, plus an ancilla qubit — and pushes it through an explicit Hadamard–controlled-SWAP–Hadamard circuit, amplitude by amplitude. Firing a batch of shots then samples real Born-rule outcomes from that simulated ancilla marginal, and the running measured statistics visibly converge toward the exact overlap as more shots accumulate — the same statistical process that underlies quantum k-means, quantum kNN and quantum kernel classifiers.

⚙ Under the hood

Adjust angles of states |ψ⟩ and |φ⟩ in 2D to estimate their overlap using a swap-test circuit with 100-1000 shots.

Quantum Machine LearningSwap TestQubit FidelityBloch SphereQuantum KernelThree.js

2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)