1
$\begingroup$

The textbook shows an example system of linear equations $Ax=b$ with

$$ A=\begin{pmatrix} -\frac{1}{3} & 1 \\ 1 & -\frac{1}{3} \end{pmatrix} \,\,\,\, b=\begin{pmatrix} 0 \\ 1 \end{pmatrix}. $$

The program in the text shows a result in real numbers. When trying to run a larger $A$ matrix and $b$ matrix, the output includes complex numbers even though the actual answer (calculated using numpy linear equation solver) shows no complex numbers. Where are these imaginary numbers coming from?

$\endgroup$
2
  • 1
    $\begingroup$ Without more details of the case you've tried, and the code you've run, it may be hard to track down. However, one quick thing to check - is it that your output $x$ is a real vector, but every element is multiplied by the same complex phase $e^{i\theta}$? $\endgroup$
    – DaftWullie
    Feb 16 '21 at 7:28
  • $\begingroup$ The code im running is the HHL code in the qiskit textbook, section 4A:Running HHL on a simulator (qiskit.org/textbook/ch-applications/hhl_tutorial.html). By replacing the matrix and vector: matrix = [[1, 1, 1, 2, 2, 3], [-5, 5, 6, 6, 6, -1], [3, 6, 2, 8, 8, 4], [2, 5, -3, 2, 4, 3], [1, 3, 2, 3, -2, 3], [12, 7, 1, 3, 3, 2]] and vector = [2,1,-2,2,1,2], the output solution includes complex numbers. $\endgroup$
    – user14860
    Feb 16 '21 at 18:02