A key aspect of density matrices is that probabilistic selections of quantum states are represented by convex combinations of their associated density matrices.
For example, if we have two density matrices, ρ and σ, representing quantum states of a system X, and we prepare the system in the state ρ with probability p and σ with probability 1−p, then the resulting quantum state is represented by the density matrix
pρ+(1−p)σ.
More generally, if we have m quantum states represented by density matrices ρ0,…,ρm−1, and a system is prepared in the state ρk with probability pk for some probability vector (p0,…,pm−1), the resulting state is represented by the density matrix
k=0∑m−1pkρk.
This is a convex combination of the density matrices ρ0,…,ρm−1.
It follows that if we have m quantum state vectors ∣ψ0⟩,…,∣ψm−1⟩, and we prepare a system in the state ∣ψk⟩ with probability pk for each k∈{0,…,m−1}, the state we obtain is represented by the density matrix
k=0∑m−1pk∣ψk⟩⟨ψk∣.
For example, if a qubit is prepared in the state ∣0⟩ with probability 1/2 and in the state ∣+⟩ with probability 1/2, the density matrix representation of the state we obtain is given by
is not a valid quantum state vector because its Euclidean norm is not equal to 1.
A more extreme example that shows that this doesn't work for quantum state vectors is that we fix any quantum state vector ∣ψ⟩ that we wish, and then we take our state to be ∣ψ⟩ with probability 1/2 and −∣ψ⟩ with probability 1/2.
These states differ by a global phase, so they're actually the same state — but averaging gives us the zero vector, which is not a valid quantum state vector.
Suppose we set the state of a qubit to be ∣0⟩ or ∣1⟩ randomly, each with probability 1/2.
The density matrix representing the resulting state is as follows.
(In this equation the symbol I denotes the 2×2 identity matrix.)
This is a special state known as the completely mixed state.
It represents complete uncertainty about the state of a qubit, similar to a uniform random bit in the probabilistic setting.
Now suppose that we change the procedure: in place of the states ∣0⟩ and ∣1⟩ we'll use the states ∣+⟩ and ∣−⟩.
We can compute the density matrix that describes the resulting state in a similar way.
It's the same density matrix as before, even though we changed the states.
In fact, we would again obtain the same result — the completely mixed state — by substituting any two orthogonal qubit state vectors for ∣0⟩ and ∣1⟩.
This is a feature, not a bug!
We do in fact obtain exactly the same state either way.
That is, there's no way to distinguish the two procedures by measuring the qubit they produce, even in a statistical sense.
Our two different procedures are simply different ways to prepare this state.
We can verify that this makes sense by thinking about what we could hope to learn given a random selection of a state from one of the two possible state sets {∣0⟩,∣1⟩} and {∣+⟩,∣−⟩}.
To keep things simple, let's suppose that we perform a unitary operation U on our qubit and then measure in the standard basis.
In the first scenario, the state of the qubit is chosen uniformly from the set {∣0⟩,∣1⟩}.
If the state is ∣0⟩, we obtain the outcomes 0 and 1 with probabilities
∣⟨0∣U∣0⟩∣2and∣⟨1∣U∣0⟩∣2
respectively.
If the state is ∣1⟩, we obtain the outcomes 0 and 1 with probabilities
∣⟨0∣U∣1⟩∣2and∣⟨1∣U∣1⟩∣2.
Because the two possibilities each happen with probability 1/2, we obtain the outcome 0 with probability
21∣⟨0∣U∣0⟩∣2+21∣⟨0∣U∣1⟩∣2
and the outcome 1 with probability
21∣⟨1∣U∣0⟩∣2+21∣⟨1∣U∣1⟩∣2.
Both of these expressions are equal to 1/2.
One way to argue this is to use a fact from linear algebra that can be seen as a generalization of the Pythagorean theorem.
Theorem
Suppose {∣ψ1⟩,…,∣ψn⟩} is an orthonormal basis of a (real or complex) vector space V. For every vector ∣ϕ⟩∈V we have
∣⟨ψ1∣ϕ⟩∣2+⋯+∣⟨ψn∣ϕ⟩∣2=∥∣ϕ⟩∥2.
We can apply this theorem to determine the probabilities as follows.
The probability to get 0 is
Because U is unitary, we know that U† is unitary as well, implying that both U†∣0⟩ and U†∣1⟩ are unit vectors.
Both probabilities are therefore equal to 1/2.
This means that no matter how we choose U, we're just going to get a uniform random bit from the measurement.
We can perform a similar verification for any other pair of orthonormal states in place of ∣0⟩ and ∣1⟩.
For example, because {∣+⟩,∣−⟩} is an orthonormal basis, the probability to obtain the measurement outcome 0 in the second procedure is
21∣⟨0∣U∣+⟩∣2+21∣⟨0∣U∣−⟩∣2=21U†∣0⟩2=21
and the probability to get 1 is
21∣⟨1∣U∣+⟩∣2+21∣⟨1∣U∣−⟩∣2=21U†∣1⟩2=21.
In particular, we obtain exactly the same output statistics as we did for the states ∣0⟩ and ∣1⟩.
Classical states can be represented by density matrices.
In particular, for each classical state a of a system X, the density matrix
ρ=∣a⟩⟨a∣
represents X being definitively in the classical state a.
For qubits we have
∣0⟩⟨0∣=(1000)and∣1⟩⟨1∣=(0001),
and in general we have a single 1 on the diagonal in the position corresponding to the classical state we have in mind, with all other entries zero.
We can then take convex combinations of these density matrices to represent probabilistic states.
Supposing for simplicity that our classical state set is {0,…,n−1}, if X is in the state a with probability pa for each a∈{0,…,n−1}, then the density matrix we obtain is
Going in the other direction, any diagonal density matrix can naturally be identified with the probabilistic state we obtain by simply reading the probability vector off from the diagonal.
To be clear, when a density matrix is diagonal, it's not necessarily the case that we're talking about a classical system, or that the system must have been prepared through the random selection of a classical state, but rather that the state could have been obtained through the random selection of a classical state.
The fact that probabilistic states are represented by diagonal density matrices is consistent with the intuition suggested at the start of the lesson that off-diagonal entries describe the degree to which the two classical states corresponding to the row and column of that entry are in quantum superposition.
Here, all of the off-diagonal entries are zero, so we just have classical randomness and nothing is in quantum superposition.
We've seen that if we take a convex combination of pure states,
ρ=k=0∑m−1pk∣ψk⟩⟨ψk∣,
we obtain a density matrix.
Every density matrix ρ, in fact, can be expressed as a convex combination of pure states like this.
That is, there will always exist a collection of unit vectors {∣ψ0⟩,…,∣ψm−1⟩} and a probability vector (p0,…,pm−1) for which the equation above is true.
We can, moreover, always choose the number m so that it agrees with the number of classical states of the system being considered, and we can select the quantum state vectors to be orthogonal.
The spectral theorem, which we encountered in the "Foundations of quantum algorithms" course, allows us to conclude this.
Here's a restatement of the spectral theorem for convenience.
Theorem
Spectral theorem: Let M be a normaln×n complex matrix.
There exists an orthonormal basis of n dimensional complex vectors {∣ψ0⟩,…,∣ψn−1⟩} along with complex numbers λ0,…,λn−1 such that
M=λ0∣ψ0⟩⟨ψ0∣+⋯+λn−1∣ψn−1⟩⟨ψn−1∣.
(Recall that a matrix M is normal if it satisfies M†M=MM†. In words, normal matrices are matrices that commute with their own conjugate transpose.)
We can apply the spectral theorem to any given density matrix ρ because density matrices are always Hermitian and therefore normal.
This allows us to write
ρ=λ0∣ψ0⟩⟨ψ0∣+⋯+λn−1∣ψn−1⟩⟨ψn−1∣
for some orthonormal basis {∣ψ0⟩,…,∣ψn−1⟩}.
It remains to verify that (λ0,…,λn−1) is a probability vector, which we can then rename to (p0,…,pn−1) if we wish.
The numbers λ0,…,λn−1 are the eigenvalues of ρ, and because ρ is positive semidefinite, these numbers must therefore be nonnegative real numbers.
We can conclude that λ0+⋯+λn−1=1 from the fact that ρ has trace equal to 1.
Going through the details will give us an opportunity to point out the following important and very useful property of the trace.
Theorem
Cyclic property of the trace: For any two matrices A and B that give us a square matrix AB by multiplying, the equality Tr(AB)=Tr(BA) is true.
Note that this theorem works even if A and B are not themselves square matrices.
That is, we may have that A is n×m and B is m×n, for some choice of positive integers n and m, so that AB is an n×n square matrix and BA is m×m.
In particular, if we let A be a column vector ∣ϕ⟩ and let B be the row vector ⟨ϕ∣, then we see that
Tr(∣ϕ⟩⟨ϕ∣)=Tr(⟨ϕ∣ϕ⟩)=⟨ϕ∣ϕ⟩.
The second equality follows from the fact that ⟨ϕ∣ϕ⟩ is a scalar, which we can also think of as a 1×1 matrix whose trace is its single entry.
Using this fact, we can conclude that λ0+⋯+λn−1=1 by the linearity of the trace function.
Alternatively, we can reach the same conclusion by using the fact that the trace of a square matrix (even one that isn't normal) is equal to the sum of its eigenvalues.
We have therefore concluded that any given density matrix ρ can be expressed as a convex combination of pure states.
We also see that we can, moreover, take the pure states to be orthogonal.
This means, in particular, that we never need the number n to be larger than the size of the classical state set of X.
In general, it must be understood that there will be different ways to write a density matrix as a convex combination of pure states, not just the ways that the spectral theorem provides.
A previous example illustrates this.
21∣0⟩⟨0∣+21∣+⟩⟨+∣=(43414141)
This is not a spectral decomposition of this matrix because ∣0⟩ and ∣+⟩ are not orthogonal.
Here's a spectral decomposition:
As another, more general example, suppose ∣ϕ0⟩,…,∣ϕ99⟩ are quantum state vectors representing states of a single qubit, chosen arbitrarily — so we're not assuming any particular relationships among these vectors.
We could then consider the state we obtain by choosing one of these 100 states uniformly at random:
ρ=1001k=0∑99∣ϕk⟩⟨ϕk∣.
Because we're talking about a qubit, the density matrix ρ is 2×2, so by the spectral theorem we could alternatively write
ρ=p∣ψ0⟩⟨ψ0∣+(1−p)∣ψ1⟩⟨ψ1∣
for some real number p∈[0,1] and an orthonormal basis {∣ψ0⟩,∣ψ1⟩} — but naturally the existence of this expression doesn't prohibit us from writing ρ as an average of 100 pure states if we choose to do that.