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,