- Algorithms
Hadamard Test
A quantum circuit that estimates the real or imaginary part of the expectation value of a unitary operator by using an ancilla qubit and controlled operations.
The Hadamard test is a fundamental quantum subroutine that estimates or for a unitary operator and a quantum state . It uses a single ancilla qubit, a Hadamard gate, and a controlled- operation. The Hadamard test is a building block for quantum phase estimation, overlap estimation, and many other quantum algorithms.
The circuit
The Hadamard test circuit for estimating :
|0⟩ ──[H]──●──[H]──[M]
│
|ψ⟩ ──────[U]──────────
Step by step:
- Initialize: Ancilla in , system in . Joint state: .
- Hadamard on ancilla:
- Controlled-:
- Hadamard on ancilla:
- Measure ancilla:
The real part is extracted as:
To estimate the imaginary part, insert an gate on the ancilla before the second Hadamard. This shifts the measurement to probe instead.
Applications
Quantum phase estimation: When is an eigenstate of with eigenvalue , the Hadamard test gives . Repeating with powers of () and classical post-processing recovers bit by bit. This is the iterative form of quantum phase estimation.
Overlap estimation: Setting (when constructible) or using related techniques, the Hadamard test can estimate the overlap between two quantum states.
Spectral analysis: The Hadamard test can be used to estimate the spectral function for a Hamiltonian , which encodes information about the energy spectrum.
Variational algorithms: In some formulations of VQE, Hadamard tests estimate off-diagonal terms in the Hamiltonian that cannot be directly measured in a single Pauli basis.
Cost analysis
The dominant cost of the Hadamard test is the controlled- operation. If is implemented as a circuit of gates, the controlled version typically requires additional gates plus multi-controlled operations. For Hamiltonian simulation where , the controlled version doubles the circuit depth.
The statistical cost of estimating to precision is shots, following standard sampling statistics.
Why it matters for learners
The Hadamard test is one of the most versatile primitives in quantum algorithms. It converts a question about a quantum operator (the expectation value of a unitary) into a measurable probability on a single ancilla qubit. Understanding this technique provides the foundation for phase estimation, spectral methods, and many variational algorithm techniques. It also demonstrates the power of controlled operations and the role of interference in extracting information from quantum systems.