liveBook · Manning

State table

As explained in Building Quantum Software with Python

A state table is a tabular visualization that lists quantum-state outcomes and associated information such as probabilities.

A state table is a tabular view of a quantum state. Each row represents a possible measurement outcome; columns expose information associated with that outcome, such as its amplitude, magnitude, direction, and probability. It turns a compact state vector—a list of complex numbers—into a form that is easier to inspect visually. section 3.0 section 3.1.1

For a single qubit, the table has two outcome rows, 0 and 1. An amplitude is a complex number associated with each outcome. Its magnitude indicates the amplitude bar length, its direction can be represented by color, and its squared magnitude gives the probability of that outcome. Because squared magnitudes sum to 1, probabilities form a valid distribution. section 3.1.1

A useful expanded state table commonly includes:

Build an expanded table from a Python state list

Given a list such as state = [a0, a1], create one row per index. For each amplitude state[k], calculate direction with atan2(state[k].imag, state[k].real), magnitude with abs(state[k]), and probability with abs(state[k]) ** 2. Round display values separately so the stored state remains intact. The resulting rows connect each outcome index to its amplitude and derived properties. section 3.1.3

The same pattern generalizes to n qubits. There are 2ⁿ possible outcomes, so the state list and table contain 2ⁿ rows. List indices match integer outcomes, while each row can present either amplitudes directly or probabilities and directions. A valid simulated state has a power-of-two list length and squared amplitude magnitudes totaling 1. section 4.2.2 section 4.6

Figure 3.9 The expanded state table for the example state encoded in Python
figure

Inspect an expanded single-qubit table that aligns outcome indices with complex amplitudes, directions, magnitudes, and probabilities computed in Python. section 3.1.3

How Building Quantum Software with Python covers it

How deep it goes
Works through expanded single- and multi-qubit rows, including Python calculations for amplitude direction, magnitude, and probability.
Examples
Uses a two-amplitude single-qubit list and an eight-amplitude multi-qubit list to produce table rows.
What it assumes
Introduces state tables from quantum-state outcomes while deferring deeper complex-number details to a separate appendix.
What you can do after
Build it from scratch in Python by deriving table rows from state-list indices and complex amplitudes.
How it connects
Connects quantum states with state vectors, complex numbers, amplitudes, probabilities, quantum gates, and quantum circuits.

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.