Skip to main content
All visualizations
Advanced

Mixed States and the Density Matrix

A qubit you are not sure about is not a shorter arrow by analogy. It is a matrix, the arrow is its length, and one half of an entangled pair is the most uncertain qubit there is.

Mixed States and the Density Matrix visualization

ρ2×2

Diagonal (violet): populations, P(0) and P(1). Off-diagonal (teal): coherences — the phase, and the only part dephasing touches.

ρ: the 2 by 2 density matrix. Rows and columns are labelled by computational basis states. Diagonal entries are populations; off-diagonal entries are coherences.
row⟨0|⟨1|
|0⟩0.500.35 − 0.35i
|1⟩0.35 + 0.35i0.50

r = (0.71, 0.71, 0.00) · |r| = 1.000

The arrow is the Bloch vector of ρ. Slide λ up and watch the teal off-diagonal cells fade while the arrow sinks toward the z axis — the diagonal never changes, so neither does P(0). Drag the ball to rotate, scroll to zoom. Cell tint tracks |ρᵢⱼ|.

What the matrix is

A statevector |ψ⟩ describes a qubit you know everything about. The density matrix ρ = Σ pᵢ |ψᵢ⟩⟨ψᵢ| describes the case where you do not: the qubit is |ψ₁⟩ with probability p₁, |ψ₂⟩ with probability p₂, and so on. For a single pure state it collapses to ρ = |ψ⟩⟨ψ| and says nothing the ket did not.

Read it like this. The diagonal is the populations — ρ₀₀ is P(0), ρ₁₁ is P(1), and they sum to 1 because Tr ρ = 1 for any state. The off-diagonal is the coherence, ρ₀₁ = ρ₁₀*. For |ψ⟩ = cos(θ/2)|0⟩ + e^(iφ)sin(θ/2)|1⟩ it is ½ sin θ e^(−iφ): it carries the phase, and it is the part that interferes. ρ is always Hermitian and never has a negative eigenvalue. The tests in lib/quantum/densityMatrix.test.ts check the first two for every state this page can produce.

Purity is the length of the arrow

For one qubit, ρ = (I + r·σ)/2 where r is exactly the Bloch vector. Squaring and taking the trace gives Tr ρ² = (1 + |r|²)/2, so |r| = √(2 Tr ρ² − 1). A pure state has Tr ρ² = 1 and sits on the surface. The maximally mixed state I/2 has Tr ρ² = ½ and sits at the centre, with no arrow at all. Everything in between is inside the ball.

In the first scene, drag λ from 0 to 100% and watch three things move together: the teal cells go to zero, the purity readout falls from 1 toward ½, and the arrow drops onto the z axis. The diagonal does not move, so P(0) is the same before and after. That is what the arrow on the decoherence page was doing: T2 shrinks ρ₀₁ by e^(−t/T2), and this page is the same picture with the numbers showing.

Same statistics, different states

Set the second scene to measure along Z. The superposition (|0⟩ + |1⟩)/√2 gives 50/50. So does a coin flip between |0⟩ and |1⟩. Looking only at Z, you cannot tell them apart, and people conclude from this that a superposition “is just” a state you do not know yet.

Now measure along X. The superposition gives |+⟩ with certainty; the mixture is still 50/50 — and is 50/50 along Y, and along every other axis, because I/2 has no direction. Turn the phase φ and the superposition’s X and Y statistics trade places while the mixture’s do nothing. The two matrices share a diagonal; the whole difference is the off-diagonal. A superposition is a definite state with a definite phase. A mixture is ignorance, and ignorance has no phase.

One thing worth knowing and not visible here: I/2 is also 50% |+⟩ and 50% |−⟩, and 50% of any other antipodal pair. The decomposition of a mixed state into pure states is not unique, and no measurement can recover which one “really” happened. ρ is the whole story.

The whole is pure, the part is mixed

The third scene starts with the Bell state Φ⁺ = (|00⟩ + |11⟩)/√2, which is pure — its 4×4 ρ has Tr ρ² = 1. Now suppose you hold one qubit and lose the other. What is the state of the qubit you have? Take the partial trace: sum over the outcomes of the qubit you gave up, which is what the smaller matrix on the right does to the larger one on the left.

The answer is I/2, the maximally mixed state. Not approximately — exactly, and for either qubit. The arrow disappears into the centre of the ball, the purity reads 0.500, and the entropy reads one full bit. The pair as a whole has zero entropy and each half has the maximum a qubit can have. That is what entanglement is, said in terms of ρ: information that lives in the correlations and in neither part.

Compare with |+⟩|0⟩. It is also pure, but trace out either qubit and what remains is still pure — the arrow stays on the surface. Then pick cos α|00⟩ + sin α|11⟩ and drag α from 0 to π/4. The reduced purity runs from 1 down to ½ following cos⁴α + sin⁴α, and the arrow slides down the z axis into the centre. How mixed a part is measures how entangled the whole was.

What this page does not do

Nothing here evolves in time. The dephasing slider applies a channel once; the rates, T1, T2 and the bound T2 ≤ 2T1 are on the decoherence page. There is no amplitude damping in the first scene either, so the diagonal never changes there — a real qubit’s would. Measurement updates ρ in a way this page does not show (it reports probabilities, not post-measurement states), the entropy readout is for one qubit only, and the two-qubit states are fixed presets rather than anything you can build gate by gate — the simulator is for that.

Build this yourself

Every visualization on this page is computed by the same engine as the simulator. Open it to place the gates by hand, up to 16 qubits, free and without an account. Or install Qubit16 so the whole lab is one tap away and works offline.

Open the simulator