Closed vontell closed 7 years ago
Hello! Thanks for the report.
The qubit indexes in Quil correspond to the exponents in the binary expansion of the basis index. Or, in other words, you should read the binary numbers right-to-left. So
X 0
X 1
would be the |011>
state, because
011 (binary) = 3 (decimal) = 0*2^2 + 1*2^1 + 1*2^0
The exponents of the radix 2
are precisely the qubit indexes.
It is important to note that some sciences do use other conventions here, which is important to be mindful of when writing Quil.
Ah of course; thanks for the clarification!
No problem. I might add that this is a good convention to follow because, were we to do it left-to-right, the basis elements would change if you add a qubit to the system. The index of the |1>
state in a 1-qubit system is the same as the index of the |0001>
state in a 4-qubit system. In the left-to-right scheme, we would have |1>
be indexed by 1, but |1000>
be indexed by 8, which seems silly. :)
When running the following code, there are some conflicting results:
I would expect this piece of code to transform my initial | 000 > state into | 110 >. The final result of running and measuring this code does return this result, but
qvm.bit_string_probabilities(p)
andprint qvm.wavefunction(p)[0]
do not have what I expect:The ordering of the bits seems to be off; instead of
110
having an amplitude/probability of 1,011
has an amplitude/probability of 1. After trying this out on a few other qubit variations, it seems that the results are reversed.