Quantum Mechanics

The Density Matrix

The operator that describes any quantum state — pure or mixed — ρ = Σ p_i |ψ_i⟩⟨ψ_i|

The density matrix ρ (or density operator) is the most general description of a quantum state: a Hermitian, positive-semidefinite operator with unit trace that encodes both pure states and statistical mixtures at once. It is defined as ρ = Σ_i p_i |ψ_i⟩⟨ψ_i|, gives every measurement average through ⟨A⟩ = Tr(ρA), and reduces to the familiar wavefunction description ρ = |ψ⟩⟨ψ| for a pure state. Introduced independently by John von Neumann and Lev Landau in 1927, it is the language of open quantum systems, decoherence, quantum information, and quantum statistical mechanics.

  • General definitionρ = Σ p_i |ψ_i⟩⟨ψ_i|
  • NormalizationTr(ρ) = 1
  • Expectation value⟨A⟩ = Tr(ρA)
  • PurityTr(ρ²) ≤ 1 (= 1 iff pure)
  • Reduced stateρ_A = Tr_B(ρ_AB)
  • Von Neumann entropyS = -Tr(ρ ln ρ)
  • Introducedvon Neumann & Landau, 1927

Interactive visualization

Press play, or step through manually. The visualization is yours to drive — try it before reading on.

Open visualization fullscreen ↗

Watch the 60-second explainer

A condensed visual walkthrough — narrated, captioned, under a minute.

Definition

Quantum mechanics as usually taught assigns a state vector — a ket |ψ⟩ — to a system. But that only works when the state is completely known. The density matrix generalizes this to cover incomplete knowledge, thermal ensembles, and subsystems of entangled wholes. It is a single operator ρ that carries every physically accessible prediction.

For a system that is, with classical probability p_i, in one of several normalized pure states |ψ_i⟩, the density operator is:

ρ = Σ_i p_i |ψ_i⟩⟨ψ_i|

where each p_i ≥ 0 and Σ_i p_i = 1. The states |ψ_i⟩ need not be orthogonal. Every valid density matrix satisfies three defining properties:

  • Hermitian: ρ = ρ† (real eigenvalues — the probabilities of its eigenstates).
  • Positive semidefinite: ⟨φ|ρ|φ⟩ ≥ 0 for all |φ⟩ (no negative probabilities).
  • Unit trace: Tr(ρ) = 1 (total probability conserved).

Any operator with these three properties is a legitimate quantum state, and every quantum state can be written this way. That is the sense in which ρ is the most general description available.

Pure states vs. mixed states

When the ensemble collapses to a single term — the system is definitely in |ψ⟩ — the density matrix becomes a rank-1 projector:

ρ_pure = |ψ⟩⟨ψ|,   ρ² = ρ,   Tr(ρ²) = 1

This is a pure state. It is idempotent (ρ² = ρ) because projecting twice is the same as projecting once. A mixed state is anything else: a classical probabilistic blend of distinguishable pure states. Its purity dips below one, Tr(ρ²) < 1.

The single most-important conceptual trap here: a superposition is not a mixture. The state (|0⟩ + |1⟩)/√2 is a pure state — you know it exactly — and its density matrix has nonzero off-diagonal terms. A 50/50 statistical mixture of |0⟩ and |1⟩, by contrast, is diagonal and represents genuine ignorance. Both have populations (½, ½), but only the superposition can interfere.

PropertyPure stateMixed state
Formρ = |ψ⟩⟨ψ|ρ = Σ p_i |ψ_i⟩⟨ψ_i|, ≥ 2 terms
Idempotenceρ² = ρρ² ≠ ρ
Purity Tr(ρ²)= 1< 1 (down to 1/d)
Von Neumann entropy S0> 0 (up to ln d)
Eigenvaluesone is 1, rest are 0several nonzero, summing to 1
Describable by a ket?YesNo
Bloch vector (qubit)on the surface, |r| = 1inside, |r| < 1

Expectation values: ⟨A⟩ = Tr(ρA)

The single most useful formula involving ρ predicts the average outcome of measuring any observable A (a Hermitian operator):

⟨A⟩ = Tr(ρ A)

Here Tr denotes the trace — the sum of diagonal elements — which is basis-independent, so ⟨A⟩ is the same computed in any representation. Symbols: ρ is the density matrix (dimensionless, unit trace); A is the observable operator (units match the physical quantity — energy in J, spin in ℏ, etc.); ⟨A⟩ is the ensemble-averaged expectation value.

For a pure state this collapses to the textbook rule: Tr(|ψ⟩⟨ψ| A) = ⟨ψ|A|ψ⟩. For a mixture it automatically produces the classically-weighted quantum average, ⟨A⟩ = Σ_i p_i ⟨ψ_i|A|ψ_i⟩. One recipe, both cases — this is precisely why ρ is so powerful.

Populations and coherences

Write ρ as a matrix in some orthonormal basis {|n⟩}. The entries split into two physically distinct groups:

  • Diagonal elements ρ_nn — populations. ρ_nn = ⟨n|ρ|n⟩ is the probability of finding the system in |n⟩. They are real, non-negative, and sum to 1 (that is what Tr(ρ) = 1 says).
  • Off-diagonal elements ρ_mn (m ≠ n) — coherences. These complex numbers encode the definite phase relationship between |m⟩ and |n⟩. Their magnitude bounds interference contrast; a purely diagonal ρ is a classical mixture that cannot interfere.

For a single qubit the density matrix in the {|0⟩, |1⟩} basis is:

      ⎡ ρ₀₀   ρ₀₁ ⎤     ⎡ population(0)   coherence ⎤
ρ  =  ⎢           ⎥  =  ⎢                          ⎥
      ⎣ ρ₁₀   ρ₁₁ ⎦     ⎣ coherence*   population(1)⎦

Hermiticity forces ρ₁₀ = ρ₀₁*. Decoherence — coupling to the environment — attacks the coherences directly: ρ₀₁(t) = ρ₀₁(0) e^(−t/T₂), where T₂ is the dephasing time. The populations may relax more slowly on the energy-relaxation timescale T₁ (with T₂ ≤ 2T₁). Once the coherences vanish, the state is an ordinary classical probability distribution — the superposition is gone.

The Bloch-sphere picture for a qubit

Every single-qubit density matrix can be written with the Pauli matrices σ_x, σ_y, σ_z and the identity I:

ρ = ½ ( I + r · σ ) = ½ ( I + r_x σ_x + r_y σ_y + r_z σ_z )

The real 3-vector r = (r_x, r_y, r_z) is the Bloch vector, with r_i = Tr(ρ σ_i) = ⟨σ_i⟩. Its length sets the purity exactly:

Tr(ρ²) = ½ ( 1 + |r|² )

Pure states have |r| = 1 and live on the surface of the Bloch sphere; mixed states have |r| < 1 and sit strictly inside; the center r = 0 is the maximally mixed state ρ = I/2 with purity ½. Decoherence shrinks r toward the axis or the center — the geometry makes "losing coherence" literally visible.

Reduced density matrix, entanglement, and decoherence

Take two systems A and B in a joint state ρ_AB. Everything predictable by measurements on A alone is contained in the reduced density matrix, obtained by the partial trace over B:

ρ_A = Tr_B(ρ_AB) = Σ_k ⟨b_k|_B  ρ_AB  |b_k⟩_B

Here {|b_k⟩} is any orthonormal basis of B. The magic: if the combined system AB is in an entangled pure state, ρ_A comes out mixed — Tr(ρ_A²) < 1 — even though ρ_AB itself is pure with Tr(ρ_AB²) = 1. The loss of purity upon tracing out a partner is the operational fingerprint of entanglement.

Consider the maximally entangled Bell state |Φ⁺⟩ = (|00⟩ + |11⟩)/√2. The joint density matrix ρ_AB = |Φ⁺⟩⟨Φ⁺| is pure. But tracing out qubit B leaves:

ρ_A = Tr_B(|Φ⁺⟩⟨Φ⁺|) = ½ (|0⟩⟨0| + |1⟩⟨1|) = I/2

Each qubit alone is maximally mixed — completely random, purity ½, entropy ln 2 — while the pair is perfectly correlated. This is the sense in which "the whole knows more than the sum of the parts." Decoherence is the same mechanism playing out with an uncontrolled environment as partner B: entanglement with the surroundings leaves the system in an effectively classical mixed state, its coherences traced away, without any need to invoke wavefunction collapse.

Von Neumann entropy

The quantum analog of Gibbs–Shannon entropy is the von Neumann entropy:

S(ρ) = -Tr(ρ ln ρ) = -Σ_i λ_i ln λ_i

where λ_i are the eigenvalues of ρ. Symbols: S is entropy (dimensionless in nats; multiply by k_B = 1.381 × 10⁻²³ J/K for thermodynamic units, or use log₂ for bits); λ_i are the eigenvalues (the probabilities in the diagonalizing eigenbasis). Key values:

  • Pure state: one eigenvalue is 1, the rest 0, so S = 0. No missing information.
  • Maximally mixed state (d dimensions): all λ_i = 1/d, giving the maximum S = ln d. For a qubit, S_max = ln 2 ≈ 0.693 nats = 1 bit.
  • Entanglement entropy: for a bipartite pure state, S(ρ_A) = S(ρ_B) is a rigorous measure of how entangled A and B are; it is ln 2 for a Bell pair and 0 for a product state.

The thermal (Gibbs) state ρ = e^(−H/k_BT)/Z maximizes S(ρ) at fixed average energy — this is quantum statistical mechanics built directly on the density operator, with the partition function Z = Tr(e^(−H/k_BT)).

Time evolution: the von Neumann equation

A closed system's density matrix evolves by the quantum Liouville (von Neumann) equation, the operator form of the Schrödinger equation:

iℏ dρ/dt = [H, ρ] = Hρ - ρH

Symbols: = 1.055 × 10⁻³⁴ J·s (reduced Planck constant); H is the Hamiltonian (energy operator, in J); [H, ρ] is the commutator. Unitary evolution preserves the eigenvalues of ρ, hence purity and von Neumann entropy stay constant — a closed system never spontaneously decoheres. To describe decoherence and dissipation you couple to an environment and derive a master equation (e.g. the Lindblad equation), which can lower purity and raise entropy while keeping Tr(ρ) = 1.

Python — building and probing a density matrix

import numpy as np

# --- single-qubit basis ---
ket0 = np.array([[1], [0]], dtype=complex)
ket1 = np.array([[0], [1]], dtype=complex)

def dm(ket):                      # pure-state density matrix |psi> + |1>)/sqrt(2)  -- has coherences
psi   = (ket0 + ket1) / np.sqrt(2)
rho_pure = dm(psi)

# Classical 50/50 mixture of |0> and |1>  -- diagonal, no coherences
rho_mix  = 0.5 * dm(ket0) + 0.5 * dm(ket1)

def purity(rho): return np.real(np.trace(rho @ rho))
def vn_entropy(rho):
    w = np.linalg.eigvalsh(rho)
    w = w[w > 1e-12]
    return float(-np.sum(w * np.log(w)))

print("Tr(rho_pure) =", np.real(np.trace(rho_pure)))   # 1.0
print("purity pure  =", purity(rho_pure))              # 1.0
print("purity mix   =", purity(rho_mix))               # 0.5
print("S(pure) nats =", vn_entropy(rho_pure))          # 0.0
print("S(mix)  nats =", vn_entropy(rho_mix))           # 0.693 = ln 2

# Expectation value   = Tr(rho A),  A = sigma_x
sx = np.array([[0, 1], [1, 0]], dtype=complex)
print("<sx> pure =", np.real(np.trace(rho_pure @ sx)))  # +1.0 (coherent)
print("<sx> mix  =", np.real(np.trace(rho_mix  @ sx)))  # 0.0  (no coherence)

# --- Bell state and the partial trace ---
bell = (np.kron(ket0, ket0) + np.kron(ket1, ket1)) / np.sqrt(2)
rho_ab = dm(bell)                                      # pure, 4x4

def partial_trace_B(rho4):                             # trace out qubit B
    r = rho4.reshape(2, 2, 2, 2)                       # a,b,a',b'
    return np.trace(r, axis1=1, axis2=3)               # sum over b=b'

rho_a = partial_trace_B(rho_ab)
print("rho_A =\n", np.round(rho_a, 3))                 # I/2
print("purity(rho_AB) =", purity(rho_ab))             # 1.0 (whole is pure)
print("purity(rho_A)  =", purity(rho_a))              # 0.5 (part is mixed!)
print("entanglement S =", vn_entropy(rho_a))          # 0.693 = ln 2

Where the density matrix shows up

  • Quantum information. Noisy qubits, quantum channels, fidelity, and error correction are all defined on density matrices — a physical qubit is almost never a clean ket.
  • Decoherence theory. The environment-induced diagonalization of ρ explains the quantum-to-classical transition without collapse.
  • Quantum statistical mechanics. The thermal state ρ = e^(−H/k_BT)/Z is the workhorse of finite-temperature quantum physics.
  • Quantum optics. Unpolarized light, thermal light, and the states produced by lasers are naturally mixed and described by ρ.
  • NMR and spin ensembles. Bulk magnetic resonance works entirely with the spin density matrix and its T₁/T₂ relaxation.
  • Entanglement measures. Entanglement entropy S(ρ_A), negativity, and concurrence are all functions of reduced density matrices.
  • Black-hole thermodynamics. The entanglement entropy of quantum fields across a horizon is a von Neumann entropy of a reduced density matrix.

Common misconceptions

  • Confusing a superposition with a mixture. (|0⟩+|1⟩)/√2 is a pure state (purity 1, S = 0, has coherences). A 50/50 mixture of |0⟩ and |1⟩ is mixed (purity ½, S = ln 2, no coherences). Same populations, entirely different physics.
  • Thinking ρ is unique to its ensemble. The decomposition ρ = Σ p_i |ψ_i⟩⟨ψ_i| is not unique — many different ensembles give the same ρ, and no measurement can tell them apart. Only ρ itself is physical.
  • Assuming a subsystem always has a wavefunction. If A is entangled with B, subsystem A has no pure state — only a reduced density matrix. Insisting on a ket for A is simply wrong.
  • Forgetting the trace is basis-independent. ⟨A⟩ = Tr(ρA) gives the same number in every basis; picking a "convenient" basis never changes a prediction.
  • Treating decoherence as collapse. Decoherence suppresses off-diagonal coherences via entanglement with the environment; globally the evolution stays unitary. It explains classicality without a measurement postulate.
  • Reading off-diagonal elements as populations. Only the diagonal ρ_nn are probabilities. The off-diagonal ρ_mn are complex phase relationships and can even be negative or imaginary.

Frequently asked questions

What is the difference between a pure state and a mixed state?

A pure state can be written as a single ket |ψ⟩, so its density matrix ρ = |ψ⟩⟨ψ| is a rank-1 projector with ρ² = ρ and purity Tr(ρ²) = 1. A mixed state is a classical statistical mixture of pure states, ρ = Σ p_i |ψ_i⟩⟨ψ_i| with probabilities p_i > 0 summing to 1, and its purity satisfies Tr(ρ²) < 1. The key point: a mixed state reflects genuine ignorance about which pure state the system is in, whereas a superposition is still a single, fully specified pure state.

Why do we need the density matrix instead of just the wavefunction?

A wavefunction |ψ⟩ only describes a pure state — a system in a definite, fully-known quantum state. The density matrix ρ also handles statistical mixtures (thermal states, unpolarized beams, noisy qubits) and, crucially, the state of a subsystem that is entangled with its environment. When you take the partial trace over the unobserved part of an entangled system, the remaining subsystem generally has no wavefunction at all — only a reduced density matrix. Open quantum systems, decoherence, and quantum information theory are impossible to describe without ρ.

What do the off-diagonal elements of a density matrix mean?

In a chosen basis, the diagonal elements ρ_nn are the populations — the probabilities of finding the system in each basis state — and they sum to 1 because Tr(ρ) = 1. The off-diagonal elements ρ_mn (m ≠ n) are the coherences; they encode the definite phase relationship between basis states that makes interference possible. A pure superposition has large coherences; decoherence drives them exponentially to zero, ρ_mn(t) = ρ_mn(0) e^(-t/T₂), leaving a diagonal (classical) mixture with no interference.

How do you calculate an expectation value from a density matrix?

For any observable represented by the Hermitian operator A, the expectation value is ⟨A⟩ = Tr(ρA), the trace of the product of the density matrix and the operator. This single formula works for both pure and mixed states. For a pure state ρ = |ψ⟩⟨ψ| it reduces to the familiar ⟨A⟩ = ⟨ψ|A|ψ⟩. Because Tr is basis-independent, you get the same answer in any representation, which makes Tr(ρA) the universal recipe for predicting measurement averages.

What is purity and what does Tr(ρ²) tell you?

Purity is P = Tr(ρ²). It equals 1 for a pure state and drops below 1 for any mixed state. For a d-dimensional system it is bounded by 1/d ≤ Tr(ρ²) ≤ 1, with the lower limit 1/d reached only by the maximally mixed state ρ = I/d, which represents complete ignorance. For a single qubit, purity ranges from 1/2 (center of the Bloch sphere) to 1 (surface), and it relates to the Bloch vector length r by Tr(ρ²) = (1 + r²)/2. Purity is the quick, basis-independent diagnostic of how mixed a state is.

What is the reduced density matrix and how does it reveal entanglement?

For a composite system AB, the reduced density matrix of subsystem A is ρ_A = Tr_B(ρ_AB), obtained by tracing out (summing over) subsystem B. If AB is in an entangled pure state, ρ_A comes out mixed — Tr(ρ_A²) < 1 — even though the whole is pure. That reduction of purity is the operational signature of entanglement. For the Bell state (|00⟩ + |11⟩)/√2, tracing out one qubit gives ρ_A = I/2, the maximally mixed state, so each qubit alone is completely random while the pair is perfectly correlated.

What is von Neumann entropy?

Von Neumann entropy is the quantum generalization of Gibbs/Shannon entropy: S(ρ) = -Tr(ρ ln ρ) = -Σ λ_i ln λ_i, where λ_i are the eigenvalues of ρ. It is zero for any pure state and maximal, S = ln d, for the maximally mixed state of a d-dimensional system. For a bipartite pure state, the von Neumann entropy of either reduced density matrix is the entanglement entropy — a rigorous measure of how entangled the two parts are. In thermodynamics one writes S = -k_B Tr(ρ ln ρ), recovering the Boltzmann constant k_B = 1.381 × 10⁻²³ J/K.