qiskit-textbook icon indicating copy to clipboard operation
qiskit-textbook copied to clipboard

[4.1.1] HHL doesn't give the right answer

Open yulunwang opened this issue 4 years ago • 4 comments

Describe the Issue

Hi I am using HHL function in Aqua. Here are two examples I tested: image For the second example, HHL failed giving me correct answer.

It gives me [4,4] instead of [-4 -4]

And also I tried these two cases: image The second case here are much less accurate comparing to the first one. The codes are the same and borrowed from qiskit textbook Thanks!

Expected Solution

Produce correct results

Anything else we should know?

yulunwang avatar Apr 13 '20 20:04 yulunwang

@yulunwang, thanks for raising this issue. We are having a few issues with the HHL chapter and I'm looking into it.

frankharkins avatar Apr 14 '20 10:04 frankharkins

@frankharkins : could you please assign this issue to me. I would like to take a look at it.

hykavitha avatar Mar 19 '21 09:03 hykavitha

Looks like it has to do with the negative eigen values. In the case of [[-1/2, 0], [0, -1/2]], the eigenvalues are all negative and we need to set the eigs-negative parameter for the HHL module to true to get the correct answer. If that is set to be the default false, we will not get the correct answer. In the other case of [[0, -1/2], [-1/2, 0]], there will be one positive and one negative eigenvalues and, as it is implemented now, there is no way to get the correct answer, neither with eigs-negative set to positive nor negative. The correct implementation of HHL doesn't have a way to handle this correctly.

zyzhang1992 avatar Apr 03 '21 17:04 zyzhang1992

Fixed in https://github.com/Qiskit/qiskit-terra/pull/6971.

rht avatar Jul 17 '22 00:07 rht