0
$\begingroup$

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: enter image description here

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?

$\endgroup$

1 Answer 1

1
$\begingroup$

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

The angles are easy to control via the clock register, as the bit representations of the eigenvalues don't have matching bits. When I try this in my infra, the rotation angles for the ancilla rotations are indeed:

$\pi\\ \pi/3\\ 0.5053605102841573\\ 0.5053605102841573$

Perhaps that's a place to start your investigations. For a detailed derivation of why I chose these angles, I learned things from this excellent Step-by-Step paper. I implemented the paper in Python here

$\endgroup$
2
  • $\begingroup$ Can I ask you why did you choose these rotation angles? What is the logic behind? In any way it is not expected that ancilla (rotations on this qubit) affect on the result. As I understand, we need this qubit just to be ensure in the correctness of the solution $\endgroup$ Jan 30 at 6:37
  • 1
    $\begingroup$ I've updated the answer. Hope this helps. $\endgroup$
    – rhundt
    Jan 30 at 16:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.