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

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):
        repetitions *= 2

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)

# Apply inverse QFT
qft_dagger(qpe, 2)
for n in range(2):

My circuit enter image description here

My result on simulator

enter image description here

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

  • $\begingroup$ 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 $\endgroup$ – rjh324 Apr 21 at 19:11
  • $\begingroup$ I've just edited my question $\endgroup$ – Simona99 Apr 21 at 20:26
  • $\begingroup$ 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? $\endgroup$ – DaftWullie Apr 22 at 7:30
  • $\begingroup$ 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 $\endgroup$ – Egretta.Thula Apr 26 at 22:32
  • $\begingroup$ 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? $\endgroup$ – Simona99 Apr 27 at 11:37

i did the hamiltonian simulation with minus sign, but in QPE, I don't have to consider it


Your Answer

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

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