Approximate quantum counting estimates the number of satisfying assignments of a Boolean function, using a quantum oracle and quantum measurement. Controlled repetitions of a Grover search algorithm iteration let quantum interference reveal the count. For one input bit, a Hadamard test can give Pauli Z gate expectation value : with the complemented phase oracle and , use to obtain . Repeated preparations estimate this expectation value; one binary measurement result does not distinguish all three counts .
For the Hadamard test with a density operator in the auxiliary register, the output control qubit has Pauli Z gate expectation and Pauli Y gate expectation , where . The minus sign comes from the final Hadamard gate, since . Measuring in therefore estimates the imaginary part using the minus-outcome frequency minus the plus-outcome frequency.
Define the Hadamard basis states . The initial two Hadamard gates prepare . For one bracket, the two control branches give
Using the Pauli X gate , unitary conjugation by the Hadamard gate gives , so . Keeping every sign, the target states along the control-one branch, in the exact gate order, are
The last column also includes the final target Hadamard gate, which lies outside the bracket. Writing , applying the final top Hadamard gate gives the exact normalized two-qubit quantum state
Thus the complete outputs, in top-then-bottom computational basis order, are
For the first qubit, the Pauli matrix has expectation value by the Born rule. The two cases each have , while the and cases are deterministic. Equivalently, this Hadamard test measures
This explains the approximate quantum counting interpretation: repeated preparations estimate the expectation value, and hence . A single top-qubit computational-basis measurement need not identify .
Read the source network as a Hadamard test: a Hadamard gate on the first qubit, a controlled unitary gate with the first qubit as control, and another Hadamard gate on that control. Starting from , the successive quantum states are
Apply b to the last line. Since by unitarity,
For the Pauli Z gate observable on the first qubit, the two eigenvalues are and . Thus
As a check, returns outcome zero certainly, while returns one certainly. The controlled unitary gate makes this relative phase measurable even though multiplying an isolated system's quantum state by is only a global phase.
For second-qubit inputs and , c gives control expectation values and . Preparing the maximally mixed state is equivalent to choosing these inputs independently with equal probability and discarding the choice. Linearity of the density operator evolution and quantum measurement probabilities therefore gives
Hence
The factor two is essential: the Hadamard test directly estimates the normalized trace. More generally, a target density operator gives . This argument never requires knowledge of the eigenvectors of .
Let the spectral decomposition of the Hermitian matrix be
The HHL algorithm proceeds as follows.
Efficiently prepare the normalized amplitude encoding .
Apply quantum phase estimation to the simulated evolution , producing an approximation of each eigenvalue:
Add one ancilla and perform an eigenvalue-controlled rotation
where .
Uncompute the eigenvalue register. Conditional on measuring the ancilla as , the system register is
The postselection probability can be increased with amplitude amplification.
The ingredients used here are efficient sparse Hamiltonian simulation of and quantum phase estimation, which converts an eigenphase of that evolution into a binary approximation of . For sparsity , condition number , and error , the cost is polynomial in , , , and under the stated access assumptions.
Finally estimate by repeated measurement of an efficient observable decomposition of , or by a Hadamard test when is unitary. A general efficiently block-encoded Hermitian can similarly be measured through its block encoding. Repetition and a concentration inequality give additive sampling error after independent preparations.
After the first Hadamard gate and the controlled unitary gate, the state is
The final Hadamard gate gives
Hence the Hadamard test returns one with probability
If , then and the outcome is zero with certainty. If , then modulo and the outcome is one with certainty. The single measurement therefore distinguishes the two promised cases exactly.
Both and are unitary and Hermitian, so their expectations are real. Run the real-part Hadamard test twice, once with controlled and once with controlled . If the respective ancilla outcome-one probabilities are and , then
The identity in part (b) implements each controlled tensor product by gates on its two target wires with the common control. By linearity,