---
title: Density matrices and decoherence
heading: Mixed states, the Bloch ball, and how T₁ and T₂ wash out a qubit's superposition
eyebrow: B10 · Lesson 27 · Density matrices
xp: 40
---

::: hook
Lesson 26 treated a two-level system as perfectly isolated, so a superposition lasted forever. Real qubits, spins and atoms are coupled to their surroundings, which slowly learn about them and scramble their phases. To describe a system whose state is uncertain, because it was prepared imperfectly or because it's tangled up with an environment you aren't tracking, quantum mechanics uses the **density matrix**. Its diagonal holds populations, its off-diagonal terms hold the coherence that makes interference possible, and two times, $T_1$ and $T_2$, describe how each decays.
:::

::: play
- A qubit starts on the equator of the Bloch sphere, in $\frac{1}{\sqrt2}(|0\rangle + |1\rangle)$, and decays. The solid curve is the length of its Bloch vector's horizontal part, the coherence; the dashed one is the population of |1⟩.
- Coherence decays at the rate $\frac{1}{T_2}$, population at $\frac{1}{T_1}$. Shorten $T_2$: interference dies long before the energy leaks out.
- The readouts give both after 20 µs. Physics forbids $T_2 > 2T_1$, so the sliders won't let coherence outlast twice the energy relaxation.
:::

```sim plot
view: graph
x: t = 0..150 µs
y: v = 0..1
slider: T1 = 10..200 step 5 = 50 µs
slider: T2 = 5..100 step 5 = 30 µs
plot: exp(-t/(T2 - (T2 - 2*T1)*step(T2 - 2*T1))) | label: coherence (Bloch vector in the plane) | samples: 400
plot: 0.5*exp(-t/T1) | dashed | color: ch2 | label: population of |1⟩ | samples: 400
readout: coherence at 20 µs = exp(-20/(T2 - (T2 - 2*T1)*step(T2 - 2*T1))) | digits: 3
readout: population of |1⟩ at 20 µs = 0.5*exp(-20/T1) | digits: 3
```

::: predict
## A qubit is either in |0⟩ or in |1⟩, each with probability ½, and you don't know which. How does that differ from the superposition $\frac{1}{\sqrt2}(|0\rangle + |1\rangle)$?

- [ ] It doesn't: both give |0⟩ half the time
- [x] Measured along z they agree, but along x the superposition always gives the same result while the mixture is random
- [ ] The mixture has more energy
- [ ] The superposition can't be measured

::: reveal
Along z they're indistinguishable: |0⟩ or |1⟩, half and half. Along x, the superposition is an eigenstate and gives "+" every time, while the mixture gives + or − at random. The difference lies in the density matrix's off-diagonal terms, the coherence: the superposition has them and the mixture doesn't. Decoherence is the process that turns the first into the second.
:::
:::

::: nameit
## The density matrix

For a system in state $|\psi_i\rangle$ with probability $p_i$, $\hat\rho = \sum_ip_i|\psi_i\rangle\langle\psi_i|$. Any measurement's average is $\langle Q\rangle = \text{Tr}(\hat\rho\hat Q)$. A pure state has $\text{Tr}\,\hat\rho^2 = 1$; a mixture has less, down to $\frac1d$ for complete ignorance in d dimensions. It evolves by $i\hbar\frac{d\hat\rho}{dt} = [\hat H, \hat\rho]$ when isolated.

## The Bloch ball

For a qubit, $\hat\rho = \frac12(1 + \mathbf r \cdot \boldsymbol\sigma)$. Pure states have $|\mathbf r| = 1$ and lie on the Bloch sphere; mixed states lie inside, and the center is the completely mixed state. With populations $p_0$, $p_1$ and coherence $\rho_{01}$, $|\mathbf r| = \sqrt{(p_0 - p_1)^2 + 4|\rho_{01}|^2}$.

## $T_1$ and $T_2$

Coupling to an environment adds two decays:

- **energy relaxation:** the populations relax toward thermal equilibrium with time $T_1$;
- **dephasing:** the off-diagonal terms decay with time $T_2$, and always $T_2 \le 2T_1$.

In thermal equilibrium at temperature T the populations follow Boltzmann, $\frac{p_1}{p_0} = e^{-hf/kT}$, with no coherence.

## Inhomogeneous dephasing and echoes

When each member of an ensemble, or each repetition of an experiment, has a slightly different frequency, the average coherence decays faster, with time $T_2^*$. A **spin echo**, a π pulse halfway through, reverses the phases' spreading and refocuses this static part, leaving only the true $T_2$. Echoes are why MRI images and qubit memories can last far longer than their raw decay suggests.
:::

::: example
## A qubit with $T_1$ = 50 µs and $T_2$ = 30 µs starts in $\frac{1}{\sqrt2}(|0\rangle + |1\rangle)$. After 20 µs, what are its coherence and its population of |1⟩?

::: solution
1. **Coherence.** The off-diagonal term starts at ½ and decays as $e^{-t/T_2}$:
   $$\frac12e^{-20/30} = 0.257$$
   so the Bloch vector's horizontal part has shrunk to 0.513.
2. **Population.** The population of |1⟩ decays toward zero (at very low temperature) as
   $$\frac12e^{-t/T_1} = 0.335$$
3. **Compare the two.** Coherence has lost half its size while energy has barely begun to leak. That's why quantum algorithms must finish well within $T_2$, the shorter of the two.

**Answer:** after 20 µs the coherence is 0.257 and the population of |1⟩ is 0.335.
:::
:::

::: example
## A 5 GHz superconducting qubit sits at 50 mK. In thermal equilibrium, what fraction of the time is it excited, and how pure is its state?

::: solution
1. **Energy over temperature.**
   $$\begin{aligned} \frac{hf}{kT} &= \frac{6.626 \times 10^{-34} \times 5 \times 10^9}{1.381 \times 10^{-23} \times 0.05} \\ &= 4.80 \end{aligned}$$
2. **Excited fraction.** $\frac{p_1}{p_0} = e^{-4.80}$, so $p_1 = 0.0082$: excited 0.8% of the time.
3. **Purity.**
   $$p_0^2 + p_1^2 = 0.984$$
4. **What experiments do about it.** A qubit left to itself isn't quite in |0⟩. Experiments reset it actively before each run, because a 0.8% error at the start would be larger than most of the gate errors that follow.

**Answer:** it's excited 0.8% of the time, and its purity is 0.984.
:::
:::

::: example
## A Ramsey measurement on a qubit shows its coherence decaying with $T_2^*$ = 1 µs, but a spin-echo measurement shows $T_2$ = 30 µs. How much coherence does each leave after 1 µs?

::: solution
1. **Without the echo.**
   $$e^{-1/1} = 0.37$$
2. **With the echo.**
   $$e^{-1/30} = 0.97$$
3. **Why they differ.** The fast Ramsey decay came from a frequency that drifted slowly between repetitions, which the echo's π pulse cancels. What's left, $T_2$, is the decay from noise too fast to refocus. Comparing the two tells a designer which kind of noise to fight.

**Answer:** 0.37 of the coherence remains without the echo, and 0.97 with it.
:::
:::

::: check
kind: parts
given: p = 0.5 | 0.7 | 0.8; c = 0.1 | 0.2 | 0.3

## A qubit's density matrix has $p_0$ = {p}, $p_1$ = 1 − {p}, and off-diagonal terms of size {c}.

::: part
answer: p^2 + (1 - p)^2 + 2*c^2
tolerance: 0.5%

### What is its purity, $\text{Tr}\,\hat\rho^2$?

::: misses
- [p^2 + (1 - p)^2] Include the off-diagonal terms: they count twice.
- [any] Sum the squares of all four entries' sizes.
:::
:::

::: part
answer: sqrt((2*p - 1)^2 + 4*c^2)
tolerance: 0.5%

### How long is its Bloch vector?

::: misses
- [any] $\sqrt{(p_0 - p_1)^2 + 4|\rho_{01}|^2}$.
:::
:::
:::

::: check
given: T = 10 | 20 | 50; t = 5 | 30
answer: exp(-t/T)
tolerance: 0.5%

## A superposition dephases with $T_2$ = {T} µs. What fraction of its coherence remains after {t} µs?

::: right
Right. $e^{-t/T_2}$.
:::

::: misses
- [exp(-t/(2*T))] The coherence itself decays with $T_2$, not $2T_2$.
- [any] The off-diagonal terms decay as $e^{-t/T_2}$.
:::
:::

::: check
given: f = 4 | 6; T = 80 | 120 | 200
answer: exp(-6.626e-34*f*1e9/(1.381e-23*T*1e-3))/(1 + exp(-6.626e-34*f*1e9/(1.381e-23*T*1e-3)))*100
unit: %
tolerance: 0.5%

## A {f} GHz qubit sits in thermal equilibrium at {T} mK. What percentage of the time is it excited?

::: right
Right. $\frac{e^{-hf/kT}}{1 + e^{-hf/kT}}$: colder or higher-frequency qubits start cleaner.
:::

::: misses
- [exp(-6.626e-34*f*1e9/(1.381e-23*T*1e-3))*100] Normalize: $p_0 + p_1 = 1$.
- [any] Boltzmann ratio, then normalize.
:::
:::

::: check
kind: parts
given: T1 = 20 | 80; T2 = 10 | 30; t = 5 | 15

## A qubit has $T_1$ = {T1} µs and $T_2$ = {T2} µs and starts in $\frac{1}{\sqrt2}(|0\rangle + |1\rangle)$.

::: part
answer: 0.5*exp(-t/T2)
tolerance: 0.5%

### After {t} µs, how big are the off-diagonal terms?

::: misses
- [exp(-t/T2)] They start at ½.
- [any] $\frac12e^{-t/T_2}$.
:::
:::

::: part
answer: 0.5*exp(-t/T1)
tolerance: 0.5%

### And the population of |1⟩, near zero temperature?

::: misses
- [0.5*exp(-t/T2)] Populations relax with $T_1$.
- [any] $\frac12e^{-t/T_1}$.
:::
:::
:::

::: check
kind: choice

## A qubit is reported with $T_1$ = 20 µs and $T_2$ = 60 µs. What do you conclude?

- [ ] It's an excellent qubit
- [x] The numbers are inconsistent: $T_2$ can't exceed $2T_1$
- [ ] Its coherence outlasts its energy, as usual
- [ ] $T_1$ must have been measured with a spin echo

::: right
Right. Energy relaxation also destroys coherence, so $T_2 \le 2T_1$ always.
:::

::: misses
- [1] One of the times must be wrong.
- [3] Coherence can outlast the energy only up to a factor of 2.
- [4] Echoes refocus dephasing, not energy loss.
:::
:::

::: check
given: d = 2 | 3 | 4
answer: 1/2^d
tolerance: 0.5%

## What is the purity of a completely mixed state of {d} qubits?

::: right
Right. $\frac{1}{2^d}$: ignorance spread evenly over all $2^d$ states.
:::

::: misses
- [1/d] The dimension is $2^d$, not d.
- [any] $\text{Tr}\,\hat\rho^2 = \frac1D$ in D dimensions.
:::
:::

::: check
kind: derivation
vars: p = 0..1, c = 0..0.5

## A qubit with $p_0$ = p, $p_1$ = 1 − p and coherence c.

::: step
answer: p^2 + (1 - p)^2 + 2*c^2

### What is its purity?
:::

::: step
answer: sqrt((2*p - 1)^2 + 4*c^2)

### What is its Bloch vector's length?
:::

::: right
Right. The state is pure exactly when the Bloch vector reaches the sphere.
:::
:::

::: explain
## Why does an environment destroy a superposition's coherence even when it takes no energy from the system?

::: model
Coherence is a fixed phase relation between the parts of a superposition. If the environment interacts with the system in a way that depends on which part it's in, even without exchanging energy, the environment's state becomes correlated with the system's: one environment state goes with |0⟩ and a slightly different one with |1⟩. Looking at the system alone, you have to average over the environment you aren't tracking, and the more distinguishable its two states become, the more the cross terms in the system's density matrix cancel. The populations are untouched, so no energy is lost, but interference between the two parts disappears. That's pure dephasing, and it's why $T_2$ can be much shorter than $T_1$.
:::
:::

::: practice

::: check
given: p = 0.5 | 0.6 | 0.7 | 0.8 | 0.9 | 0.99
answer: p^2 + (1 - p)^2
tolerance: 0.5%

## Purity of a mixture with populations {p} and 1 − {p} and no coherence?

::: misses
- [any] $p_0^2 + p_1^2$.
:::
:::

::: check
given: T = 1 | 30; t = 0.5 | 10
answer: exp(-t/T)
tolerance: 0.5%

## Coherence left after {t} µs with $T_2$ = {T} µs?

::: misses
- [any] $e^{-t/T_2}$.
:::
:::
:::
