circuits / hadamard-test

Hadamard Test

FEATURED

Estimates ⟨ψ|U|ψ⟩ using an ancilla qubit, controlled-U, and measurement. Fundamental for many quantum algorithms.

quantumcomputer.dev
openqasm2q3 gatesdepth319 views0 saves0 forks0 downloads
1OPENQASM 2.0;
2include "qelib1.inc";
3qreg q[2];
4creg c[1];
5h q[0];
6// Controlled-U (example: controlled-Z)
7cz q[0],q[1];
8h q[0];
9measure q[0] -> c[0];

Cite this circuit

MIT
quantumcomputer.dev. "Hadamard Test". quantumcomputer.dev/circuits/hadamard-test. 2026.