Research Explained · Algorithms
Quantum Algorithm for Linear Systems of Equations
Aram W. Harrow, Avinatan Hassidim, and Seth Lloyd
Massachusetts Institute of Technology; University of Bristol · 2009 · Difficulty ★★★★☆
Reference
Harrow, A. W., Hassidim, A., & Lloyd, S. (2009). Quantum algorithm for linear systems of equations. Physical Review Letters, 103, 150502. arXiv:0811.3171.
Preprint: arXiv:0811.3171
This page is an independent explanation. For exact wording, figures, and data, read the original paper.
The short version
The HHL algorithm prepares a quantum state proportional to the solution of a linear system of equations in a time that grows only with the logarithm of the size of the system, an exponential speedup under certain conditions. The conditions matter a great deal, and they limit where the speedup applies.
Key findings
- For a sparse, well-conditioned N by N matrix A, a quantum computer can prepare a state proportional to the solution of A x equals b in time polylogarithmic in N.
- The runtime depends on the sparsity s, the condition number kappa, and the target precision epsilon, scaling roughly as log N times s squared times kappa squared over epsilon.
- The output is a quantum state, from which one can estimate quantities such as an inner product, but not read out the entire solution vector efficiently.
- Matrix inversion in this setting is BQP-complete, so the algorithm solves a problem that is universal for quantum computation.
Background: why this paper was written
Linear systems arise in nearly every area of science and engineering, from solving differential equations to training regression models. For a sparse system, the best classical iterative methods, such as conjugate gradient, take time roughly linear in N. In 2008, Harrow, Hassidim, and Lloyd asked whether a quantum computer could do much better, using the fact that a quantum state of log N qubits can hold N amplitudes.
The idea sits on top of quantum phase estimation and Hamiltonian simulation. Lloyd and others had shown that sparse Hamiltonians can be simulated efficiently on a quantum computer, and phase estimation can extract eigenvalues. A linear system can be solved if the right-hand side is expanded in the eigenvectors of the matrix and each component divided by its eigenvalue.
What the researchers did
The algorithm starts with a quantum state proportional to the vector b, assumed to be available. It uses Hamiltonian simulation to apply e to the i A t, then phase estimation to write the eigenvalues of A into an ancilla register in superposition. A controlled rotation then sets the amplitude of an extra qubit to be proportional to the inverse of each eigenvalue. The phase estimation is undone to clear the eigenvalue register, and the extra qubit is measured. When the result is one, the remaining register holds a state proportional to the solution x.
The authors analyze the running time. The cost is dominated by Hamiltonian simulation for a time of order kappa over epsilon, repeated to boost the success probability, and the final cost scales as log N times s squared times kappa squared over epsilon. A classical algorithm that outputs the full solution needs at least N steps, and even the best classical methods for finding a specific property of the solution scale polynomially in N.
The paper is explicit about what the algorithm does not do. It does not output the vector x. It outputs a quantum state, and extracting all N entries would take N measurements, destroying the speedup. What can be estimated efficiently are expectation values, such as the overlap of x with a given vector, or the total electromagnetic scattering cross section in a physical application.
Results
The central result is an exponential speedup in N for estimating certain properties of the solution of a sparse, well-conditioned linear system, assuming the input state can be prepared efficiently.
The authors show that the problem is BQP-complete under appropriate definitions, which means that any quantum computation can be encoded as a matrix inversion problem of this kind, and that a similar classical algorithm is unlikely.
The first experiments, in 2013, solved two-by-two systems on photonic and nuclear magnetic resonance devices, demonstrating the structure and not a speedup.
Key facts and numbers
| Item | Detail |
|---|---|
| Runtime | About log N times s squared times kappa squared over epsilon |
| Classical comparison | At least linear in N for the sparse conjugate gradient method |
| Output | A quantum state proportional to the solution, not the explicit vector |
| Complexity | The problem is BQP-complete |
| First experiments | 2013, two-by-two systems on photonic and NMR devices |
Limitations and caveats
Preparing the vector b as a quantum state can cost as much as solving the problem classically unless b has special structure, and the matrix must be sparse and given by an efficient oracle.
The dependence on the condition number kappa is steep, and well-conditioned systems are often easy for classical iterative methods as well.
Scott Aaronson's 2015 essay Read the Fine Print listed the caveats. In 2018, Ewin Tang's dequantization work showed that for machine learning applications with low-rank assumptions, classical algorithms with sampling access can match the quantum ones.
Why it matters
HHL started the field of quantum linear algebra and quantum machine learning. Its limitations, discussed by Aaronson in 2015, and the dequantization results that followed taught the field to examine input and output assumptions closely.
What happened next
Improvements by Childs, Kothari, and Somma in 2017 and by Gilyén and coauthors in 2019 reduced the dependence on precision and the condition number. Quantum singular value transformation now gives matrix inversion with a cost linear in kappa.
HHL inspired quantum algorithms for regression, support vector machines, principal component analysis, and differential equations, and also the variational linear solvers designed for near-term hardware. It remains a standard example in discussions of the assumptions behind quantum speedups.
How to read the original paper
The paper is short, and the algorithm is described in the main text. The supplementary material has the error analysis. Read Aaronson's Read the Fine Print afterward for the caveats.
The HHL and quantum singular value transformation pages on this site compare the original algorithm with its modern improvements.
Original abstract (paraphrased)
Solving linear systems of equations is a common problem that arises both on its own and as a subroutine in more complex problems. The paper shows that a quantum computer can obtain information about the solution vector x of Ax equals b in time poly(log N, kappa), where N is the number of variables and kappa is the condition number, by preparing a quantum state proportional to x, and compares this with the best classical algorithms, which take at least time proportional to N.
Frequently asked questions
What does the HHL algorithm do?
It prepares a quantum state proportional to the solution of a linear system, in time that grows only logarithmically with the size of the system under certain conditions.
Is the speedup real?
In its model, yes, but it requires efficient state preparation, a sparse and well-conditioned matrix, and a limited kind of output. In many applications those conditions undo the advantage.
Can HHL read out the full solution?
No. Reading all entries would take about N measurements. It is useful for estimating properties of the solution.
Keep exploring
- Algorithm: HHL Algorithm
- Algorithm: Quantum Singular Value Transformation (QSVT)
- Algorithm: Variational Quantum Linear Solver (VQLS)
- Hardware: IBM Heron (r1, r2, and r3)
- Dictionary: Hamiltonian
- Dictionary: Unitary Operator
- Dictionary: BQP Complexity Class
- Dictionary: Quantum Speedup
- Industry: Quantum Computing for Manufacturing
- Industry: Quantum Computing for the Aerospace and Defense Industry
- Industry: Quantum Computing for Oil, Gas, and Mining
Explanations on this page summarize published work for education (last reviewed September 30, 2026). Numbers are taken from the cited paper or from widely reported follow-up work, and later results may have updated or challenged them. Check the reference above before citing.