# How to encode eigenvalues of matrix $A$ in solving $A\vec{x} = \vec{b}$ using the HHL Algorithm

I am trying to implement multiple parallel subroutines of HHL algorithm, each working on a different set of matrix $$A$$ (when solving for $$x$$, in $$A\vec{x} = \vec{b}$$), to find the expectation values of $$|x\rangle$$. The matrix $$A$$ is randomly generated Hermitian matrix, and may/may not be sparse (checking what happens, is also something I'm wondering).

I have the following queries:

1. If I understand correctly, I need to encode eigenvalues of a $$2 \times 2$$ matrix $$A$$, say $$\lambda_1$$ and $$\lambda_2$$ in the quantum register. Is that right? How do I do that?
2. Is the quantum register initialized with the binary values of $$\lambda_1$$ and $$\lambda_2$$? Does that mean 2 runs of HHL? Is finding Eigenvalues of matrix $$A$$ supposed to be a classical subroutine?
• If you’re randomly generating A, why not randomly generate its inverse instead and save yourself the bother of running HHL? Feb 6, 2020 at 6:41
• Thanks for your comment, DaftWullie. For now, I'm just testing on some random small size matrices, I intend to scale this to larger size matrices, and secondly I want to implement a quantum version inverse finding to learn doing it correctly. Feb 6, 2020 at 7:59

Finding the eigenvalues of $$A$$ is an intermediate part of the HHL algorithm (although it will not output them). It is a quantum routine known as phase estimation, for which you need to be able to implement a controlled-unitary evolution where the unitary is determined by $$U=e^{iAt}$$ for some $$t$$. You do not need to find them by any classical routine. However, you do need some prior information: a bound on the range that the eigenvalues can occupy (this determines the $$t$$ in the previous relation), and a bound on how close to zero these eigenvalues might be (this determines how large a register you need for performing the phase estimation).