# 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.

Please see these articles for more information how to implement HHL algorithm:

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. – DaftWullie Mar 2 '20 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. – Martin Vesely Mar 2 '20 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. – DaftWullie Mar 2 '20 at 7:59
• @DaftWullie: I see your point, answer edited accordingly. – Martin Vesely Mar 2 '20 at 8:41