from qiskit import QuantumRegister, QuantumCircuit
      import numpy as np

      t = 2  # This is not optimal; As an exercise, set this to the
      # value that will get the best results. See section 8 for solution.

      nqubits = 4  # Total number of qubits
      nb = 1  # Number of qubits representing the solution
      nl = 2  # Number of qubits representing the eigenvalues

      theta = 0  # Angle defining |b>

      a = 1  # Matrix diagonal
      b = -1/3  # Matrix off-diagonal

     # Initialise the quantum and classical registers
     qr = QuantumRegister(nqubits)

     # Create a Quantum Circuit
     qc = QuantumCircuit(qr)

     qrb = qr[0:nb]
     qrl = qr[nb:nb+nl]
     qra = qr[nb+nl:nb+nl+1]

    # State preparation. 
    qc.ry(2*theta, qrb[0])

    # QPE with e^{iAt}
    for qu in qrl:

    qc.u1(a*t, qrl[0])
    qc.u1(a*t*2, qrl[1])

    qc.u3(b*t, -np.pi/2, np.pi/2, qrb[0])

   # Controlled e^{iAt} on \lambda_{1}:


My question regarding this part of the code is

What is $e^{iAt}$ and controlled-$e^{iAt}$, and why is controlled U gates based on different angles $at,2at$. There are many questions regarding this.

Can somebody explain this code to me, on this site or can somebody share his/her mail. I really am have trouble regarding this HHL algorithm and its implementation.


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.