liveBook · Manning

Quantum state

As explained in Building Quantum Software with Python

A quantum state is the mathematical description of a quantum system that specifies the amplitudes and therefore the probabilities of its possible measurement outcomes.

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
figure

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

How Building Quantum Software with Python covers it

How deep it goes
Develops amplitudes, complex-list encodings, validity checks, tables, gates, and visualizations, while deferring a proof of quantum postulates.
Examples
Uses single-qubit complex lists, three-qubit probability wheels and tables, uniform distributions, and pixel-array state images.
What it assumes
Assumes binary strings, complex numbers, basic trigonometry, and probabilities while requiring no quantum mechanics background.
What you can do after
Build it from scratch as validated Python lists of complex amplitudes and visualize probabilities in state tables.
How it connects
Connects amplitudes, quantum measurement, quantum gates, quantum circuits, superposition, amplitude amplification, and uniform distributions.

Also explained in

Compare how 2 books explain quantum state →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Quantum Software with Python. The section links point to the parts of the book it draws on.