= Hadamard test
{c}
{wiki}
The Hadamard test converts an overlap $\langle\psi|U|\psi\rangle$ into an ancilla measurement probability. Prepare an ancilla in $|+\rangle$, apply controlled $U$ to the data state $|\psi\rangle$, apply a Hadamard to the ancilla, and measure it. Then
$$
p(0)=\frac{1+\operatorname{Re}\langle\psi|U|\psi\rangle}{2}.
$$
Interference between the ancilla's two branches reveals the real part of the overlap. One run supplies one binary sample; repeated preparations estimate the probability and hence the expectation value. A single outcome does not reveal a general real number exactly. A Hermitian Pauli operator is a useful choice of $U$, while the <imaginary-part Hadamard test> changes the reference phase to obtain the other component.
Back to article page