Week 10 | Block III begins: states we only partly know, halves of entangled pairs, and the mathematics of noise | reading: Watrous Ch. 9–10 (density matrices, channels)
Every result in Blocks I and II assumed perfect gates and perfectly known states. Real devices are noisy (Lecture 17's resource estimates were all about that), and we often know a state only statistically. This lecture introduces the language for both situations. By the end you should be able to build the density matrix of an ensemble and use it to predict measurements, decide whether a state is pure, locate it in the Bloch ball, compute a reduced state with the partial trace, apply a channel given its Kraus operators, and compute the trace distance and fidelity of two qubit states.
Classical ignorance. A source prepares \(|0\rangle\) with probability \(\tfrac34\) and \(|{-i}\rangle\) with probability \(\tfrac14\), and does not tell us which. No single vector \(|\psi\rangle\) describes what we hold: the probability of each outcome of any measurement is an average over the two possibilities, and that average is not the Born rule for any one state.
Entanglement. Alice holds one qubit of an entangled pair (Lecture 5). Her qubit on its own has no state vector at all, since the pair is not a product. Yet she can measure it, and her statistics must be described by something that refers to her qubit only.
Both situations are handled by one object, and the second turns out to be a special case of the first.
An ensemble is a list of states \(|\psi_k\rangle\) prepared with probabilities \(p_k\). Its density matrix is
$$\rho=\sum_kp_k\,|\psi_k\rangle\langle\psi_k| .$$A pure state \(|\psi\rangle\) has density matrix \(|\psi\rangle\langle\psi|\). For \(|\psi\rangle=\alpha|0\rangle+\beta|1\rangle\) this is the matrix \(\begin{pmatrix}|\alpha|^2&\alpha\bar\beta\\ \bar\alpha\beta&|\beta|^2\end{pmatrix}\).
The point of \(\rho\) is that it predicts every measurement. If we measure in an orthonormal basis \(\{|b\rangle\}\), the outcome \(b\) has probability \(\sum_kp_k|\langle b|\psi_k\rangle|^2\) (average over the ensemble, Born rule within each member), and \(|\langle b|\psi_k\rangle|^2=\langle b|\psi_k\rangle\langle\psi_k|b\rangle\). Summing,
$$P(b)=\langle b|\rho|b\rangle=\operatorname{tr}\big(\rho\,|b\rangle\langle b|\big).$$After a gate \(U\), each member becomes \(U|\psi_k\rangle\), so \(\rho\mapsto U\rho U^\dagger\). Since all predictions go through \(\rho\), two ensembles with the same density matrix cannot be told apart by any experiment: \(\rho\) is the state.
A source prepares \(|1\rangle\) with probability 0.6 and \(|{+i}\rangle\) with probability 0.4. The qubit is measured in the Y basis. What is the probability of the outcome \({+i}\)?
Every density matrix \(\rho\) is (a) Hermitian, (b) positive semidefinite, \(\langle v|\rho|v\rangle\ge0\) for all \(v\), and (c) of trace 1. Conversely, every matrix with (a)–(c) is the density matrix of some ensemble, for example of its eigenvectors weighted by its eigenvalues. Moreover \(\operatorname{tr}\rho^2\le1\), with equality exactly when \(\rho\) is pure.
(a) Each \(|\psi\rangle\langle\psi|\) is Hermitian and real combinations of Hermitian matrices are Hermitian. (b) \(\langle v|\rho|v\rangle=\sum_kp_k|\langle v|\psi_k\rangle|^2\ge0\). (c) \(\operatorname{tr}|\psi\rangle\langle\psi|=\langle\psi|\psi\rangle=1\), and the \(p_k\) sum to 1. Conversely, by the spectral theorem (Lecture 2) a Hermitian \(\rho\) equals \(\sum_j\lambda_j|e_j\rangle\langle e_j|\) with orthonormal \(|e_j\rangle\); (b) makes \(\lambda_j\ge0\) and (c) makes them sum to 1, so they are probabilities. Finally \(\operatorname{tr}\rho^2=\sum_j\lambda_j^2\le\sum_j\lambda_j=1\), with equality iff one \(\lambda_j\) is 1 and the rest 0, that is, iff \(\rho=|e_j\rangle\langle e_j|\) is pure.
The quantity \(\operatorname{tr}\rho^2\) is the purity. For a qubit it ranges from 1 (pure) down to \(\tfrac12\), reached only by \(I/2\), the maximally mixed state: a fair coin between \(|0\rangle\) and \(|1\rangle\), and equally between any two orthogonal states.
Which of these matrices is a density matrix?
Find \(\rho\) for the ensemble \(\{(\tfrac34,|0\rangle),(\tfrac14,|{-i}\rangle)\}\) of the cartoon, its purity and eigenvalues, and the probability of each outcome in the Z and Y bases.
With \(|{-i}\rangle\langle{-i}|=\tfrac12\begin{pmatrix}1&i\\ -i&1\end{pmatrix}\),
$$\rho=\frac34\begin{pmatrix}1&0\\[2pt] 0&0\end{pmatrix}+\frac18\begin{pmatrix}1&i\\[2pt] -i&1\end{pmatrix}=\begin{pmatrix}7/8&i/8\\[2pt] -i/8&1/8\end{pmatrix}.$$Purity: \(\operatorname{tr}\rho^2=\tfrac{49}{64}+\tfrac1{64}+2\cdot\tfrac1{64}=\tfrac{13}{16}\lt1\), so the state is mixed. The eigenvalues solve \(\lambda^2-\lambda+\det\rho=0\) with \(\det\rho=\tfrac7{64}-\tfrac1{64}=\tfrac3{32}\): \(\lambda=\tfrac12\big(1\pm\tfrac{\sqrt{10}}4\big)\approx0.895,\,0.105\). Measurements: \(P(0)=\rho_{00}=\tfrac78\). In the Y basis, \(P({+i})=\langle{+i}|\rho|{+i}\rangle=\tfrac38\) and \(P({-i})=\tfrac58\). (Check by averaging: \(P({-i})=\tfrac34\cdot\tfrac12+\tfrac14\cdot1=\tfrac58\).)
The off-diagonal entries of a density matrix are called coherences. A quick check of the definitions before reading on:
For \(\rho=\begin{pmatrix}1/2&-1/2\\ -1/2&1/2\end{pmatrix}\), the purity is \(\operatorname{tr}\rho^2=\) , so the state is .
Every qubit density matrix can be written uniquely as
$$\rho=\tfrac12\big(I+xX+yY+zZ\big),$$ $$\vec r=(x,y,z)=\big(\operatorname{tr}\rho X,\ \operatorname{tr}\rho Y,\ \operatorname{tr}\rho Z\big),$$ $$|\vec r|\le1 .$$The state is pure exactly when \(|\vec r|=1\) (on the sphere, matching Definition 3.3), its purity is \(\tfrac12(1+|\vec r|^2)\), and measuring along a unit vector \(\vec n\) gives \(+\) with probability \(\tfrac12(1+\vec r\cdot\vec n)\). The density matrix of an ensemble has the probability-weighted average of the members' Bloch vectors.
\(I,X,Y,Z\) form a basis of the \(2\times2\) Hermitian matrices, the coefficients are real for Hermitian \(\rho\), and \(\operatorname{tr}\rho=1\) fixes the coefficient of \(I\) at \(\tfrac12\). Since \(\operatorname{tr}(PQ)=2\delta_{PQ}\) for Paulis, \(\operatorname{tr}\rho X=x\), and so on. The eigenvalues of \(\vec r\cdot\vec\sigma\) are \(\pm|\vec r|\), so those of \(\rho\) are \(\tfrac12(1\pm|\vec r|)\): positivity is \(|\vec r|\le1\), and purity \(\sum\lambda^2=\tfrac12(1+|\vec r|^2)\). The projector onto \(+\vec n\) is \(\tfrac12(I+\vec n\cdot\vec\sigma)\), and \(\operatorname{tr}\big(\rho\,\tfrac12(I+\vec n\cdot\vec\sigma)\big)=\tfrac12(1+\vec r\cdot\vec n)\). Finally \(\rho\mapsto\vec r\) is linear, so mixtures average Bloch vectors.
Find the Bloch vector and the purity of \(\rho=\begin{pmatrix}0.7&0.2\\ 0.2&0.3\end{pmatrix}\).
Example 18.1 has \(\vec r=\tfrac34(0,0,1)+\tfrac14(0,-1,0)=(0,-\tfrac14,\tfrac34)\), of length \(\sqrt{10}/4\approx0.79\): inside the ball, on the chord from \(|0\rangle\) to \(|{-i}\rangle\), a quarter of the way along. Its purity \(\tfrac12(1+\tfrac{10}{16})=\tfrac{13}{16}\) agrees with the direct computation.
Tick every ensemble whose density matrix is \(I/2\).
Now the second situation. Let two qubits be in a state \(\rho_{AB}\) (pure or not), with \(A\) the left factor and \(B\) the right. What state describes \(A\) alone?
The reduced state of \(A\) is \(\rho_A=\operatorname{tr}_B\rho_{AB}\), defined on product operators by \(\operatorname{tr}_B(M\otimes N)=M\operatorname{tr}(N)\) and extended linearly. In components, \((\rho_A)_{ij}=\sum_k(\rho_{AB})_{ik,jk}\): sum over the matching indices of \(B\). For a pure two-qubit state with coefficient matrix \(C\) (Definition 5.6, rows indexed by \(A\)), \(\rho_A=CC^\dagger\) and \(\rho_B=(C^\dagger C)^{\mathsf T}\).
Two qubits are in \(\tfrac{\sqrt3}{2}|00\rangle+\tfrac12|11\rangle\) (kets \(|q_1q_0\rangle\)). Find the probability that measuring \(q_1\) alone gives 0, and the purity of \(\rho_{q_1}\).
For every observable or measurement on \(A\) alone, \(\operatorname{tr}\big(\rho_{AB}(M\otimes I)\big)=\operatorname{tr}(\rho_AM)\). So \(\rho_A\) predicts everything that can be learned by experiments on \(A\), and nothing done to \(B\) alone (any gate, any measurement whose result is not communicated) changes it.
The first identity is the definition, checked on products: \(\operatorname{tr}\big((P\otimes Q)(M\otimes I)\big)=\operatorname{tr}(PM)\operatorname{tr}(Q)=\operatorname{tr}\big(\operatorname{tr}_B(P\otimes Q)M\big)\), then linearity. For the second, a gate \(I\otimes U\) on \(B\) changes \(\rho_{AB}\) to \((I\otimes U)\rho_{AB}(I\otimes U^\dagger)\), and the cyclicity of the trace over \(B\) removes \(U\). A measurement on \(B\) with unknown outcome replaces \(\rho_{AB}\) by \(\sum_b(I\otimes\Pi_b)\rho_{AB}(I\otimes\Pi_b)\), and \(\sum_b\Pi_b=I\) gives the same \(\rho_A\).
In the same state \(\tfrac{\sqrt3}{2}|00\rangle+\tfrac12|11\rangle\), Bob measures \(q_0\) in the X basis and does not tell Alice the outcome. Alice's probability of getting 0 from \(q_1\) is now .
Let \(|\psi\rangle=\tfrac1{\sqrt3}\big(|00\rangle+|01\rangle+|11\rangle\big)\), kets \(|q_1q_0\rangle\). Find the reduced state of each qubit, its purity and its eigenvalues.
The coefficient matrix is \(C=\tfrac1{\sqrt3}\begin{pmatrix}1&1\\ 0&1\end{pmatrix}\) (rows: \(q_1\)). Then
$$\rho_{q_1}=CC^\dagger=\frac13\begin{pmatrix}2&1\\[2pt] 1&1\end{pmatrix},\qquad \rho_{q_0}=(C^\dagger C)^{\mathsf T}=\frac13\begin{pmatrix}1&1\\[2pt] 1&2\end{pmatrix}.$$Both have trace 1, determinant \(\tfrac19\) and purity \(\tfrac{4+1+1+1}{9}=\tfrac79\), and eigenvalues \(\tfrac{3\pm\sqrt5}{6}\approx0.873,\ 0.127\). These are the squares of the Schmidt coefficients of \(|\psi\rangle\) (Lecture 5): for a pure state of two parts, the two reduced states always have the same eigenvalues, and they are pure exactly when the state is a product. The less pure the halves, the more entangled the whole.
No signalling, made precise. Proposition 18.3 is the reason entanglement cannot transmit information. In teleportation (Lecture 8), before Alice's two bits arrive, Bob's qubit is in one of four states \(P|\psi\rangle\), \(P\in\{I,X,Z,XZ\}\), each with probability \(\tfrac14\), so his density matrix is \(\tfrac14\sum_PP\rho P^\dagger\). This average is \(I/2\) for every qubit state (HW10 Problem 1 asks you to show it): Bob holds a maximally mixed qubit, independent of \(|\psi\rangle\), until the classical bits tell him which correction to apply.
Noise is anything that happens to a qubit that is not a known unitary: a random gate error, leakage of information to the environment, energy loss. The most general physically allowed transformation of a state has a simple form.
A channel is a map
$$\Phi(\rho)=\sum_kK_k\,\rho\,K_k^\dagger\qquad\text{with}\qquad \sum_kK_k^\dagger K_k=I .$$The matrices \(K_k\) are its Kraus operators. The condition on the right guarantees that \(\Phi(\rho)\) has trace 1; \(\Phi(\rho)\) is automatically Hermitian and positive semidefinite.
One way to read the formula: with probability \(\operatorname{tr}(K_k\rho K_k^\dagger)\) the event \(k\) happens and the state becomes \(K_k\rho K_k^\dagger\) (normalised), and we do not learn which event happened. A unitary is a channel with one Kraus operator. "Measure in the standard basis and forget the result" has Kraus operators \(|0\rangle\langle0|\) and \(|1\rangle\langle1|\), and it kills the coherences.
Four channels describe most single-qubit noise. Each sends the Bloch ball into itself, and since \(\Phi\) is linear, it acts on Bloch vectors as an affine map \(\vec r\mapsto M\vec r+\vec c\): the ball becomes an ellipsoid.
The phase-flip channel with \(p=0.2\) acts on \(|+\rangle\). The result is then measured in the X basis. What is \(P(+)\)?
Every channel arises by letting the qubit interact unitarily with an environment that starts in a fixed state and then forgetting (tracing out) the environment; this is Stinespring's theorem. The simplest case: a CNOT from the qubit onto an environment qubit in \(|0\rangle\) copies the \(Z\) value into the environment. Tracing out the environment leaves the qubit with its populations intact and its coherences gone: the phase-flip channel with \(p=\tfrac12\). The second code box in Section 7 does exactly this. Decoherence is not the qubit "getting tired"; it is information about the qubit leaking into things we do not control, which is why isolating qubits is the central engineering problem.
The trace distance is \(D(\rho,\sigma)=\tfrac12\sum_j|\lambda_j|\), the eigenvalues \(\lambda_j\) being those of \(\rho-\sigma\). The fidelity is \(F(\rho,\sigma)=\big(\operatorname{tr}\sqrt{\sqrt\rho\,\sigma\sqrt\rho}\big)^2\); if \(\sigma=|\psi\rangle\langle\psi|\) is pure, \(F=\langle\psi|\rho|\psi\rangle\).
For qubit states with Bloch vectors \(\vec r\) and \(\vec s\):
$$D(\rho,\sigma)=\tfrac12|\vec r-\vec s|,\qquad F(\rho,\sigma)=\tfrac12\Big(1+\vec r\cdot\vec s+\sqrt{(1-|\vec r|^2)(1-|\vec s|^2)}\Big).$$Operationally: given one copy of a state that is \(\rho\) or \(\sigma\) with equal probability, the best possible measurement guesses correctly with probability \(\tfrac12+\tfrac12D(\rho,\sigma)\) (Helstrom). No channel can increase the trace distance: \(D(\Phi(\rho),\Phi(\sigma))\le D(\rho,\sigma)\).
Proof sketch. \(\rho-\sigma=\tfrac12(\vec r-\vec s)\cdot\vec\sigma\) has eigenvalues \(\pm\tfrac12|\vec r-\vec s|\). The fidelity formula is a \(2\times2\) computation (checked numerically in verify_L18.py). For Helstrom's bound and contractivity, see Watrous Ch. 9 or Nielsen–Chuang §9.2.
Let \(\rho=\mathrm{diag}(\tfrac14,\tfrac34)\) and \(\sigma=|1\rangle\langle1|\). Find \(D(\rho,\sigma)\) and the best probability of guessing correctly, from one copy, which of the two (equally likely) you hold.
Compute \(D\) and \(F\) between Example 18.1's \(\rho\) and \(|0\rangle\langle0|\), and \(D\) between \(\rho\) and \(I/2\).
\(\vec r=(0,-\tfrac14,\tfrac34)\) and \(\vec s=(0,0,1)\): \(D=\tfrac12\big|(0,-\tfrac14,-\tfrac14)\big|=\tfrac{\sqrt2}{8}\approx0.177\). Since \(|0\rangle\) is pure, \(F=\langle0|\rho|0\rangle=\tfrac78\). So the best single-shot test tells \(\rho\) from \(|0\rangle\) only with probability \(\tfrac12+\tfrac12\cdot0.177\approx0.588\). From the centre: \(D(\rho,I/2)=\tfrac12|\vec r|=\tfrac{\sqrt{10}}8\approx0.395\).
Both quantities are used constantly from here on: fidelity is how hardware papers report the quality of a gate or a prepared state (Lecture 19), and trace distance is how cryptographers bound what an eavesdropper can learn (Lecture 20).
import numpy as np from qiskit.quantum_info import DensityMatrix, Statevector, SparsePauliOp, partial_trace zero = Statevector([1, 0]) minus_i = Statevector([1, -1j]) / np.sqrt(2) rho = 0.75 * DensityMatrix(zero) + 0.25 * DensityMatrix(minus_i) # Example 18.1 print(np.round(rho.data, 4)) print("purity tr(rho^2) =", round(float(rho.purity().real), 4), " is it a valid state?", rho.is_valid()) print("Bloch vector:", [round(float(rho.expectation_value(SparsePauliOp(P)).real), 4) + 0.0 for P in "XYZ"]) print("eigenvalues:", np.round(np.linalg.eigvalsh(rho.data), 4)) psi = Statevector(np.array([1, 1, 0, 1]) / np.sqrt(3)) # Example 18.2, kets |q1 q0> rho_q1 = partial_trace(psi, [0]) # trace out qubit 0, keep qubit 1 rho_q0 = partial_trace(psi, [1]) # trace out qubit 1, keep qubit 0 print("rho_q1 * 3 =", np.round(3 * rho_q1.data.real, 4).tolist(), " rho_q0 * 3 =", np.round(3 * rho_q0.data.real, 4).tolist()) print("purity of each half:", round(float(rho_q1.purity().real), 4), round(float(rho_q0.purity().real), 4))
[[0.875+0.j 0. +0.125j] [0. -0.125j 0.125+0.j ]] purity tr(rho^2) = 0.8125 is it a valid state? True Bloch vector: [0.0, -0.25, 0.75] eigenvalues: [0.1047 0.8953] rho_q1 * 3 = [[2.0, 1.0], [1.0, 1.0]] rho_q0 * 3 = [[1.0, 1.0], [1.0, 2.0]] purity of each half: 0.7778 0.7778
Examples 18.1 and 18.2. DensityMatrix accepts a Statevector and supports weighted sums; partial_trace(state, qargs) traces out the listed qubits (here qubit 0, the right-hand digit, in the first call), keeping the rest.
import numpy as np from qiskit import QuantumCircuit from qiskit.quantum_info import DensityMatrix, Statevector, Kraus, SparsePauliOp, partial_trace, state_fidelity I2 = np.eye(2); X = np.array([[0, 1], [1, 0]]); Z = np.diag([1, -1]) p = 0.3 bit_flip = Kraus([np.sqrt(1 - p) * I2, np.sqrt(p) * X]) phase_flip = Kraus([np.sqrt(1 - p) * I2, np.sqrt(p) * Z]) bloch = lambda r: [round(float(r.expectation_value(SparsePauliOp(P)).real), 3) + 0.0 for P in "XYZ"] plus_i = DensityMatrix(Statevector([1, 1j]) / np.sqrt(2)) # Bloch vector (0, 1, 0) for name, ch in (("bit flip", bit_flip), ("phase flip", phase_flip)): out = plus_i.evolve(ch) print(f"{name:10s}: Bloch {bloch(out)}, fidelity with |+i> {state_fidelity(out, plus_i):.3f}") # decoherence as entanglement with an environment: CNOT from the qubit (q0) onto a fresh environment qubit (q1) qc = QuantumCircuit(2) qc.ry(2 * np.arccos(np.sqrt(0.8)), 0) # system: sqrt(0.8)|0> + sqrt(0.2)|1>, Bloch (0.8, 0, 0.6) qc.cx(0, 1) # the environment "learns" the Z value sys = partial_trace(Statevector.from_instruction(qc), [1]) # forget the environment print("system after the environment looked:", np.round(sys.data.real, 3).tolist(), " Bloch", bloch(sys))
bit flip : Bloch [0.0, 0.4, 0.0], fidelity with |+i> 0.700 phase flip: Bloch [0.0, 0.4, 0.0], fidelity with |+i> 0.700 system after the environment looked: [[0.8, 0.0], [0.0, 0.2]] Bloch [0.0, 0.0, 0.6]
Both flips shorten the \(y\) component of \(|{+i}\rangle\) from 1 to \(1-2p=0.4\), so the fidelity drops to \(\tfrac12(1+0.4)=0.7\). The last line is the idea box of Section 5: after the CNOT, the qubit's Bloch vector \((0.8,0,0.6)\) has lost its \(x\) component, exactly as a phase flip with \(p=\tfrac12\) would do.
Next time: noise on real hardware (\(T_1\), \(T_2\), readout error) and error mitigation, and the launch of Lab 5. HW9 (Lectures 17–18) is due at the start of Week 11.
DensityMatrix, partial_trace, Kraus, state_fidelity).all numbers and figures in these notes are computed in python (verify_L18.py) and follow the page theme