A quantum bit, or qubit, is the fundamental unit of a quantum computing system. Measurement returns 0 or 1, but before measurement its state assigns an amplitude—and therefore an outcome probability—to each possible result. Unlike a classical bit, a qubit can be in a superposition, so computation changes outcome probabilities before one result is observed. section 1.4.2 section 2.5
A variable-bias coin is a useful programming analogy: instead of switching directly between two values, computation changes the chances of heads and tails, then measurement produces one outcome. The analogy stops short of the full model because quantum amplitudes have direction as well as magnitude; probability is the squared length of an amplitude. section 1.4.2
With multiple qubits:
- Each qubit supplies one digit of the measured binary string. Two qubits can yield 00, 01, 10, or 11; n qubits have 2^n possible outcomes. section 1.4.3 section 2.2.1
- The system state has one amplitude for every possible outcome. An n-qubit state can be represented programmatically as an array of 2^n complex numbers whose squared magnitudes sum to 1. section 1.4.3 section 4.6
- Qubits can be grouped into quantum registers to represent logical variables, such as an item selection, its value, and its weight. section 2.2.1
- Quantum gates transform amplitudes; controlled transformations use other qubits as controls. Circuits combine these transformations to create useful probability distributions. section 4.6
Figure 1.9 The steps of a quantum computation using quantum bits (qubits). The example in the diagram uses three qubits, so there are eight possible outcomes, each with a certain measurement probability represented by the filled part of the sectors. When a measurement is performed, we get one result according to the probabilities. The result is interpreted as a binary string.
This three-qubit view connects a state with eight possible outcomes to the single binary string returned by measurement. section 1.4.3
Encoding a knapsack candidate
Use a register of qubits for item selection and separate registers for total value and total weight. A run returns one binary string; its digits can be interpreted as the encoded variables. For optimization, transformations aim to increase the probability of desired outcomes. section 2.2.1 section 2.5

