1
$\begingroup$

I am currently trying to understand HHL by implementing a very inefficient Qiskit simulation script that performs HHL on an arbitrary hermitian matrix $A$ and a vector $b$.

Because I am currently only attempting to understand the higher-level workings of the HHL algorithm itself, I am cheating and just using Qiskit simulator features to implement the operators $e^{iAt/T}$ and to 'prepare' $|b>$

So far, I am trying to get it to work on two examples: the HHL example here and the problem done in this paper. It works as expected on the former, but not on the latter. This makes me wonder if i am correctly implementing the operators $e^{iAt/T}$ used in the QPE section of HHL.

So my question is whether I am implementing $e^{iAt/T}$ correctly or not. I have written a function that takes a hermitian matrix, exponentiates it using the scipy function expm, adds a control to this matrix, and then turns it into an operator using the Qiskit Operator function.

Does this function return the intended unitary operator, $e^{iAt/T}$? If it is ill-conceived, why?

from qiskit.quantum_info.operators import Operator
from scipy.linalg import expm

def hermitian_to_controlled_U(hermitian_matrix,T):
    U_matrix = expm(2j*pi*hermitian_matrix/T)

    # add control
    M0 = np.asarray([[1,0],\
                     [0,0]])
    M1 = np.asarray([[0,0],\
                     [0,1]])
    I = np.eye(np.shape(hermop)[0])
    controlled_U_matrix = np.kron(M0,I)+np.kron(M1,U_matrix)

    controlled_U_gate = Operator(controlled_U_matrix)

    return controlled_U_gate
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.