|q⟩ Bad Qubits

intermediate · Physics · Density Matrices & Mixed States

The Partial Trace

The partial trace is the operation that produces a subsystem's state from a joint state. It is the quantum generalization of marginalizing a joint probability distribution.

Definition on product operators

For an operator that factorizes, M=ABM = A \otimes B, the partial trace over the second system is defined by

TrB(AB)=ATr(B).\operatorname{Tr}_B(A\otimes B) = A\,\operatorname{Tr}(B).

It traces the BB factor down to a number and leaves the AA factor alone. Because every operator on HAHB\mathcal{H}_A\otimes\mathcal{H}_B is a linear combination of such product operators, this single rule plus linearity defines TrB\operatorname{Tr}_B on everything.

The index formula

In components, with the joint basis a,b|a,b\rangle,

(TrBρ)aa=bρ(a,b),(a,b)b=b=ba,bρa,b.\big(\operatorname{Tr}_B\rho\big)_{a a'} = \sum_b \rho_{(a,b),(a',b')}\Big|_{b'=b} = \sum_b \langle a,b|\rho|a',b\rangle.

You sum over the diagonal of the traced-out system while keeping the surviving system's indices open. Tracing out AA instead is symmetric: (TrAρ)bb=aa,bρa,b\big(\operatorname{Tr}_A\rho\big)_{b b'} = \sum_a \langle a,b|\rho|a,b'\rangle.

Key properties

Marginalization analogy

If ρ\rho were a classical joint distribution p(a,b)p(a,b) written as a diagonal matrix, the partial trace over BB would compute bp(a,b)=p(a)\sum_b p(a,b) = p(a) — the ordinary marginal. The partial trace is exactly this operation lifted to operators, where it also correctly handles the off-diagonal coherences that have no classical counterpart.

Try it

Build the product state ρAB=ρAρB\rho_{AB} = \rho_A\otimes\rho_B with ρA=diag(0.8,0.2)\rho_A = \operatorname{diag}(0.8, 0.2) and ρB=diag(0.5,0.5)\rho_B = \operatorname{diag}(0.5, 0.5) via the Kronecker product, then trace out BB and return the (0,0)(0,0) entry. It should return 0.80.8, recovering ρA\rho_A exactly.

Run your code to see the quantum state.

Sign in on the full site to ask questions and join the discussion.