A quantum state is the working data structure of a qubit-based computation. It assigns an amplitude, or probability amplitude, to every possible measurement outcome. An amplitude has magnitude and direction; the probability of an outcome is the squared magnitude of its amplitude. Measurement returns one binary-string outcome sampled according to those probabilities, not the amplitudes themselves. section 2.2.2 section 1.3.2
For n qubits, there are 2ⁿ binary outcomes, so the state contains 2ⁿ complex amplitudes. List index k corresponds to the integer form of an outcome, and a valid state has a power-of-two length with squared amplitude magnitudes summing to 1. The usual initial state has amplitude 1 for the all-zero outcome and 0 for every other outcome. section 4.2.2 section 1.4.3
Treat a state as a lifecycle rather than a value you can inspect directly:
- Initialize the qubit system, commonly so only the all-zero outcome can occur. section 2.2
- Apply quantum gates, which recombine selected pairs of amplitudes and thereby change outcome probabilities. section 12.3
- Measure repeatedly to collect binary-string outcomes at frequencies determined by the state probabilities. section 1.4.4
- After a measurement, collapse the state to probability 1 for the observed outcome and 0 for the others. section 1.4.4
Encode and validate a single-qubit state
A single qubit has outcomes 0 and 1, so represent its state as two complex numbers. For state = [sqrt(0.3), -sqrt(0.7)], outcome 0 has probability 0.3 and outcome 1 has probability 0.7. The negative second amplitude changes its direction while the squared magnitudes still total 1. In Python, validate a candidate state with sum(abs(a)**2 for a in state) == 1. section 3.1 section 3.1.3
State tables make the representation inspectable in a simulator: show each outcome index beside its complex amplitude, direction, magnitude, and probability. For larger systems, the same data can be rendered as a wheel, a probability table, or pixels whose color represents amplitude direction and whose intensity represents magnitude. section 3.3.1 section 12.4
States are useful because gates manipulate amplitudes before measurement. Applying a Hadamard gate to every qubit of an all-zero three-qubit state produces equal-magnitude amplitudes for all eight outcomes, encoding a uniform distribution. More generally, quantum computations seek to raise the probability of desired outcomes; amplitude amplification is one such process. section 4.3.4 section 2.5
Figure 12.7 A three-qubit quantum state (top) and a four-qubit quantum state (bottom) illustrated as two-dimensional arrays of pixels
Use the pixel-array view to see that each outcome owns one amplitude and that partitioning qubits can arrange a state into rows and columns. section 12.4

