Steven GellerQuantum Computing, End to End

Book contents

Current section

Part II. Mathematical Core

  1. Complex Numbers for Quantum Computing
  2. Vectors, Bases, and Amplitudes
  3. Inner Products, Orthogonality, and Projection
  4. Matrices as Gates
  5. Unitary Operations and Reversibility
  6. Tensor Products and State-Space Growth
  7. Observables, Eigenvectors, and Measurement
  8. Density Matrices and Mixed States

Part II. Mathematical Core · Chapter 15

Density Matrices and Mixed States

The state ∣ + ⟩ and an honest coin flip between ∣0 ⟩ and ∣1 ⟩ give identical measurement statistics — and behave completely differently from then on. The density matrix is the notation that can tell them apart, and the one real hardware makes unavoidable.

Artifact
In this chapter 8 sections

Reader question. When is a statevector insufficient, and what can a density operator predict that a classical mixture description makes explicit?

A density operator represents both pure states and statistical mixtures, remains positive semidefinite with unit trace, predicts measurements by Tr(ρP), and distinguishes coherent superposition from an incoherent mixture through off-diagonal terms and purity.

Scope and non-goals.
  • This chapter does not cover complete-positive maps, master equations, or full tomography.
  • It does not claim every reduced mixed state reflects classical ignorance; entanglement can produce mixed subsystems.
Pure state on the surface, mixed state at the center Same Z-basis statistics, different states |0⟩ |1⟩ |+⟩ pure: ρ = |+⟩⟨+|; on the surface |0⟩ |1⟩ ρ = I/2 maximally mixed; at the center same Z statistics
Figure 15.1. Notice that only the pure state sits on the surface. Both ρ's return identical Z-basis counts, but the off-diagonal entries of the left one let it interfere later; the right one's never can.

Two preparations with identical Z counts

Contrast |+><+| with a 50/50 mixture of |0> and |1>.

A pure statevector represents maximal knowledge of an ideal, isolated quantum state. A density matrix represents pure states and everything short of them. It is the right language whenever you face uncertainty, noise, entanglement with an environment, or partial access to a larger system; which is to say, whenever you face hardware.

For a pure state ψ\lvert\psi\rangle, the density matrix is the outer product:

ρ=ψ ⁣ψ\rho=\lvert\psi\rangle\!\langle\psi\rvert(15.1)

A mixed state is a classical weighted combination of such projectors:

ρ=ipiψi ⁣ψi,ipi=1\rho=\sum_i p_i\lvert\psi_i\rangle\!\langle\psi_i\rvert,\quad \sum_i p_i=1(15.2)

Read the mixture as a recipe: with probability pip_i, the device actually holds ψi\lvert\psi_i\rangle, and you do not know which.

Evidence boundary. Density operators are positive semidefinite, Hermitian, and have trace one. [John Watrous] [Michael A. Nielsen]

Three conditions for a physical density operator

Derive Hermiticity, positivity, and trace one.

Three conditions certify any candidate density matrix:

  • Hermitian: ρ=ρ\rho=\rho^\dagger.
  • Unit trace: Tr(ρ)=1\operatorname{Tr}(\rho)=1; total probability is conserved.
  • Nonnegative eigenvalues; no outcome gets negative weight.

Two examples to hold in your head. For 0\lvert0\rangle:

ρ0=0 ⁣0=(1000)\rho_0=\lvert0\rangle\!\langle0\rvert=\begin{pmatrix}1&0\\0&0\end{pmatrix}(15.3)

And for +=(0+1)/2\lvert+\rangle=(\lvert0\rangle+\lvert1\rangle)/\sqrt2:

ρ+=12(1111)\rho_+=\frac12\begin{pmatrix}1&1\\1&1\end{pmatrix}(15.4)

The off-diagonal entries carry coherence; the memory that the amplitudes had a definite phase relationship. Noise typically shrinks or scrambles exactly those entries, which is why experimentalists watch them.

Evidence boundary. Pure states satisfy Tr(ρ²)=1 while nontrivial mixtures have lower purity. [Michael A. Nielsen] [John Preskill]

Off-diagonal terms carry coherence

Calculate the two example matrices explicitly.

In the Z basis, diagonal entries give Z outcome probabilities and off-diagonal entries preserve relative-phase information. Dephasing can erase those off-diagonal terms while leaving the Z populations unchanged. Comparing rho_plus with I/2 demonstrates why one measurement basis is incomplete: both are uniform in Z, yet X measurement is deterministic for rho_plus and uniform for I/2.

Evidence boundary. A subsystem of an entangled pure state can have a mixed reduced density operator obtained by partial trace. [John Watrous] [Michael A. Nielsen]

ρ=ipiψi ⁣ψi;Trρ=1;ρ0;γ=Tr(ρ2)\rho=\sum_i p_i\lvert\psi_i\rangle\!\langle\psi_i\rvert;\quad \operatorname{Tr}\rho=1;\quad \rho\succeq0;\quad \gamma=\operatorname{Tr}(\rho^2)(15.5)

Notation contract: ρ=Σ_i p_i|ψ_i><ψ_i|; Tr ρ=1; ρ⪰0; purity γ=Tr(ρ²); subsystem labels explicit in Tr_B.

Purity separates vector states from mixtures

Compute Tr(ρ²) and its limits.

The density matrix is a richer state representation for systems with uncertainty and environment interaction. It costs more; an nn-qubit ρ\rho holds 4n4^n entries against the statevector's 2n2^n; and it buys realism: noise processes act on ρ\rho in ways a statevector cannot express. The depolarizing channel, for instance, steadily pushes any state toward the less informative mixture at the center of the sphere, erasing off-diagonal coherence as it goes.

This is load-bearing for simulator design, error mitigation, quantum error correction, and hardware diligence alike. It also separates two stories that look identical in one measurement basis: a coherent superposition can interfere later, while a classical mixture with the same immediate probabilities cannot. A model that cannot represent that difference will overstate what an ideal statevector demonstration says about hardware.

Subsystem states by partial trace

Obtain a mixed qubit from a Bell pair and state the interpretive boundary.

The reduced state ρA=TrB(ρAB)\rho_A=\operatorname{Tr}_B(\rho_{AB}) is the unique operator that reproduces every local expectation Tr[(AI)ρAB]\operatorname{Tr}[(A\otimes I)\rho_{AB}]. For a Bell pair it is I/2 even though the joint state is pure. Local mixedness therefore does not identify ignorance about a locally prepared pure state; it can be the exact signature of entanglement with an inaccessible subsystem.

Density-matrix coherence laboratory

Acceptance contract for Density-matrix coherence laboratory
FieldReader-visible record
FormatNotebook with preparation, measurement, purity, and partial-trace functions
VerificationFixtures compare coherent/mixed preparations in X and Z bases, verify PSD/trace, and recover maximally mixed marginals from a Bell state.
AvailabilitySource-embedded acceptance record; no separate download is claimed
{
  "artifact": "Density-matrix coherence laboratory",
  "format": "Notebook with preparation, measurement, purity, and partial-trace functions",
  "acceptance_test": "Fixtures compare coherent/mixed preparations in X and Z bases, verify PSD/trace, and recover maximally mixed marginals from a Bell state.",
  "publication_state": "source-embedded contract and worked fixture"
}

Executable reference fixture

Run with Python 3.11 or later. The final assertion is the chapter-level pass condition for this small instance.

import math

def outer(state):
    return tuple(tuple(state[row] * state[column].conjugate() for column in range(len(state)))
                 for row in range(len(state)))

def mixture(weighted_states):
    if abs(sum(weight for weight, _ in weighted_states) - 1.0) > 1e-12:
        raise ValueError("mixture weights must sum to one")
    size = len(weighted_states[0][1])
    return tuple(tuple(sum(weight * state[row] * state[column].conjugate()
                           for weight, state in weighted_states)
                       for column in range(size)) for row in range(size))

def trace(matrix):
    return sum(matrix[index][index] for index in range(len(matrix)))

def purity(matrix):
    return sum(abs(value) ** 2 for row in matrix for value in row).real

def validate_qubit_density(matrix):
    if len(matrix) != 2 or any(len(row) != 2 for row in matrix):
        raise ValueError("fixture expects a qubit density matrix")
    if abs(trace(matrix) - 1.0) > 1e-12 or abs(matrix[1][0] - matrix[0][1].conjugate()) > 1e-12:
        raise ValueError("density matrix must be Hermitian with trace one")
    determinant = (matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0]).real
    if matrix[0][0].real < -1e-12 or matrix[1][1].real < -1e-12 or determinant < -1e-12:
        raise ValueError("density matrix must be positive semidefinite")
    return determinant

def probability(matrix, ket):
    return sum(ket[row].conjugate() * matrix[row][column] * ket[column]
               for row in range(2) for column in range(2)).real

def phase_flip_channel(matrix, probability_z):
    if not 0 <= probability_z <= 1:
        raise ValueError("channel probability must lie in [0,1]")
    factor = 1 - 2 * probability_z
    return ((matrix[0][0], factor * matrix[0][1]),
            (factor * matrix[1][0], matrix[1][1]))

def trace_out_second(matrix):
    if len(matrix) != 4 or any(len(row) != 4 for row in matrix):
        raise ValueError("partial trace fixture expects two qubits")
    return tuple(tuple(sum(matrix[2 * left + bit][2 * right + bit] for bit in (0, 1))
                       for right in (0, 1)) for left in (0, 1))

scale = math.sqrt(0.5)
zero, one, plus, plus_i = (1, 0), (0, 1), (scale, scale), (scale, 1j * scale)
rho_plus = outer(plus)
rho_plus_i = outer(plus_i)
rho_mixed = mixture(((0.5, zero), (0.5, one)))
for matrix in (rho_plus, rho_plus_i, rho_mixed):
    validate_qubit_density(matrix)
assert abs(purity(rho_plus) - 1.0) < 1e-12
assert abs(purity(rho_plus_i) - 1.0) < 1e-12
assert abs(purity(rho_mixed) - 0.5) < 1e-12
assert abs(probability(rho_plus, zero) - probability(rho_mixed, zero)) < 1e-12
x_contrast = probability(rho_plus, plus) - probability(rho_mixed, plus)
assert abs(x_contrast - 0.5) < 1e-12

channel_purities = []
for probability_z in (0.0, 0.25, 0.5):
    evolved = phase_flip_channel(rho_plus, probability_z)
    validate_qubit_density(evolved)
    channel_purities.append(purity(evolved))
assert all(abs(actual - expected) < 1e-12 for actual, expected in zip(channel_purities, (1.0, 0.625, 0.5)))

bell = (scale, 0, 0, scale)
marginal = trace_out_second(outer(bell))
assert all(abs(marginal[row][column] - (0.5 if row == column else 0.0)) < 1e-12
           for row in range(2) for column in range(2))

non_psd_rejected = False
try:
    validate_qubit_density(((0.5, 0.6), (0.6, 0.5)))
except ValueError:
    non_psd_rejected = True
assert non_psd_rejected
bad_weights_rejected = False
try:
    mixture(((0.4, zero), (0.4, one)))
except ValueError:
    bad_weights_rejected = True
assert bad_weights_rejected
print(f"PASS: 15 density laboratory separates coherent/mixed X statistics by {x_contrast:.3f}, tracks dephasing purities={channel_purities}, and recovers Bell marginal purity={purity(marginal):.3f}")

Scope boundary

  • This chapter does not cover complete-positive maps, master equations, or full tomography.
  • It does not claim every reduced mixed state reflects classical ignorance; entanglement can produce mixed subsystems.

Depth commitment. Two indistinguishable-in-Z states, one X-basis separation, one Bell marginal, and a complete validator.

Practice problem

Build density matrices for |+>, a 50/50 Z mixture, and one Bell-pair marginal; compute X/Z statistics and purity for each.

Deliverable
Three matrices, two measurement tables, three purity values, and one equivalence/distinction statement.
Pass condition
The notebook verifies physicality, reproduces all statistics, and shows which preparations are operationally distinguishable in X.

Verification record

Expected solution form. Matrix-by-matrix solution plus tested density-operator report.

Model answer. rho_plus=[[1/2,1/2],[1/2,1/2]] has purity one, deterministic X+, and uniform Z. The 50/50 Z mixture is I/2 with purity one half and uniform X and Z. Tracing either half of a Bell pair also gives I/2, so local statistics cannot distinguish those last two preparations.

Model result and check. CI checks eigenvalues, traces, purities, measurement probabilities, and the partial trace.

Acceptance test. The notebook verifies physicality, reproduces all statistics, and shows which preparations are operationally distinguishable in X.

Companion work

Artifacts for this chapter

These entries resolve to checked-in local source. Commands are reproduced exactly from the chapter manifest, and source-embedded fixtures are exported as direct downloads.

  1. Reproduce or test

    python3 tools/validate_briefs.py --briefs data/editorial_briefs_00_35.json --from 0 --through 35 --check-rewritten-sources --execute-artifacts

Provenance

Sources and review

  1. John Watrous. The Theory of Quantum Information. Cambridge University Press / University of Waterloo. 2018textbook
  2. Michael A. Nielsen and Isaac L. Chuang. Quantum Computation and Quantum Information. Cambridge University Press. 2010textbook
  3. John Preskill. Lecture Notes for Physics 219: Quantum Computation. California Institute of Technology. 2018graduate lecture notes

The load-bearing claims in the chapter are mapped inline to this registered source set. A citation supports only the bounded claim beside it.

Cite this chapter