# HHL algorithm, How to implement exp(iAt) gates?

The paper shows what inside operator $$e^{-iAt}$$ but didn't shows how to connect the control qubit (register term C) how can I connect them?

• Ask only a single question at once. However, you can likely re-formulate your question list to get an answer for 2 or more of your current points. It is also likely, that knowing the answer for that, you will know the answer for all. Feb 24 at 13:14

Edit: the question has been edited after I wrote my answer.

1. The paper shows what inside operator $$e^{-iAt}$$ but didn't shows how to connect the control qubit (register term C) how can I connect them?

The problem of controlling a full circuit (or sub-circuit here) has a trivial solution: control all the gates that compose the circuit.

So the implementation of the controlled exponential operator will be performed via this kind of circuit: All you have left to do is to decompose the non-primitive gates into primitive ones such as CCZ -> H(2) CCX H(2) -> H(2) [Toffoli gate implementation] H(2).

1. How can I encode matrix A into the circuit? Is the circuit for operator $$e^{-iAt}$$ in fig 4 can be use for any 4x4 matrix?

The matrix $$A$$ is already encoded in the circuit. In fact, the circuit implements the unitary matrix $$e^{-iAt}$$ which is the only place in the HHL algorithm where we actually need $$A$$.

As far as I know, this circuit may be able to encode any $$4\times 4$$ matrice. I do not think this is the case, but I do not have counter example to provide so the possibility is still there.

1. What does the eigenvalues from matrix $$A$$ is for? How is it related to the circuit?

In HHL and in linear system solving in general, the eigenvalues of the matrix $$A$$ are a particular interest. In this case, HHL works by estimating the eigenvalues of the matrix and inverting them (as in $$\frac{1}{\lambda}$$). In this paper, the authors use this specific matrix with these specific eigenvalues because the eigenvalues are easy to encode on qubits and the inversion step is easy to implement.

2. The last Z gate in the implementation actually seems to be an error. At least I was not able to make the code work with this Z gate but I was able to get results when replacing it with a CZ gate.
3. It is important to realize that this implementation is highly tailored to a specific matrix $$A$$. Changing it to make it work with another matrix $$A$$ will require to re-write nearly everything from scratch.
• Could you tell me the value of $t_0$ in your implemented code? I try to implement my own version but got different result. Mar 29 at 9:05
• My $t_0$ is $2\pi$ like in the article: github.com/nelimee/quantum-hhl-4x4/blob/master/hhl4x4/… Mar 29 at 9:57