# hhl algorithm output

I'm trying to implement the HHL algorithm for the matrix and vecor as follows: $$A = \begin{bmatrix} 11 & 5 & -1 & -1 \\ 5 & 11 & 1 & 1 \\ -1 & 1 & 11 & -5 \\ -1 & 1 & -5 & 11 \end{bmatrix}$$ , $$B = \begin{bmatrix} 0 & 0 & 0 & 1 \end{bmatrix}^T$$ such that the normalized output vector is the following: $$\begin{bmatrix} 0.045 & 0.045 & 0.1818 & 0.7272 \end{bmatrix}^T$$.

The quantum circuit is the following:

where each e^(iApi/n) is buits as follows:

def get_gate(A, n):
pauli_op = PauliSumOp(SparsePauliOp.from_operator(A))
phi = Parameter('ϕ')
evolution_op = (phi * pauli_op).exp_i() # exp(-iϕA)
trotterized_op = PauliTrotterEvolution(trotter_mode=Suzuki(order=2, reps=1)).convert(evolution_op).bind_parameters({phi: np.pi/n})
#----control---------
gate = trotterized_op.to_circuit()
gate.name = f"e^(i*A*pi/{n})"
gate.label = f"e^(i*A*np.pi/{n})"
gate = gate.to_gate().control()
#---------------------
return gate


However, the output of the circuit is the following:

{'011': 1491, '000': 52, '010': 463, '001': 42}

what leads to the following output normilized X-vector:

0.72802734375 0.22607421875 0.025390625 0.021484375

having 2048 shots. I see that the first two numbers are almost correct, but the least two have a differnce almost in 2 times. I tried to change powers of the matrix eponentiations and change plus on minus, however this did not help. Is there any hint of how should I change the circuit?

Interesting! It appears your (mapped to integer) eigenvalues are $$\{1.0, 2.0, 4.0, 4.0\}$$. We know that for the rotations controlled by the clock register $$c$$, this relationship must hold: $$\theta(c) = \theta(c_3 c_2 c_1 c_0) = 2 \arcsin(1/\lambda)$$ which, for your eigenvalues, would be: $$\theta(1) = \theta(0001) = 2 \arcsin(1/1) = \pi \\ \theta(2) = \theta(0010) = 2 \arcsin(1/2) = \pi/3 \\ \theta(4) = \theta(0100) = 2 \arcsin(1/4) = 0.5053...$$
$$\pi\\ \pi/3\\ 0.5053605102841573\\ 0.5053605102841573$$