# Exponentiating Hermitian Matrix for use in QPE/HHL

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)