DiracDirac

Part I · The Machinery of Quantum Information · Chapter 4

Quantum Channels and Noise

A state vector is an idealization: a system perfectly known and perfectly isolated. Real qubits are neither. To describe a qubit that is partly classical guesswork — or entangled with an environment we cannot hold — we need a richer object, and a language for what noise does to it.

Sources: Nielsen & Chuang, Ch. 8 · Wilde, Ch. 4 · Watrous, Chs. 2, 4

Two chapters of pure states have taken us far, but they described a world that does not exist: qubits known to infinite precision and sealed off from everything else. Chapter 3 already cracked the idealization — the local half of a Bell pair, looked at alone, is random, and no state vector on that one qubit can say so. This chapter builds the object that can: the density matrix. With it comes the honest arithmetic of imperfect hardware — quantum channels, the maps that model decoherence, and the handful of standard noise processes every real device suffers. Nothing is asserted: by the end you will have, in Rust, a channel simulator whose every claim — that these maps preserve probability, keep states legal, and deform the Bloch ball by exactly the predicted amount, all four of them — is checked by referees that abort the run, most of them gated near . A few are honestly looser — one because the fidelity functional itself loses precision at the pure boundary — and the chapter says so out loud rather than sampling around it.

What this chapter covers

  • 4.1When pure is not enough. Two ways a state vector fails: classical uncertainty about which state you hold, and the local view of an entangled pair.
  • 4.2The density matrix. ρ = Σ pᵢ|ψᵢ⟩⟨ψᵢ|: Hermitian, positive, unit trace. Pure vs mixed, the purity 𝒫 = Tr(ρ²), and ⟨A⟩ = Tr(ρA).
  • 4.3The Bloch ball. Mixed qubit states fill the ball: ρ = (I + r·σ)/2 with |r| ≤ 1. The centre is maximal ignorance.
  • 4.4Channels, Kraus, and Choi. Quantum operations as completely-positive trace-preserving maps, the Kraus form ρ → Σ Eₖ ρ Eₖ†, and the Choi matrix that certifies complete positivity in one finite test.
  • 4.5The channel zoo. Bit-flip, phase-flip (dephasing), depolarizing, and amplitude damping — the four maps every device suffers, and the four Bloch deformations the lab referees one by one.
  • 4.6Fidelity. How close two states are: F(ρ,σ), reducing to ⟨ψ|ρ|ψ⟩ for a pure target — the score noise is measured against, and where computing it gets hard.
  • 4.7The Lab. A density-matrix + Kraus kit in Rust, with a live referee scoreboard and two sweeps of one probe state through all four channels.

A pure state encodes perfect knowledge: you know exactly which unit vector you hold. Two perfectly ordinary situations break that assumption, and neither can be written as a state vector.

First, classical uncertainty. Suppose a faulty machine prepares half the time and half the time, and does not tell you which. This is not the superposition — that would be a definite pure state. It is a classical coin flip over two different pure states, a statistical mixture, and quantum mechanics has no vector for “one of these two, I forget which.”

Second, and deeper: entanglement. Take the Bell state from Chapter 3 and ask only about the first qubit. There is no pure state of that qubit that reproduces its measurement statistics: it comes up 0 half the time and 1 half the time in every basis, as if maximally uncertain — even though the global two-qubit state is perfectly, purely known. The information is in the correlations, not in either qubit alone. The local view of an entangled state is intrinsically mixed.

Both failures share a cure. In each case what we can actually predict is a set of measurement probabilities, and those turn out to be captured by a single Hermitian matrix — the object we build next. It will describe the coin-flip mixture and the reduced Bell qubit with the very same formalism, and it will turn out that they are the same state: no experiment can tell a 50/50 classical mixture of the right two states from the local half of a Bell pair.

4.2The density matrix

F · Formalism

Here is the object — the same that Chapter 1's Holevo argument had to borrow ahead of schedule; this section is where it is properly earned. Given an ensemble — pure states occurring with classical probabilities — define the density matrix

(4.1)

Every probability we can compute comes from alone. The expectation value of any observable is the clean, basis-free trace formula

(4.2)

which specializes to the Born rule: the probability of an outcome with projector is . Because only enters, any two ensembles with the same density matrix are physically identical — which is exactly why the coin-flip mixture and the reduced Bell qubit of §4.1 cannot be told apart.

From its definition (4.1), has three properties that turn out to be not just necessary but sufficient — any matrix with all three is a legal state:

(4.3)

Hermiticity makes expectation values real; positivity (all eigenvalues ) makes probabilities non-negative; unit trace makes them sum to one. A single pure state is the special case , a rank-one projector.

How do we tell a genuinely mixed state from a pure one dressed up as a matrix? The purity — written here, to keep free for the damping rate of §4.5 —

(4.4)

does it in one number. For a pure state , so . For anything mixed it is strictly less than 1, bottoming out at for the maximally mixed state — for a qubit that floor is exactly , the density matrix of total ignorance.

4.3The Bloch ball

F · FormalismC · Concepts

Chapter 1 put every pure qubit on the surface of the Bloch sphere. Mixed states fill the inside. Any qubit density matrix can be written with the Pauli matrices as

(4.5)

where the Bloch vector now has a length that reports the purity directly: . The surface is the pure states; the centre is , maximal ignorance; everything between is a mixed state of intermediate purity. The sphere became a solid ball the moment we admitted we might not know the state.

This picture is what makes noise visual: a noise process is a rule that moves and shrinks the Bloch vector. Keep it in mind for §4.4, where every channel becomes a specific deformation of this ball.

4.4Channels, Kraus, and Choi

F · FormalismC · Concepts

What are the legal ways a density matrix can evolve? A closed system evolves unitarily, . But an open system — one talking to an environment — does more. The most general physical operation, a quantum channel , is any map that is completely positive and trace-preserving (CPTP): it must send density matrices to density matrices, even when applied to just part of a larger entangled system (that is the “complete” in complete positivity), and it must never lose probability.

The remarkable theorem — due to Kraus, building on Stinespring — is that every such map has a concrete finite form. There exist operators (the Kraus operators) with

(4.6)

Read it physically: with “probability” the environment applies operation and we do not learn which — so we sum over the possibilities. The completeness relation is precisely what guarantees the trace is preserved, and hence total probability stays 1. A unitary is the one-operator case .

But suppose someone hands you a map and you want to check it is completely positive — positive not only on every state of the qubit, of which there are infinitely many, but on every entangled input of every larger system it could be part of. That sounds untestable. It is not, and the finite test is the one the lab runs. Write the unnormalized maximally entangled vector on two copies of the system, , let act on the second copy alone, and call the result the Choi matrix of the map:

(4.7)

It is one matrix — for a qubit — and it stores the map completely, because the matrices are a basis and is linear. The payoff is Choi's theorem:

(4.8)

An infinite family of positivity conditions collapses into the positivity of one finite matrix, settled by computing four eigenvalues. And the two directions are constructive: an eigendecomposition with reshapes each into a Kraus operator, so Choi's theorem and Kraus's are two faces of one statement. It also explains why deserves to be called the channel's fingerprint: the Kraus operators are not unique — Exercise 5 makes you find another set for the same channel — but is.

pure input ρ|r| = 1channelρ ↦ Σ Eₖ ρ Eₖ†CPTP · Σ Eₖ†Eₖ = Imixed output ρ'|r'| < 1 a contracting channel: |r′| < 1, so the purity Tr(ρ²) = ½(1 + |r′|²) drops below 1
Figure 4.1. A quantum channel as a box: a pure input (Bloch vector of length 1) enters on the left, and the mixed output leaves on the right as a shorter vector confined to a contracted ball. The map is ρ ↦ Σ Eₖ ρ Eₖ† with Σ Eₖ†Eₖ = I. Drawn here is a contracting channel, for which |r′| < 1 and so the purity ½(1 + |r′|²) drops below 1. Not every channel contracts at every strength: §4.7's purity chart shows dephasing and amplitude damping climbing back to purity 1 at full strength, where each becomes a unitary or a reset.

4.5The channel zoo

C · ConceptsF · Formalism

Four channels model almost everything that goes wrong with a real qubit. Each is written by its Kraus operators; each deforms the Bloch ball in its own signature way.

The bit-flip applies with probability : . It leaves alone and shrinks both and by , collapsing the ball onto the -axis. The phase-flip (or dephasing) channel applies instead: . It is the most insidious noise there is — it destroys the relative phase that superposition lives on while costing the qubit no energy, shrinking the whole equatorial disk toward the -axis. The depolarizing channel is isotropic: with probability it replaces the qubit with total noise,

(4.9)

which shrinks the Bloch vector uniformly by — the whole ball contracts toward its centre. Finally, amplitude damping models energy loss (spontaneous emission, decay): it is not symmetric, because it drives the excited state down to the ground state with probability ,

(4.10)

Unlike the others, amplitude damping moves the ball toward the north pole , not toward the centre: its fixed point is a pure state, because a qubit that has lost all its energy is definitely in the ground state. Watch all four act on a live state — pick a channel and turn up the noise:

|0⟩|1⟩+xρρ'
√(1−¾p) I, ½√p·{X,Y,Z}

1.000

|r| in (pure)

0.600

|r'| out

1.000

purity in

0.680

purity out Tr(ρ'²)

Isotropic noise: shrinks every component by exactly (1−p), pulling the state straight toward the maximally mixed centre.

Drawn: the x–z cross-section of the ball, y = 0 throughout. Each closed form above is refereed against the lab's Kraus sum on the full three-dimensional ball — referees 4–7 in the table below.

Notice the different geometries the slider reveals. Depolarizing pulls straight in toward maximal ignorance. Dephasing flattens the equator: it shrinks and together while leaving alone, and because the widget draws only the slice you see just the half of that collapse. Amplitude damping curves the state up toward . These are not cosmetic differences: the error-correcting codes of Part III are each engineered against a specific noise shape, and getting the shape right is the whole game. All four of these closed forms are refereed in §4.7 against the Kraus sum itself, on the full three-dimensional ball rather than the drawn slice — the lab found that swapping for in the dephasing channel survives every other check in the file, so the check had to exist.

If noise degrades a state, we need a number for how much. The fidelity measures how close two states are, from 1 (identical) down toward 0 (perfectly distinguishable). For a general pair it is

(4.11)

which looks forbidding but collapses in the cases we care about. When the target is a pure state — the usual situation, comparing a noisy output against the clean state we wanted — it becomes the simple overlap

(4.12)

the probability that the noisy passes a test for . Fidelity is 1 exactly when , and for a qubit it has the tidy closed form , which the lab uses as an independent cross-check on the matrix-root formula (4.11). As noise strength climbs, fidelity falls — smoothly and, for these channels, monotonically, as the panel in §4.7 shows.

One honest caveat, because the lab measures it. Evaluating (4.11) means taking a square root of a matrix whose smallest eigenvalue is of order , and blows up at the origin. So the unavoidable rounding of the matrix entries comes out amplified to in : the fidelity of a nearly-pure state to itself is 1 to about thirteen digits in the interior of the ball and only to about eight digits on its surface. This is a property of the functional, not of our code — an eigendecomposition in any dimension does the same thing — and the qubit closed form, which contains no matrix root, does not suffer from it. The lab therefore splits the claim in two and reports both numbers, rather than quietly drawing its test states away from the boundary.

Everything above becomes a compact Rust kit. A density matrix is a complex matrix; a channel is a list of Kraus operators; applying it is one sum. Here is the core:

ch04-channels/src/main.rs — the Kraus kit and the four channels
1type Mat2 = [[C; 2]; 2];
2
3// …
4
5/// Apply a channel {E_k} to ANY 2x2 matrix: sum_k E_k M E_k^dagger. (Works on
6/// non-Hermitian M too, which the Choi construction needs.)
7fn apply(kraus: &[Mat2], m: &Mat2) -> Mat2 {
8 let mut out = zero();
9 for e in kraus {
10 out = add(&out, &mul(&mul(e, m), &dagger(e)));
11 }
12 out
13}
14
15fn bit_flip(p: f64) -> Vec<Mat2> {
16 vec![scale(&id2(), c((1.0 - p).sqrt(), 0.0)), scale(&pauli_x(), c(p.sqrt(), 0.0))]
17}
18fn phase_flip(p: f64) -> Vec<Mat2> {
19 // dephasing: E0 = sqrt(1-p) I, E1 = sqrt(p) Z
20 vec![scale(&id2(), c((1.0 - p).sqrt(), 0.0)), scale(&pauli_z(), c(p.sqrt(), 0.0))]
21}
22fn depolarizing(p: f64) -> Vec<Mat2> {
23 // rho -> (1-p) rho + p I/2, written with four Pauli Kraus operators.
24 vec![
25 scale(&id2(), c((1.0 - 0.75 * p).sqrt(), 0.0)),
26 scale(&pauli_x(), c((p / 4.0).sqrt(), 0.0)),
27 scale(&pauli_y(), c((p / 4.0).sqrt(), 0.0)),
28 scale(&pauli_z(), c((p / 4.0).sqrt(), 0.0)),
29 ]
30}
31fn amplitude_damping(gamma: f64) -> Vec<Mat2> {
32 // E0 = diag(1, sqrt(1-gamma)), E1 = sqrt(gamma) |0><1|
33 vec![
34 [[c(1.0, 0.0), c(0.0, 0.0)], [c(0.0, 0.0), c((1.0 - gamma).sqrt(), 0.0)]],
35 [[c(0.0, 0.0), c(gamma.sqrt(), 0.0)], [c(0.0, 0.0), c(0.0, 0.0)]],
36 ]
37}

Fidelity is built from a closed-form square root of a positive matrix, then the Uhlmann formula (4.11) — alongside the qubit closed form it is graded against. Both lean on one shared primitive, herm_det, which recovers to full relative accuracy with fused multiply-add. Written naively that difference of two nearly equal numbers has no correct digits at all once is close to pure, and the closed form inherits the damage:

ch04-channels/src/main.rs — fidelity via a 2×2 matrix square root
1// … herm_det(m): m00·m11 − |m01|², recovered to full RELATIVE accuracy
2// … with fused multiply-add, so det is right even as rho → a pure state …
3
4/// Principal square root of a 2x2 PSD Hermitian matrix, in closed form:
5/// sqrt(M) = (M + sqrt(det) I) / sqrt(tr + 2 sqrt(det)).
6fn sqrt_psd(m: &Mat2) -> Mat2 {
7 let det = herm_det(m).max(0.0);
8 let s = det.sqrt();
9 let tr = (m[0][0] + m[1][1]).re;
10 let denom = (tr + 2.0 * s).max(0.0).sqrt();
11 if denom < 1e-300 {
12 return zero();
13 }
14 scale(&add(m, &scale(&id2(), c(s, 0.0))), c(1.0 / denom, 0.0))
15}
16/// Uhlmann (Jozsa) fidelity F(rho,sigma) = (Tr sqrt( sqrt(rho) sigma sqrt(rho) ))^2.
17/// For a pure target |psi>, F = <psi|rho|psi>. F(rho,rho) = 1.
18fn fidelity(rho: &Mat2, sigma: &Mat2) -> f64 {
19 let r = sqrt_psd(rho);
20 let inner = mul(&mul(&r, sigma), &r);
21 let t = trace(&sqrt_psd(&inner)).re;
22 t * t
23}
24/// Qubit closed form: F = Tr(rho sigma) + 2 sqrt(det rho * det sigma). An
25/// independent route to fidelity above — no matrix square root anywhere in it,
26/// only a product trace and two determinants. (It shares the herm_det
27/// primitive, but nothing of the algorithm.)
28fn fidelity_closed(rho: &Mat2, sigma: &Mat2) -> f64 {
29 let overlap = trace(&mul(rho, sigma)).re;
30 let dr = herm_det(rho).max(0.0);
31 let ds = herm_det(sigma).max(0.0);
32 overlap + 2.0 * (dr * ds).sqrt()
33}

The referees are where the physics is verified rather than asserted. One of the sharpest is below: it locates amplitude damping's fixed point — it iterates the channel from two hundred random states scattered through the ball and asks where they all end up, which is a different question from the population curve the previous referee grades, and one that a channel damping the wrong way would fail. Below it sits an honest counter-example: the lab computes the Choi matrix (4.7) of each channel and asserts its spectrum has no negative eigenvalue — but it refuses to score that as a referee, because a Choi matrix built from any Kraus sum is positive semidefinite whether the physics is right or wrong (Choi's theorem (4.8) cuts both ways). Like the Hermiticity check, it guards the linear algebra, not the channels — and a referee that cannot fail is not a referee:

ch04-channels/src/main.rs — the fixed-point referee, and the Choi check demoted to an assert
1// --- Referee 9: the amplitude-damping FIXED POINT is |0><0| ------------
2 // Deliberately NOT referee 8 with different words. That one starts at |1>
3 // and grades a population against (1-gamma)^n. This one starts from random
4 // states all over the ball, iterates the channel until it stops moving, and
5 // asks WHERE it stopped — plus that |0><0| is exactly fixed, E(|0><0|) =
6 // |0><0|. Damping the wrong way (E1 = sqrt(g)|1><0|) or contracting to I/2
7 // instead fails here.
8 let g_fix = 0.35_f64;
9 let n_fix = 200;
10 let kraus_fix = amplitude_damping(g_fix);
11 let ground = rho_from_bloch(0.0, 0.0, 1.0); // |0><0|
12 let mut worst_fixed: f64 = dist(&apply(&kraus_fix, &ground), &ground);
13 for _ in 0..200 {
14 let len = rng.gen::<f64>();
15 let (x, y, z) = rand_bloch(&mut rng, len);
16 let mut r = rho_from_bloch(x, y, z);
17 for _ in 0..n_fix {
18 r = apply(&kraus_fix, &r);
19 }
20 worst_fixed = worst_fixed.max(dist(&r, &ground));
21 }
22 assert!(worst_fixed.is_finite());
23 referees.push(Referee {
24 name: "Amp. damping fixed point max |Eⁿ(ρ) − |0⟩⟨0||".into(),
25 value: worst_fixed,
26 tol: 1e-15,
27 pass: worst_fixed < 1e-15,
28 });
29
30 // --- Choi PSD: computed and asserted, but NOT scored as a referee ------
31 // J built from a Kraus sum is PSD for ANY Kraus matrices — wrong physics
32 // included — so this can only catch bugs in the 8x8 Choi embedding itself.
33 // Same class as the Hermiticity assert above; see the header.
34 let mut worst_choi: f64 = f64::INFINITY; // most negative Choi eigenvalue seen
35 for (_, build) in &registry {
36 for &p in &ps {
37 let lo = choi_min_eig(&build(p));
38 worst_choi = worst_choi.min(lo);
39 }
40 }
41 assert!(worst_choi.is_finite());
42 assert!(worst_choi >= -1e-15, "Choi embedding broken: {worst_choi:e}");

The lab writes every referee to JSON and the panel below reads them live — the count, the values, the tolerances, and the numbers quoted in the two chart captions are all pulled from the file, so nothing here can go stale behind a re-run. Each channel is CPTP; outputs stay Hermitian, unit-trace, and positive; all four Bloch deformations match their closed forms; amplitude damping reproduces decay and lands on from anywhere; every Choi matrix is positive; and fidelity is 1 to itself and never turns back up as noise grows.

Loading /data/ch04/channels.json… (run cargo run --release in Rust-QML/ch04-channels)

Run it yourself with cargo run --release in Rust-QML/ch04-channels. This kit is the noise model the rest of the book fights: Part III's codes exist precisely to undo these channels, and to prove they work we will subject encoded qubits to exactly the maps built here.

4.8Exercises

1. (F) Compute the reduced density matrix of the first qubit of by tracing out the second. Show it equals , and confirm its purity is — the maximally mixed qubit, even though the pair is pure.

2. (F) Show that the 50/50 mixture of and and the 50/50 mixture of and give the same density matrix . Conclude that no measurement can distinguish the two preparations.

3. (C) The purity chart in §4.7 is not monotone: two of its four curves come back up to 1 at full strength. Say which, and why, in one sentence each. Then reproduce both on the Bloch-ball widget by pushing the slider to and reading the “purity out” tile. Why does the depolarizing channel have no such escape, whatever you set to?

4. (P) Add a phase_damping channel with , . Verify it is CPTP, and show that on the Bloch ball it acts identically to a phase-flip with — two different Kraus sets, one channel. Since the two Kraus sets describe the same map, their Choi matrices must be equal; check that too.

5. (P, hard) The Kraus representation is not unique: any set with unitary gives the same channel. Generate a random unitary mixing of the depolarizing channel's four Kraus operators, and show in the lab that the new operators produce an identical output on 1000 random states (to ) and an identical Choi matrix (4.7). Then prove it in general: why must be invariant under a unitary remixing of the , and why does that make the canonical fingerprint of a channel?

The bridgeChapter 5: The Stabilizer Formalism

Where you stand. You have the density matrix — Hermitian, positive, unit-trace — and the Bloch ball it fills; quantum channels as CPTP maps in Kraus form; the Choi matrix and Choi's theorem, which turn complete positivity into one finite eigenvalue test; the four standard noise processes and the exact Bloch deformation each performs; and fidelity to score the damage. A Rust kit referees all of it, almost every check gated at 10⁻¹⁵ — and where the fidelity formula is genuinely ill-conditioned, it says so instead of hiding it.

The open question. Noise is the enemy the rest of the book fights — but to fight it with error correction, and even just to simulate the large circuits where correction happens, we hit a wall: a general n-qubit state needs 2ⁿ amplitudes, hopeless past a few dozen qubits. Is there a smaller, exact description of the states and operations that actually matter for error correction?

What comes next. There is. We meet the Pauli group and the stabilizer formalism: an entire class of highly entangled states described not by 2ⁿ amplitudes but by n generators. The Gottesman–Knill theorem then delivers a startling payoff — a large family of quantum circuits, the very ones at the heart of error correction, can be simulated efficiently on a classical computer, and we build that simulator in Rust.

Continue to Chapter 5