The Density Operator

4 hours ~11 min read

The Density Operator

A pure state ψ|\psi\rangle is the most you can know about a quantum system — but it is not the most general thing you can have. The moment there is classical uncertainty about which state was prepared, or the moment you look at one half of an entangled pair, the ket description breaks down. The density operator ρ\rho repairs it: a single Hermitian, positive, unit-trace matrix that encodes every statistical prediction, pure or mixed. It is the true state object of quantum mechanics, and from Term 4 onward (noise, channels, error correction) it is the only one we use.

Learning Objectives

After this lesson you will be able to:

  1. Motivate the density operator from classical ensembles and from subsystems of entangled states.
  2. Define ρ=ipiψiψi\rho = \sum_i p_i|\psi_i\rangle\langle\psi_i| and prove it is Hermitian, positive semidefinite, and unit-trace — and that these three properties characterize valid states.
  3. Distinguish pure (ρ2=ρ\rho^2 = \rho, Trρ2=1\operatorname{Tr}\rho^2 = 1) from mixed (Trρ2<1\operatorname{Tr}\rho^2 < 1) states and compute the purity.
  4. Derive the expectation-value formula A=Tr(ρA)\langle A\rangle = \operatorname{Tr}(\rho A) and the evolution rule ρUρU\rho \to U\rho U^\dagger.
  5. Explain ensemble ambiguity: different ensembles can yield the same ρ\rho, and only ρ\rho is physically meaningful.

Intuition

Two genuinely different kinds of uncertainty live inside quantum mechanics, and the ket handles only one of them.

Quantum uncertainty (already in the ket). A pure state $|+\rangle = \tfrac1{\sqrt2}(|0\rangle + |1\rangle)hasadefinite,fullyspecifieddescription,yeta has a definite, fully-specified description, yet a Zmeasurementstillreturns-measurement still returns 0$ or 11 with probability 12\tfrac12 each. That randomness is intrinsic — the Born rule — and the ket captures it perfectly.

Classical uncertainty (the ket cannot hold it). Now suppose a (sloppy) lab sends you a qubit that is 0|0\rangle with probability 12\tfrac12 and 1|1\rangle with probability 12\tfrac12 — an honest coin flip deciding which state was prepared. This is not the same as +|+\rangle: there is no single ket that means "0|0\rangle or 1|1\rangle, I forget which." You cannot average kets (120+121\tfrac12|0\rangle + \tfrac12|1\rangle is not normalized, and choosing relative phases would smuggle in coherence that isn't there). We need an object that mixes probabilities of states, not amplitudes.

There is a second, deeper reason the ket fails — and it is not about a careless experimenter at all. Take the Bell state Φ+=12(00+11)|\Phi^+\rangle = \tfrac1{\sqrt2}(|00\rangle + |11\rangle), a perfectly definite pure state of two qubits. Ask: what is the state of qubit AA alone? It has no ket — qubit AA is not in any definite state, because its identity is entangled with BB. Yet AA still has well-defined measurement statistics (we will find they are completely random). Describing "one subsystem of an entangled whole" forces the same machinery as classical mixing.

The fix in both cases is to package an ensemble {(pi,ψi)}\{(p_i, |\psi_i\rangle)\} into one operator,

ρ  =  ipiψiψi, \rho \;=\; \sum_i p_i\,|\psi_i\rangle\langle\psi_i| ,

by averaging the projectors ψiψi|\psi_i\rangle\langle\psi_i| (which carry no spurious phases) with the classical probabilities pip_i. Everything you can measure will turn out to depend on the ensemble only through this ρ\rho — which is exactly why it, and not the list of kets, is the state.


Theory

Definition

Definition (density operator). Let {(pi,ψi)}\{(p_i, |\psi_i\rangle)\} be an ensemble: normalized states ψi|\psi_i\rangle (not necessarily orthogonal) prepared with probabilities pi0p_i \ge 0, ipi=1\sum_i p_i = 1. The associated density operator is

ρ  =  ipiψiψi. \rho \;=\; \sum_i p_i\,|\psi_i\rangle\langle\psi_i| .

The notation matches Appendix C: each ψiψi|\psi_i\rangle\langle\psi_i| is the rank-1 projector of 0.1.3, and ρ\rho is their probability-weighted convex combination. A pure state is the special case of a single term, ρ=ψψ\rho = |\psi\rangle\langle\psi|; any other case is mixed.

The three defining properties (and their proofs)

Three properties hold for every density operator, and — as we show afterward — they are also sufficient: any operator with these properties is the density operator of some ensemble. They are the density-matrix analog of "normalized ket."

Property 1 — Hermitian, ρ=ρ\rho^\dagger = \rho.

ρ=(ipiψiψi)=ipi(ψiψi)=ipiψiψi=ρ. \rho^\dagger = \Big(\sum_i p_i\,|\psi_i\rangle\langle\psi_i|\Big)^\dagger = \sum_i \overline{p_i}\,\big(|\psi_i\rangle\langle\psi_i|\big)^\dagger = \sum_i p_i\,|\psi_i\rangle\langle\psi_i| = \rho .

We used (ψψ)=ψψ(|\psi\rangle\langle\psi|)^\dagger = |\psi\rangle\langle\psi| from 0.1.3 E4 and the fact that pip_i is real, so pi=pi\overline{p_i} = p_i. ∎ Hermiticity guarantees a real spectrum and an orthonormal eigenbasis (spectral theorem, 0.1.5).

Property 2 — Positive semidefinite, ρ0\rho \succeq 0.

For any φ|\varphi\rangle,

φρφ=ipiφψiψiφ=ipiψiφ2    0, \langle\varphi|\rho|\varphi\rangle = \sum_i p_i\,\langle\varphi|\psi_i\rangle\langle\psi_i|\varphi\rangle = \sum_i p_i\,\big|\langle\psi_i|\varphi\rangle\big|^2 \;\ge\; 0 ,

since each pi0p_i \ge 0 and each ψiφ20|\langle\psi_i|\varphi\rangle|^2 \ge 0. By the characterization in 0.1.6, ρ0\rho \succeq 0, so all its eigenvalues are 0\ge 0. ∎ Physically these eigenvalues will be probabilities.

Property 3 — Unit trace, Trρ=1\operatorname{Tr}\rho = 1.

Using linearity and cyclicity of the trace (Appendix E §4), Tr(ψiψi)=ψiψi=1\operatorname{Tr}(|\psi_i\rangle\langle\psi_i|) = \langle\psi_i|\psi_i\rangle = 1 for each normalized ψi|\psi_i\rangle, so

Trρ=ipiTr(ψiψi)=ipiψiψi=ipi=1. \operatorname{Tr}\rho = \sum_i p_i\,\operatorname{Tr}\big(|\psi_i\rangle\langle\psi_i|\big) = \sum_i p_i\,\langle\psi_i|\psi_i\rangle = \sum_i p_i = 1 . \qquad \blacksquare

Theorem (these properties characterize states). An operator ρ\rho on H\mathcal H is the density operator of some ensemble iff ρ=ρ\rho = \rho^\dagger, ρ0\rho \succeq 0, and Trρ=1\operatorname{Tr}\rho = 1.

Proof of sufficiency. Suppose ρ\rho has the three properties. By the spectral theorem it has an orthonormal eigenbasis {vk}\{|v_k\rangle\} with real eigenvalues λk\lambda_k: ρ=kλkvkvk\rho = \sum_k \lambda_k|v_k\rangle\langle v_k|. Positivity forces λk0\lambda_k \ge 0, and unit trace forces kλk=Trρ=1\sum_k \lambda_k = \operatorname{Tr}\rho = 1. Hence {(λk,vk)}\{(\lambda_k, |v_k\rangle)\} is a valid ensemble (probabilities λk\lambda_k, orthonormal states), and it manifestly reproduces ρ\rho. ∎

The set of all such ρ\rho is convex: if ρ1,ρ2\rho_1,\rho_2 are states then so is λρ1+(1λ)ρ2\lambda\rho_1 + (1-\lambda)\rho_2 for λ[0,1]\lambda\in[0,1] (each property is preserved under convex combination — check trace and positivity termwise). The pure states are precisely the extreme points of this convex set: those that cannot be written as a nontrivial mixture. We make this precise next.

Pure vs. mixed

Definition. ρ\rho is pure if ρ=ψψ\rho = |\psi\rangle\langle\psi| for some normalized ψ|\psi\rangle; otherwise it is mixed.

The idempotence test. A density operator is pure iff ρ2=ρ\rho^2 = \rho.

Proof. (\Rightarrow) If ρ=ψψ\rho = |\psi\rangle\langle\psi| with ψψ=1\langle\psi|\psi\rangle = 1, then ρ2=ψψψψ=ψψ=ρ\rho^2 = |\psi\rangle\langle\psi|\psi\rangle\langle\psi| = |\psi\rangle\langle\psi| = \rho. (\Leftarrow) If ρ2=ρ\rho^2 = \rho, then ρ\rho is a Hermitian projector (0.1.6), so its eigenvalues are 00 or 11. Unit trace means exactly one eigenvalue is 11 and the rest are 00, i.e. ρ=vv\rho = |v\rangle\langle v| for that eigenvector — pure. ∎

The purity functional. Define the purity

  γ(ρ):=Tr(ρ2)=kλk2   \boxed{\;\gamma(\rho) := \operatorname{Tr}(\rho^2) = \sum_k \lambda_k^2\;}

where λk\lambda_k are the eigenvalues of ρ\rho. Because the λk0\lambda_k \ge 0 form a probability distribution (kλk=1\sum_k\lambda_k = 1), purity is a measure of how peaked that distribution is:

Purity bounds. For a state on a dd-dimensional space,

1d    Tr(ρ2)    1, \tfrac1d \;\le\; \operatorname{Tr}(\rho^2) \;\le\; 1,

with Tr(ρ2)=1\operatorname{Tr}(\rho^2) = 1 iff ρ\rho is pure, and Tr(ρ2)=1/d\operatorname{Tr}(\rho^2) = 1/d iff ρ=I/d\rho = I/d is maximally mixed.

Proof. Among probability distributions (λk)(\lambda_k) on dd outcomes, kλk2\sum_k\lambda_k^2 is maximized when all weight sits on one outcome (giving 11) and minimized by the uniform distribution λk=1/d\lambda_k = 1/d (giving d(1/d)2=1/dd\cdot(1/d)^2 = 1/d). The maximum kλk2=1\sum_k\lambda_k^2 = 1 together with kλk=1\sum_k\lambda_k = 1 and λk[0,1]\lambda_k\in[0,1] forces a single λk=1\lambda_k = 1 — exactly the pure case, matching ρ2=ρ\rho^2 = \rho. The minimum forces uniform eigenvalues, i.e. ρ=I/d\rho = I/d. (Formally, by Cauchy–Schwarz / Jensen, kλk21d(kλk)2=1d\sum_k\lambda_k^2 \ge \tfrac1d(\sum_k\lambda_k)^2 = \tfrac1d.) ∎

So purity slides from 11 (a sharp ket) down to 1/d1/d (total ignorance). It is the workhorse scalar diagnostic for "how mixed is this state," and in Lesson 3 we will see it is a clean quadratic in the Bloch vector for a qubit.

Expectation values from ρ\rho

The whole point of ρ\rho is that it predicts measurement statistics. Recall (1.1.2) that for a pure state the expectation of an observable A=AA = A^\dagger is $\langle A\rangle = \langle\psi|A|\psi\rangle$. For an ensemble, average over the classical uncertainty:

A  =  ipiψiAψi. \langle A\rangle \;=\; \sum_i p_i\,\langle\psi_i|A|\psi_i\rangle .

Now convert each term to a trace using the "trace trick" of 0.1.3 E5, ψiAψi=Tr(Aψiψi)\langle\psi_i|A|\psi_i\rangle = \operatorname{Tr}(A|\psi_i\rangle\langle\psi_i|):

A=ipiTr ⁣(Aψiψi)=Tr ⁣(Aipiψiψi)=Tr(Aρ). \langle A\rangle = \sum_i p_i\,\operatorname{Tr}\!\big(A\,|\psi_i\rangle\langle\psi_i|\big) = \operatorname{Tr}\!\Big(A\sum_i p_i|\psi_i\rangle\langle\psi_i|\Big) = \operatorname{Tr}(A\rho) .   A=Tr(ρA)=Tr(Aρ)   \boxed{\;\langle A\rangle = \operatorname{Tr}(\rho A) = \operatorname{Tr}(A\rho)\;}

(the two forms agree by cyclicity of the trace). This single formula subsumes the pure-state Born rule and is the computational definition of measurement in the density-matrix formalism. In particular, the probability of a projective outcome with projector PkP_k is Tr(ρPk)\operatorname{Tr}(\rho P_k), since PkP_k is itself an observable with eigenvalue 11 on its subspace.

Notice the formula depends on the ensemble only through the combination $\rho = \sum_i p_i|\psi_i\rangle\langle\psi_i|.Twoensembleswiththesame. Two ensembles with the same \rho$ are operationally indistinguishable — there is no measurement that tells them apart. This is not a deficiency of our tools; it is a statement about nature, and it has a name.

Ensemble ambiguity

Different ensembles can give the same ρ\rho. The map (ensemble) ρ\to \rho is many-to-one, and only ρ\rho is observable.

The cleanest example is the maximally mixed qubit ρ=12I\rho = \tfrac12 I. It arises from at least two physically distinct preparation stories:

1200+1211coin flip in Z basis=12(1000)+12(0001)=12I, \underbrace{\tfrac12|0\rangle\langle0| + \tfrac12|1\rangle\langle1|}_{\text{coin flip in }Z\text{ basis}} = \tfrac12\begin{pmatrix}1&0\\0&0\end{pmatrix} + \tfrac12\begin{pmatrix}0&0\\0&1\end{pmatrix} = \tfrac12 I, 12+++12coin flip in X basis=1212(1111)+1212(1111)=12I. \underbrace{\tfrac12|+\rangle\langle+| + \tfrac12|-\rangle\langle-|}_{\text{coin flip in }X\text{ basis}} = \tfrac12\cdot\tfrac12\begin{pmatrix}1&1\\1&1\end{pmatrix} + \tfrac12\cdot\tfrac12\begin{pmatrix}1&-1\\-1&1\end{pmatrix} = \tfrac12 I.

One lab flipped a coin and prepared 0|0\rangle or 1|1\rangle; another flipped a coin and prepared +|+\rangle or |-\rangle. No experiment can distinguish their qubits, because $\langle A\rangle = \operatorname{Tr}(\rho A)dependsonlyon depends only on \rho = \tfrac12 I$. The list of kets is, in this sense, more information than physics provides — the density operator is the right, gauge-invariant object.

When do two ensembles give the same ρ\rho? The precise answer is the unitary freedom of ensembles (the Hughston–Jozsa–Wootters / Schrödinger theorem, [NC §2.4]): ensembles {piψi}\{\sqrt{p_i}|\psi_i\rangle\} and {qjϕj}\{\sqrt{q_j}|\phi_j\rangle\} generate the same ρ\rho iff their (sub-normalized) vectors are related by a unitary (padding the shorter list with zero vectors). We state it here and prove the qubit case in the exercises; the general proof rides on the partial trace and purification of Lesson 2.

Evolution: ρUρU\rho \to U\rho U^\dagger

Closed-system (unitary) evolution of a ket is ψUψ|\psi\rangle \to U|\psi\rangle (0.1.6). Push this through the ensemble. Each pure component evolves as

ψiψi    (Uψi)(Uψi)=UψiψiU, |\psi_i\rangle\langle\psi_i| \;\longrightarrow\; \big(U|\psi_i\rangle\big)\big(U|\psi_i\rangle\big)^\dagger = U|\psi_i\rangle\langle\psi_i|U^\dagger ,

and the classical probabilities pip_i are untouched (unitary evolution does not alter which state was prepared), so by linearity

  ρ    UρU   \boxed{\;\rho \;\longrightarrow\; U\rho U^\dagger\;}

This is the von Neumann picture of evolution. Differentiating U=eiHtU = e^{-iHt} (Appendix E §3, =1\hbar = 1) gives the von Neumann equation ρ˙=i[H,ρ]\dot\rho = -i[H,\rho] — the density-matrix form of Schrödinger's equation, developed in Term 1.6. Two sanity checks: this map preserves the three defining properties (Hermiticity, positivity, trace — since $\operatorname{Tr}(U\rho U^\dagger) = \operatorname{Tr}(\rho U^\dagger U) = \operatorname{Tr}\rho$ by cyclicity), and it preserves purity ($\operatorname{Tr}((U\rho U^\dagger)^2) = \operatorname{Tr}(U\rho^2 U^\dagger) = \operatorname{Tr}\rho^2$). Unitary evolution can never turn a pure state mixed — that requires the non-unitary channels of Term 4.


Worked Examples

Example 1 — Pure +|+\rangle vs. a 50/50 classical mix: same diagonal, different state

Build both density matrices and separate them with purity and an XX-measurement.

Pure state +=12(0+1)|+\rangle = \tfrac1{\sqrt2}(|0\rangle + |1\rangle):

ρ+=++=12(0+1)(0+1)=12(1111). \rho_+ = |+\rangle\langle+| = \tfrac12(|0\rangle+|1\rangle)(\langle0|+\langle1|) = \tfrac12\begin{pmatrix}1 & 1\\ 1 & 1\end{pmatrix}.

Classical 50/50 mix of 0|0\rangle and 1|1\rangle:

ρmix=1200+1211=12(1001)=12I. \rho_{\text{mix}} = \tfrac12|0\rangle\langle0| + \tfrac12|1\rangle\langle1| = \tfrac12\begin{pmatrix}1 & 0\\ 0 & 1\end{pmatrix} = \tfrac12 I .

Both have the same diagonal (12,12\tfrac12,\tfrac12): a ZZ-measurement gives 00 or 11 equally for each, so ZZ alone cannot tell them apart. The off-diagonal coherences differ, and that is where the physics hides.

Purity. $\operatorname{Tr}(\rho_+^2) = \operatorname{Tr}!\big(\tfrac14\begin{psmallmatrix}2&2\2&2\end{psmallmatrix}\big) = \tfrac14(2+2) = 1pure. — pure. \operatorname{Tr}(\rho_{\text{mix}}^2) = \operatorname{Tr}(\tfrac14 I) = \tfrac12 = 1/d$ — maximally mixed.

An XX-measurement separates them. With X = \begin{psmallmatrix}0&1\\1&0\end{psmallmatrix},

X+=Tr(ρ+X)=Tr ⁣(12(1111)(0110))=Tr ⁣(12(1111))=1, \langle X\rangle_{+} = \operatorname{Tr}(\rho_+ X) = \operatorname{Tr}\!\Big(\tfrac12\begin{pmatrix}1&1\\1&1\end{pmatrix}\begin{pmatrix}0&1\\1&0\end{pmatrix}\Big) = \operatorname{Tr}\!\Big(\tfrac12\begin{pmatrix}1&1\\1&1\end{pmatrix}\Big) = 1, Xmix=Tr(12IX)=12Tr(X)=0. \langle X\rangle_{\text{mix}} = \operatorname{Tr}(\tfrac12 I\,X) = \tfrac12\operatorname{Tr}(X) = 0 .

The pure +|+\rangle is a definite +1+1 eigenstate of XX (X=1\langle X\rangle = 1); the mix is utterly random in every basis (X=0\langle X\rangle = 0). The coherence in ρ+\rho_+ is physically real and measurable — it just doesn't show up in the ZZ basis.

Example 2 — Expectation and purity of a biased single-basis mix

Let \rho = \tfrac34|0\rangle\langle0| + \tfrac14|1\rangle\langle1| = \begin{psmallmatrix}3/4 & 0\\ 0 & 1/4\end{psmallmatrix} (diagonal, so already in its eigenbasis with λ=34,14\lambda = \tfrac34, \tfrac14).

Trace check: 34+14=1\tfrac34 + \tfrac14 = 1. ✓ Positivity: eigenvalues 34,140\tfrac34,\tfrac14 \ge 0. ✓

Expectation of Z=diag(1,1)Z = \operatorname{diag}(1,-1):

Z=Tr(ρZ)=34(1)+14(1)=12. \langle Z\rangle = \operatorname{Tr}(\rho Z) = \tfrac34(1) + \tfrac14(-1) = \tfrac12 .

(Equivalently, P(0)P(1)=3414=12P(0) - P(1) = \tfrac34 - \tfrac14 = \tfrac12.)

Expectation of XX: $\rho X = \begin{psmallmatrix}3/4&0\0&1/4\end{psmallmatrix}\begin{psmallmatrix}0&1\1&0\end{psmallmatrix} = \begin{psmallmatrix}0&3/4\1/4&0\end{psmallmatrix},whichistraceless,so, which is traceless, so \langle X\rangle = 0$.

Purity: $\operatorname{Tr}(\rho^2) = (\tfrac34)^2 + (\tfrac14)^2 = \tfrac{9}{16} + \tfrac1{16} = \tfrac{10}{16} = \tfrac58 = 0.625.Since. Since 1/2 < 0.625 < 1$, this is a genuinely mixed state — more ordered than maximally mixed, less than pure. We will read this same number off the Bloch vector r=(0,0,12)\vec r = (0,0,\tfrac12) via $\operatorname{Tr}\rho^2 = \tfrac12(1 + |\vec r|^2) = \tfrac12(1 + \tfrac14) = \tfrac58$ in Lesson 3.


Hands-on (Python)

We build pure and mixed density matrices, verify the defining properties, compute expectations via Tr(ρA)\operatorname{Tr}(\rho A), measure purity, and exhibit ensemble ambiguity. NumPy is the natural home for density matrices — they are just Hermitian arrays.

import numpy as np

# --- Pauli matrices and computational basis (Appendix E) ---
I = np.eye(2, dtype=complex)
X = np.array([[0, 1], [1, 0]], dtype=complex)
Y = np.array([[0, -1j], [1j, 0]], dtype=complex)
Z = np.array([[1, 0], [0, -1]], dtype=complex)
ket0 = np.array([[1], [0]], dtype=complex)
ket1 = np.array([[0], [1]], dtype=complex)

def proj(ket):
    """Rank-1 projector |ψ⟩⟨ψ| from a column ket (assumed normalized)."""
    return ket @ ket.conj().T

def density_from_ensemble(probs, kets):
    """ρ = Σ_i p_i |ψ_i⟩⟨ψ_i| for probabilities `probs` and column kets `kets`."""
    return sum(p * proj(k) for p, k in zip(probs, kets))

# Pure |+⟩ vs. classical 50/50 mix of |0⟩,|1⟩ (Worked Example 1)
plus = (ket0 + ket1) / np.sqrt(2)
rho_pure = proj(plus)
rho_mix  = density_from_ensemble([0.5, 0.5], [ket0, ket1])

print("rho_pure =\n", np.round(rho_pure, 3))
print("rho_mix  =\n", np.round(rho_mix, 3))
# rho_pure has off-diagonal 0.5 coherences; rho_mix is diag(0.5, 0.5) = I/2.
def is_valid_state(rho, tol=1e-9):
    """Check the three defining properties: Hermitian, PSD, unit trace."""
    hermitian = np.allclose(rho, rho.conj().T, atol=tol)
    eigs = np.linalg.eigvalsh((rho + rho.conj().T) / 2)   # symmetrize for safety
    psd = np.all(eigs >= -tol)
    unit_trace = np.isclose(np.trace(rho).real, 1.0, atol=tol)
    return hermitian and psd and unit_trace

for name, rho in [("pure", rho_pure), ("mix", rho_mix)]:
    print(name, "valid state?", is_valid_state(rho))   # both True

def expectation(rho, A):
    """⟨A⟩ = Tr(ρ A); real for Hermitian A."""
    return np.trace(rho @ A).real

def purity(rho):
    """Tr(ρ²) ∈ [1/d, 1]; equals 1 iff pure."""
    return np.trace(rho @ rho).real

# ⟨X⟩ separates the two states even though ⟨Z⟩ does not:
print("⟨Z⟩ pure/mix:", expectation(rho_pure, Z), expectation(rho_mix, Z))  # 0.0 0.0
print("⟨X⟩ pure/mix:", expectation(rho_pure, X), expectation(rho_mix, X))  # 1.0 0.0
print("purity pure/mix:", purity(rho_pure), purity(rho_mix))               # 1.0 0.5
# Ensemble ambiguity: two different ensembles, identical ρ = I/2.
plus  = (ket0 + ket1) / np.sqrt(2)
minus = (ket0 - ket1) / np.sqrt(2)

rho_Z = density_from_ensemble([0.5, 0.5], [ket0, ket1])     # Z-basis coin flip
rho_X = density_from_ensemble([0.5, 0.5], [plus, minus])    # X-basis coin flip
print("Same operator?", np.allclose(rho_Z, rho_X))          # True  -> indistinguishable
print(np.round(rho_X, 3))                                   # I/2

# Unitary evolution ρ → U ρ U†: a pure state stays pure, a mix stays mixed.
from scipy.linalg import expm
H_gate = np.array([[1, 1], [1, -1]], dtype=complex) / np.sqrt(2)   # Hadamard (a unitary)
print("purity after H (pure):", purity(H_gate @ rho_pure @ H_gate.conj().T))  # 1.0
print("purity after H (mix): ", purity(H_gate @ rho_mix  @ H_gate.conj().T))  # 0.5
# H rotates |+⟩ to |0⟩ (still pure); I/2 is invariant under any unitary.

Numerical note. Density matrices accumulate tiny imaginary parts and sub-zero eigenvalues from floating-point error. Take .real of expectations/purities (the exact values are real), and symmetrize with (ρ + ρ†)/2 before calling eigvalsh, as is_valid_state does. This is the same hygiene Term 4's noise simulations rely on.


Exercises

E1 (easy). Write the density matrix for the ensemble "0|0\rangle with probability 13\tfrac13, +|+\rangle with probability 23\tfrac23" as an explicit 2×22\times2 matrix, and verify Trρ=1\operatorname{Tr}\rho = 1.

Solution

|0\rangle\langle0| = \begin{psmallmatrix}1&0\\0&0\end{psmallmatrix} and $|+\rangle\langle+| = \tfrac12\begin{psmallmatrix}1&1\1&1\end{psmallmatrix}$. So

ρ=13(1000)+2312(1111)=(13+13131313)=(23131313). \rho = \tfrac13\begin{pmatrix}1&0\\0&0\end{pmatrix} + \tfrac23\cdot\tfrac12\begin{pmatrix}1&1\\1&1\end{pmatrix} = \begin{pmatrix}\tfrac13 + \tfrac13 & \tfrac13\\[2pt] \tfrac13 & \tfrac13\end{pmatrix} = \begin{pmatrix}\tfrac23 & \tfrac13\\[2pt] \tfrac13 & \tfrac13\end{pmatrix}.

Trace =23+13=1= \tfrac23 + \tfrac13 = 1. ✓ (Hermitian and, since both diagonal entries are \ge the off-diagonal in the right way, one checks det=2919=190\det = \tfrac29 - \tfrac19 = \tfrac19 \ge 0 with positive trace, so PSD — it is a valid state.)

E2 (easy). Show directly from the matrices that ρ=++\rho = |+\rangle\langle+| satisfies $\rho^2 = \rho,while, while \rho = \tfrac12 I$ does not. What does each conclude about purity?

Solution

|+\rangle\langle+| = \tfrac12\begin{psmallmatrix}1&1\\1&1\end{psmallmatrix}, and $\big(\tfrac12\begin{psmallmatrix}1&1\1&1\end{psmallmatrix}\big)^2 = \tfrac14\begin{psmallmatrix}2&2\2&2\end{psmallmatrix} = \tfrac12\begin{psmallmatrix}1&1\1&1\end{psmallmatrix}equal,so — equal, so \rho^2 = \rho$: pure. For 12I\tfrac12 I, (12I)2=14I12I(\tfrac12 I)^2 = \tfrac14 I \ne \tfrac12 I: not idempotent, so mixed. Purities: Tr(ρ2)=1\operatorname{Tr}(\rho^2) = 1 vs. Tr(14I)=12\operatorname{Tr}(\tfrac14 I) = \tfrac12.

E3 (medium). Prove that A=Tr(ρA)\langle A\rangle = \operatorname{Tr}(\rho A) is real whenever AA is Hermitian, directly from properties of ρ\rho and AA (do not assume ρ\rho is pure).

Solution

$\overline{\operatorname{Tr}(\rho A)} = \operatorname{Tr}\big((\rho A)^\dagger\big) = \operatorname{Tr}(A^\dagger\rho^\dagger) = \operatorname{Tr}(A\rho) = \operatorname{Tr}(\rho A),using, using \overline{\operatorname{Tr}(M)} = \operatorname{Tr}(M^\dagger),then, then A^\dagger = A,, \rho^\dagger = \rho$, and cyclicity of the trace. A number equal to its own conjugate is real. ∎

E4 (medium). Let ρ=p00+(1p)11\rho = p\,|0\rangle\langle0| + (1-p)\,|1\rangle\langle1| for p[0,1]p\in[0,1]. Compute Tr(ρ2)\operatorname{Tr}(\rho^2) as a function of pp, find where it is minimized and maximized, and interpret.

Solution

ρ=diag(p,1p)\rho = \operatorname{diag}(p, 1-p), so $\operatorname{Tr}(\rho^2) = p^2 + (1-p)^2 = 1 - 2p(1-p) = 2p^2 - 2p + 1.Minimizing:. Minimizing: \frac{d}{dp}(2p^2 - 2p + 1) = 4p - 2 = 0 \Rightarrow p = \tfrac12$, giving purity 12\tfrac12 — the maximally mixed qubit. Maxima at the endpoints p=0p = 0 or p=1p = 1, giving purity 11 — the pure states 1|1\rangle or 0|0\rangle. Purity is a downward parabola in pp: most mixed at the fair coin, pure at the certain outcomes.

E5 (hard). Prove that a density operator ρ\rho is pure iff Tr(ρ2)=1\operatorname{Tr}(\rho^2) = 1 (closing the loop with the ρ2=ρ\rho^2 = \rho test).

Solution

Diagonalize ρ=kλkvkvk\rho = \sum_k\lambda_k|v_k\rangle\langle v_k| with λk0\lambda_k\ge0, kλk=1\sum_k\lambda_k = 1. Then Tr(ρ2)=kλk2\operatorname{Tr}(\rho^2) = \sum_k\lambda_k^2. Since 0λk10\le\lambda_k\le1 we have $\lambda_k^2\le \lambda_k,so, so \sum_k\lambda_k^2 \le \sum_k\lambda_k = 1,withequalityiff, with equality **iff** \lambda_k^2 = \lambda_k$ for every kk, i.e. each λk{0,1}\lambda_k\in\{0,1\}. Combined with kλk=1\sum_k\lambda_k = 1, exactly one λk=1\lambda_k = 1 and the rest vanish, so ρ=vkvk\rho = |v_k\rangle\langle v_k| is pure. Conversely a pure ρ\rho has eigenvalues (1,0,)(1,0,\dots) giving Tr(ρ2)=1\operatorname{Tr}(\rho^2) = 1. ∎

E6 (hard). (Unitary freedom, qubit case.) Two qubit ensembles {(12,0),(12,1)}\{(\tfrac12,|0\rangle),(\tfrac12,|1\rangle)\} and {(12,+),(12,)}\{(\tfrac12,|+\rangle),(\tfrac12,|-\rangle)\} both give ρ=12I\rho = \tfrac12 I. Exhibit a 2×22\times2 unitary VV relating the (sub-normalized) state vectors {piψi}\{\sqrt{p_i}|\psi_i\rangle\} of the two ensembles, confirming the HJW theorem in this case.

Solution

The sub-normalized vectors are a~0=120|\tilde a_0\rangle = \tfrac1{\sqrt2}|0\rangle, $|\tilde a_1\rangle = \tfrac1{\sqrt2}|1\rangleforthefirstensemble,and for the first ensemble, and |\tilde b_0\rangle = \tfrac1{\sqrt2}|+\rangle$, b~1=12|\tilde b_1\rangle = \tfrac1{\sqrt2}|-\rangle for the second. HJW asks for unitary V=(Vji)V = (V_{ji}) with b~j=iVjia~i|\tilde b_j\rangle = \sum_i V_{ji}|\tilde a_i\rangle. Writing $|+\rangle = \tfrac1{\sqrt2}(|0\rangle + |1\rangle),, |-\rangle = \tfrac1{\sqrt2}(|0\rangle - |1\rangle)gives gives \tfrac1{\sqrt2}|+\rangle = \tfrac1{\sqrt2}\big(\tfrac1{\sqrt2}|0\rangle + \tfrac1{\sqrt2}|1\rangle\big) = \tfrac1{\sqrt2}|\tilde a_0\rangle

  • \tfrac1{\sqrt2}|\tilde a_1\rangleandsimilarlyfor and similarly for |-\rangle$. SoV=12(1111)=H, V = \tfrac1{\sqrt2}\begin{pmatrix}1 & 1\\ 1 & -1\end{pmatrix} = H, the Hadamard, which is unitary. The same Hadamard that maps the ZZ basis to the XX basis maps one ensemble's vectors to the other's — making ρ=12I\rho = \tfrac12 I from either. ∎

Checkpoint

  1. Give two physically distinct situations that require a density operator rather than a ket.
  2. State the three properties that characterize a valid density operator, and which one encodes "probabilities sum to 1."
  3. How do you test whether ρ\rho is pure, two different ways?
  4. Derive A=Tr(ρA)\langle A\rangle = \operatorname{Tr}(\rho A) from the ensemble average. Why does it imply ensemble ambiguity?
  5. Write the evolution rule for ρ\rho under a unitary UU, and argue it preserves purity.
Answers
  1. (i) Classical uncertainty about which pure state was prepared (an ensemble / "noisy preparation"); (ii) a subsystem of an entangled pure state, which has no ket of its own (Lesson 2).
  2. ρ=ρ\rho^\dagger = \rho (Hermitian, real spectrum), ρ0\rho\succeq0 (positive, eigenvalues are probabilities), Trρ=1\operatorname{Tr}\rho = 1 — the last encodes "probabilities sum to 1."
  3. ρ2=ρ\rho^2 = \rho (idempotent ⇔ pure), or equivalently Tr(ρ2)=1\operatorname{Tr}(\rho^2) = 1 (purity =1= 1).
  4. $\langle A\rangle = \sum_i p_i\langle\psi_i|A|\psi_i\rangle = \sum_i p_i\operatorname{Tr}(A|\psi_i\rangle\langle\psi_i|) = \operatorname{Tr}(A\rho).Sinceeveryexpectationdependsontheensembleonlythrough. Since every expectation depends on the ensemble only through \rho$, two ensembles with the same ρ\rho produce identical statistics for all AA — indistinguishable.
  5. ρUρU\rho\to U\rho U^\dagger. Purity is invariant: $\operatorname{Tr}((U\rho U^\dagger)^2) = \operatorname{Tr}(U\rho^2U^\dagger) = \operatorname{Tr}(\rho^2)$ by cyclicity, so pure stays pure and mixing requires non-unitary dynamics (Term 4).

Further Reading

  • [NC] Nielsen & Chuang, §2.4 — the density operator, ensembles, and the unitary-freedom theorem (their §2.4.3 is the HJW result used in E6).
  • [Pre] Preskill, Ph219, Ch. 2–3 — density operators and the physics of mixed states.
  • [Wat] Watrous, Theory of Quantum Information, Ch. 2 — density operators as the state objects of quantum information, with full rigor.
  • Appendix E §1, §4 — Pauli/trace identities used throughout.

← Prev: Schmidt Decomposition · Up: Term 1 · Next: Partial Trace & Reduced States

Ready to measure your state?

6 exercises · 10 checkpoint questions

Start the quiz