I'm working on solving a linear system with the quantum algorithm HHL. I don't understand how I can recover my vector $|x\rangle$ of real solution of the system starting from the states measured with ancilla qubit in $|1\rangle$. I found something about using tomography but I don't know how to apply it successfully to my circuit with Qiskit.

Can someone help me? Many thanks.


1 Answer 1


Quick answer: You will not be able to fully recover $x$.


  1. By design, the HHL algorithm stores $x$ in the amplitudes of a quantum state. Because of how quantum mechanics works, the vector representing the quantum state (i.e. containing all the amplitudes of the quantum state) needs to be of unit-norm (according to the Euclidean norm). Because of this, the result stored in the amplitudes of your quantum state is (most of the time) not $\vec{x}$ but rather $\vert x \rangle = \frac{\vec{x}}{\vert\vert\vec{x}\vert\vert}$. Also because quantum states are defined up to a global-phase, the most general expression of the "solution" of the linear system stored in the amplitudes is $$\vert x \rangle = e^{i\phi}\frac{\vec{x}}{\vert\vert\vec{x}\vert\vert}.$$

  2. As said in point 1, the HHL algorithm stores the result of the linear system provided by the user in the amplitudes of a quantum state. The problem is that these amplitudes are not directly measurable. You can measure the value of your qubits and the measured value will depend (probabilistically) on the underlying amplitudes, but you can't measure the amplitudes.

    One way to approximate the amplitudes (up to a global phase) is to use quantum state tomography. Here are some links related to quantum state tomography in Qiskit:

  • 3
    $\begingroup$ Presumably the biggest issue is that to perform tomography on the state in an attempt to recover $x$ (subject to the caveats you mention) is efficiency? Is it not the case that you need to repeat the whole thing enough times that you'd have been better performing the classical calculation? $\endgroup$
    – DaftWullie
    Commented Mar 5, 2019 at 12:41
  • 1
    $\begingroup$ I never used tomography but from what I read you are right: if you want to recover a good approximation of the whole state you will need to repeat your algorithm+measurements an exponential number of times, which would defeat the whole purpose of HHL (and of all the quantum algorithm I know). $\endgroup$ Commented Mar 5, 2019 at 12:42
  • $\begingroup$ Yes, I also think that the only possibility we have to make an estimation of x is by tomography operation, but we lose all the advantage of quantum computation... So I ask you guys, how can I interpret the probability results on ancilla qubit of my algorithm in connection to the problem I'm try to solving? $\endgroup$ Commented Mar 5, 2019 at 13:41
  • $\begingroup$ I would say this is 100% problem-dependent. It depends on what is your problem, what kind of information you will need to solve your problem and what information you will be able to extract from the quantum state. This would be a whole question on its own, only describing your problem might be quite long. If you want to investigate on your own you can try to understand the theory behind quantum measurement (en.wikipedia.org/wiki/Measurement_in_quantum_mechanics). I will not be able to help you more on this topic, I also need to improve my understanding of measurement. $\endgroup$ Commented Mar 6, 2019 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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