Solving Linear Systems of Equations with the Quantum HHL Algorithm: A Tutorial on the Physical and Mathematical Foundations for Undergraduate Students
Lucas Q. Galvão, Anna Beatriz M. de Souza, Alexandre Oliveira S. Santos, André Saimon S. Sousa, Clebson Cruz
TL;DR
This tutorial synthesizes the physical and mathematical underpinnings of the Harrow–Hassidim–Lloyd HHL algorithm for solving linear systems $A\vec{x}=\vec{b}$ on quantum devices. It details the end-to-end circuit structure—State Preparation, Quantum Phase Estimation, Ancilla Encoding, and Inverse QPE—along with a concrete 2×2 numerical example implemented in Qiskit, and discusses both ideal and noisy hardware performance. The work analyzes the algorithm's computational complexity, highlights practical limitations (notably state preparation and tomography on NISQ devices), and outlines the algorithm's potential as a subroutine for quantum simulations and quantum machine learning. By providing explicit circuits, code guidance, and critical discussion of noise and scalability, the paper aims to empower undergraduates to understand, implement, and evaluate HHL in realistic settings and to contribute to its future development.
Abstract
Quantum computing enables the efficient resolution of complex problems, often outperforming classical methods across various applications. In 2009, Harrow, Hassidim and Lloyd proposed an algorithm for solving linear systems of equations, demonstrating exponential speedup (under ideal conditions) with a complexity of $poly(\log N)$, in contrast to classical approaches, which in the general case exhibit a complexity of $O(N^3)$, although they can achieve $O(N)$ in specific cases involving sparse matrices. This algorithm holds promise for advancements in machine learning, the solution of differential equations, linear regression, and cryptographic analysis. However, its structure is intricate, and there is a notable lack of detailed instructional materials in the literature. In this context, this paper presents a tutorial addressing the physical and mathematical foundations of the HHL algorithm, aimed at undergraduate students, explaining its theoretical construction and its implementation for solving linear equation systems. After discussing the underlying mathematical and physical concepts, we present numerical examples that illustrate the evolution of the quantum circuit. Finally, the algorithm's complexity, limitations, and future prospects are analyzed. The examples are compared with their classical simulations, allowing for an operational assessment of the algorithm's performance.
