4
$\begingroup$

From the paper A survey on HHL algorithm: From theory to application in quantum machine learning , I use qasm code from here. I try to follow the example in page 7. with Ax = b
matrix A
and
enter image description here
the answer x should be
enter image description here

From the algorithm 2 in page 7 from the paper, They applied measurement on qubit q[0].
If q[0] = $|1\rangle$, the answer will be stored in q[.3] or register b.

HHL circuit from page 7

But in the example here, I got state $|0\rangle$ from ancilla bit if I use the same rotation angle as the example.

When I measure register b, I always got state $|1\rangle$ even if the result on ancilla bit is $|1\rangle$ (I change ancilla bit rotation angel from the example to 3.6591 and 1.8296).

Does the problem is the rotation angle on ancilla bit?
How can I get the correct result on register b? Can you give me a good example to do this?

$\endgroup$
3
$\begingroup$

In your code the measure clause means one shot, so the state collapses to one basis state as here: enter image description here By removing that last line the Statevector option shows the state before measurement, i.e. as a superposition of basis states: enter image description here Now you can see that for the basis states with q[0]=1 (that is 0001 and 1001) we get the right components of the solution vector $x$ (you can check that the numbers coincide with those reported in Table 2, row 1 of the paper you mentioned).

The "right" thing to do here if you want to avoid statevectors would be to do a few measurements and calculate the probabilities of obtaining 0001 and 1001, which is what they explain in Section 3.3.2. of the paper. The more measurements you do, the closer the probabilities you calculate will be to those from the statevector simulation.

$\endgroup$

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.