# In the HHL alghoritm, how can I transform my hermitian matrix into a unitary operator?

I'm studying the HHL algorithm and I'm trying to do an his implementation but, there are some points that I don't understand how I can transform my hermitian Matrix into its unitary operator?

In Qiskit textbook I found this explanation about HHL algorithm. It says that after load the input data, we have to do QPE, but for QPE I need to transform my matrix A into $$e^{iAt}$$, how can I do that? The textbook doesn't explain.

Re-edit:I start with the first question and I use an example. I know that every hermitian matrix could be written as $$e^{-iAt}$$, using Pauli Gates. If I have the following matrix $$A=\begin{bmatrix} 1&-\frac{1}{3}\\ -\frac{1}{3}&1\\ \end{bmatrix}$$, I can write it as $$A=-\frac{1}{3}X+\mathbb{1}$$, so the exponential matrix is $$e^{-iAt}=e^{-i(-\frac{1}{3}X+\mathbb{1})t}=e^{-i(-\frac{1}{3}X)t}e^{-i(\mathbb{1})t}$$, I can write the last equality because the two operator commute. I want to write this in terms of gates, following the instruciton of previous posts I can write the term $$e^{-i(\mathbb{1})t}$$ as U1(-t) on control qubit. For $$e^{-i(-\frac{1}{3}X)t}$$, I know that $$e^{-i(X)t}$$ is equal to $$HR_z(2t)H$$,so, in my case, I can write $$e^{-i(-\frac{1}{3}X)t}=HR_z(-2\frac{t}{3})H$$

I tried to implement in qiskit the circuit, I find 100% of probability to have |11>, but I expect to have 100% of probability to have |10>, what am I doing wrong?

This is my code

t=2*np.pi*3/8
qpe = QuantumCircuit(3, 2)
qpe.h(2) #inizializzo il vettore (1,1) con H gate
for qubit in range(2):
qpe.h(qubit)     #applico H gate ai control bit
repetitions = 1
for counting_qubit in range(2):
for i in range(repetitions):
qpe.p(-t,counting_qubit)
qpe.h(2)
qpe.crz(-2/3*t,counting_qubit,2)
qpe.h(2)
repetitions *= 2
qpe.barrier();
qpe.draw()

def qft_dagger(qc, n):
"""n-qubit QFTdagger the first n qubits in circ"""
# Don't forget the Swaps!
for qubit in range(n//2):
qc.swap(qubit, n-qubit-1)
for j in range(n):
for m in range(j):
qc.cp(-math.pi/float(2**(j-m)), m, j)
qc.h(j)

# Apply inverse QFT
qft_dagger(qpe, 2)
#Measure
qpe.barrier()
for n in range(2):
qpe.measure(n,n)
qpe.draw()


My circuit

My result on simulator

Re-edit: I noticed that if I remove the minus sign to the gates, the result is correct, but I don't understand why

• Can you provide a little more context? For example, listing the specific equations you're referencing or pointing them out in the original paper would help – rjh324 Apr 21 at 19:11
• I've just edited my question – Simona99 Apr 21 at 20:26
• Both of these questions have been asked before on this site. If there's something about those answers that you still don't understand, perhaps that starts to pin down more specifically what your difficulty is? – DaftWullie Apr 22 at 7:30
• Comment on the Re-edit: You are doing it wrong. For example, QPE creates a controlled version of your circuit, so you shouldn't ignore the global phase. And as @DaftWullie said, your questions are already answered on this site. For example, the answers here are a good start: quantumcomputing.stackexchange.com/q/5567/9474 – Egretta.Thula Apr 26 at 22:32
• I have read the post, Ihave implemented the gloabal fase rotation, for the other term I think it is ok (I did the same thing done in the post), but I don't have the correct result, Is there something else wrong? – Simona99 Apr 27 at 11:37