# Implementation of matrix A in HHL algorithm circuit

In HHL algorithm, how do we implement matrix $$A$$ (where $$A|x\rangle = |b\rangle$$) in the circuit?

A Hermitian matrix $$A$$ is implemented as series of controlled gates $$\mathrm{e}^{iAt}$$ for some $$t$$. This gate can be then implementend with controlled $$\mathrm{U3}$$ gate on IBM Q.

Note that original paper on HHL algorithm (see link below) provides a "trick" how to convert any matrix to Hermitian one and apply HHL algrithm.

For example, for Hermitian matrix $$A$$, type 2x2, there are two gates with $$t=\frac{\pi}{2}$$ and $$t=\frac{\pi}{4}$$ controlled by two different qubits.

1. Original paper by Harrow, Hasidim and Lloyd: Quantum algorithm for linear systems of equations
2. Practical implementation for 2x2 matrix: Quantum circuits for solving linear systems of equations
3. Another demonstration of practical implementation (pgs. 49-51): Quantum Algorithm Implementations for Beginners

I would recommend the third article for the best understanding how to implement HHL algorithm in practice.

• You seem to be assuming that A is Hermitian. Mar 2, 2020 at 6:31
• Yes, it is an assumption of original paper by HHL, however, the authors also provided simple "trick" how to convert non-Hermitian matrix to Hermitian one. See first link, pg. 2. Mar 2, 2020 at 7:49
• I know this. My point was that the Hermitian property is not stated in the question. So you probably want to be clear in your answer that that is what your assuming or, better yet, detail how to avoid it. Mar 2, 2020 at 7:59
• @DaftWullie: I see your point, answer edited accordingly. Mar 2, 2020 at 8:41

you can refer to the site for implementing HHL.

https://quantumpedia.uk/quantum-algorithm-4-hhl-algorithm-for-linear-systems-of-equations-40619daec41d

• Hi, and welcome to the Quantum Computing SE! We prefer to avoid link-only answers, since the links may break with time. Can you sum up what is described within this article in a way that answers the question please? Jan 2 at 21:09