Basis Ordering and Indexing
A two-qubit state vector has four entries, one per basis state. To read or set the right entry you need to know which index corresponds to which label.
From labels to indices
Each computational basis state is a tensor product , written compactly as . The bits and each take the value 0 or 1.
In qbit-learning the convention is: qubit 0 is the most significant bit (MSB). So the index is computed exactly like reading a two-digit binary number with in the leading position:
Applying that formula to every two-qubit basis state gives the full table:
| Basis label | | | Index | |-------------|-------|-------|-------| | | 0 | 0 | 0 | | | 0 | 1 | 1 | | | 1 | 0 | 2 | | | 1 | 1 | 3 |
For example, has and , giving index .
Why MSB-first?
The choice to place qubit 0 at the most significant position is common in quantum computing toolkits and makes the index formula clean: the index of in an -qubit system is the ordinary binary integer whose bits are .
Generalising to qubits
For qubits the state vector has entries. The index is still the binary integer formed by reading the qubit values from qubit 0 (MSB) to qubit (LSB):
Three qubits give eight basis states ( through at indices 0–7), four qubits give sixteen, and so on.
Try it
Use the formula above to determine the state-vector index for the two-qubit basis state and return that integer.
Sign in on the full site to ask questions and join the discussion.