Overview

4 Analyze quantum states

This chapter focuses on the final step of quantum algorithms: extracting information from quantum states via measurement. It explains how quantum readout differs sharply from classical readout—outcomes are probabilistic, only limited information can be obtained, and measurement generally disturbs the state—so algorithms must be designed so that the desired information is actually retrievable. It also highlights that measurements can be computational tools in their own right, and pairs conceptual coverage with practical patterns for building and testing measurement-centric code in both Qiskit and Q#, including basic readout of basis states and strategies for validating results with repeated shots.

The chapter develops a sequence of state discrimination tasks. It starts with the simplest case—reading an unknown basis state by measuring all qubits—then advances to distinguishing orthogonal superpositions whose basis components do not overlap, which can be solved by direct measurement and classical postprocessing. When orthogonal states share basis components (e.g., Bell states), a change of measurement basis is required: apply a unitary that maps the target basis to the computational basis, measure, and interpret the results (e.g., Hadamard-basis measurement or a Bell measurement implemented with H and CNOT). Throughout, implementations in Qiskit (using classical registers and counts) and Q# (using the Result type and operations like MResetZ) show how to build and test these procedures.

Beyond perfectly distinguishable states, the chapter treats minimum-error discrimination of non-orthogonal states, deriving an optimal single-qubit measurement basis (implemented as a rotation followed by computational-basis measurement) and validating success probabilities statistically across many trials. It then outlines a lightweight tomography workflow for reconstructing a single-qubit state from multiple copies: estimate amplitude magnitudes from measurement frequencies and infer the relative sign via a π/2 rotation and comparison of outcomes. Finally, it introduces joint/parity measurements that extract partial information without collapsing a superposition: compute parity onto an ancilla via a chain of CNOTs and measure the ancilla so the data register remains intact—an approach that emphasizes testing not only the correctness of the extracted information but also that the post-measurement state is preserved.

Any quantum algorithm can be broken down into several steps: prepare the initial state, evolve it following the algorithm, and measure the end state to get the result. In this chapter, we’ll learn to work with the final step, measuring the state of the system to extract information about it.
figure
Measuring two qubits that are in a superposition of all basis states can give any of the results 00, 01, 10, and 11, with probabilities equal to squares of the amplitudes of the corresponding basis states in the superposition state. When we measure a system that is in a specific basis state, we can only get the result that corresponds to that state, with 100% probability.
figure
Measuring a quantum system in a superposition state can only return a basis state that was part of that superposition. Since all states consist of different basis states, the measurement result points back to the state that was measured uniquely.
figure
To do a measurement in Hadamard basis, we need to find unitary transformation that maps the states of the Hadamard basis, \(\ket{+}\) and \(\ket{-}\), into the computational basis states \(\ket{0}\) and \(\ket{1}\). This is exactly the effect of the Hadamard gate! After this, a measurement in the computational basis will let us figure out which of the states we started with, \(\ket{+}\) or \(\ket{-}\).
figure
Performing a measurement in a non-computational basis, using the Bell measurement as an example. First, we apply an operation that maps the basis states of the measurement basis (in this case, the Bell states) to the computational basis states. Then, we measure the qubits in the computational basis and interpret the measurement results. Finally, if the state of the system after the measurement has to match the measurement outcome, we apply the adjoint of the operation we applied on the first step.
figure
Choosing the measurement basis for distinguishing \(\ket{\psi_0} = \ket{0}\) from \(\ket{\psi_1} = \frac12 \ket{0} + \frac{\sqrt3}{2} \ket{1}\) with minimum error. We can describe the state \(\ket{\psi_1}\) using only one parameter, the angle \(\theta\) (for this example \(2\theta = \frac{\pi}{3}\)), and the measurement basis using the second parameter, the angle \(\gamma\). We aim to choose the measurement basis states so that they are as close to the states being distinguished as possible while remaining orthogonal.
figure
Reconstructing a single-qubit state \(\alpha \ket{0} + \beta \ket{1}\) from multiple copies. We start by estimating the absolute values of the coefficients \(\alpha\) and \(\beta\) and then figure out whether these coefficients have the same sign or different signs.
figure
Measuring the parity of a quantum state. You are given a state that is a superposition of basis states with the same parity: \(\ket{00}\) and \(\ket{11}\) or \(\ket{01}\) and \(\ket{10}\). The goal is to perform a measurement to learn the parity of this state in a way that doesn’t change the state.
figure

Summary

  • Measurements are an important part of quantum algorithms, since they’re the only way to learn information about the state of a quantum system. They also limit the power of quantum computing, since they limit the amount of information you can get out of a system!
  • Measurement allows us to identify the basis state in which the system is, or, if the system is in a superposition state, to read out one of the basis states that have non-zero amplitudes in the superposition. The probability of getting each state as the result of a measurement equals the square of its amplitude in the superposition.
  • The goal of many quantum algorithms is to get the quantum system into a state in which a measurement produces a problem solution with high probability. Some algorithms aim to estimate the probabilities of different measurement outcomes instead.
  • Orthogonal states can be distinguished with perfect accuracy, as long as you use the right measurement procedure. This can involve doing a measurement in a basis other than the default (computational) basis.
  • Non-orthogonal states cannot be distinguished with perfect accuracy. A measurement procedure can be set up to maximize the probability of identifying the given state correctly over multiple independent trials.
  • Quantum state tomography allows us to learn more detailed information about a quantum state compared to the information returned by a single measurement, as long as we’re given multiple copies of the state.
  • Joint measurements are a way to extract partial information about the quantum system — for example, the parity of the basis states included in the superposition — while preserving the state of this system. Joint measurements extract information about correlations between qubit states, while single-qubit measurements extract information about individual qubit states.

FAQ

What are the key differences between classical and quantum measurements?Classical readout is deterministic, can reveal the full n-bit state, and doesn’t disturb the system. Quantum measurement is probabilistic (outcomes weighted by amplitudes), reveals at most n classical bits from an n‑qubit system, and generally collapses/changes the state.
How do I read out an unknown basis state from an n‑qubit register?Measure all qubits in the computational basis. If the register is in a basis state, the bitstring you get equals that state with probability 1. In Qiskit: create QuantumCircuit(n, n) and circ.measure(range(n), range(n)). In Q#: loop MResetZ over the qubits and collect Result values.
How should I test code that involves measurements and randomness?- For basis states, assert a single outcome across many shots (deterministic).
- For superpositions/orthogonal discrimination, run multiple shots and verify every observed outcome maps to the correct label.
- For non‑orthogonal tasks, gather statistics over many trials and compare the success rate to theory (e.g., Helstrom bound), allowing tolerance.
How do I handle bit order (endianness) when interpreting results?Qiskit’s get_counts keys are big‑endian bitstrings; converting with int(key, 2) treats the leftmost bit as most significant. Many algorithms/notations (and some Q# helpers) use little‑endian. Be consistent: choose one convention, and convert explicitly when mapping results to integers or labels.
How can I distinguish orthogonal superposition states built from distinct basis states?Measure in the computational basis. Because no basis state appears in more than one candidate, any observed basis state points uniquely to the original superposition. Implement by measuring all qubits and mapping each basis outcome to its state label.
How do I distinguish Bell states (overlapping basis states) with a single measurement?Measure in the Bell basis by first mapping Bell states to computational states: apply CNOT(control=0,target=1), then H on qubit 0 (this is the inverse of Bell preparation), measure both qubits in Z, and interpret the two-bit result as the Bell index.
How can I distinguish two non‑orthogonal states with minimum error?Use the optimal (Helstrom) measurement: choose a basis rotated so each measurement vector is as close as possible to each state while remaining orthogonal. For states |ψ0>=|0> and |ψ1>=α|0>+β|1> (α,β≥0), compute θ = 0.5*atan2(β, α), then rotate by Ry(-2*(θ - π/4)) and measure Z. The maximum success probability is Pmax = 0.5*(1 + sin(2θ)).
How do I reconstruct a single‑qubit state from multiple copies (basic tomography)?- Estimate magnitudes: measure many copies in Z; set |α| ≈ sqrt(freq(0)), |β| ≈ sqrt(freq(1)).
- Estimate relative sign: rotate by Ry(π/2) (i.e., measure in the X/Hadamard basis) on many copies; if 0 occurs more than 1, infer a negative sign; otherwise positive. More trials are needed when one amplitude is small.
What is a parity (joint) measurement and how can it preserve superposition?A parity measurement extracts the XOR (even/odd) of multiple qubits without collapsing which basis component is present. Use an ancilla initialized to |0>, apply CNOT from each data qubit to the ancilla, then measure the ancilla. If all components share the same parity, the ancilla disentangles, the outcome gives the parity, and the data superposition is preserved.
How do I perform measurement in a non‑computational basis in general?Find a unitary U that maps the desired measurement basis to the computational basis, apply U, measure in Z, and (optionally) apply U† if you need the post‑measurement state in the original basis. This strategy underlies Hadamard‑basis and Bell‑basis measurements.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Quantum Programming in Depth ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Quantum Programming in Depth ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Quantum Programming in Depth ebook for free