|q⟩ Bad Qubits

intermediate · Programming · Noise, Decoherence & Density-Matrix Simulation

Checkpoint: Model a Noisy Qubit

This checkpoint synthesises the density-matrix and noise-channel ideas from module 13. Rather than running a circuit, you will track the probability distribution analytically through a two-step noise process — the same computation a density-matrix simulator performs under the hood.

The bit-flip channel, revisited

The bit-flip channel with error probability pp maps a single-qubit density matrix ρ\rho to

E(ρ)=(1p)ρ+pXρX.\mathcal{E}(\rho) = (1-p)\,\rho + p\,X\rho X.

With probability 1p1-p the qubit is untouched; with probability pp the Pauli-XX gate fires and flips 01|0\rangle \leftrightarrow |1\rangle. This is the quantum version of a binary symmetric channel with crossover probability pp.

Starting from the pure state 00|0\rangle\langle 0|:

E ⁣(00)=(1p)00+p11=(1p00p).\mathcal{E}\!\left(|0\rangle\langle 0|\right) = (1-p)\,|0\rangle\langle 0| + p\,|1\rangle\langle 1| = \begin{pmatrix} 1-p & 0 \\ 0 & p \end{pmatrix}.

The qubit is now in a classical mixture: 0|0\rangle with probability 1p1-p and 1|1\rangle with probability pp.

Applying the channel a second time

What happens when the same channel is applied again to the output ρ1\rho_1?

Because ρ1\rho_1 is already diagonal, we only need to track how its diagonal entries transform. With probability 1p1-p each entry stays put; with probability pp it is swapped with the other diagonal entry (the XX gate exchanges the two populations). Writing q0=1pq_0 = 1-p and q1=pq_1 = p for the populations after the first channel:

P2(0)=(1p)q0+pq1=(1p)2+p2.P_2(0) = (1-p)\,q_0 + p\,q_1 = (1-p)^2 + p^2.

The qubit lands back in 0|0\rangle either because neither flip fired or because both flips fired — two independent rare events that restore the original state. Conversely

P2(1)=2p(1p),P_2(1) = 2p(1-p),

which is the probability that exactly one of the two flips fired.

Sanity-check with purity

The purity γ=tr(ρ2)\gamma = \text{tr}(\rho^2) measures how mixed the state is. For a diagonal density matrix ρ=diag(a,1a)\rho = \text{diag}(a, 1-a) the purity is a2+(1a)2a^2 + (1-a)^2.

Purity decreases monotonically: each application of the channel (with 0<p<120 \lt p \lt \tfrac{1}{2}) pushes the state closer to the maximally mixed state I/2I/2, whose purity is 12\tfrac{1}{2}.

Generalisation: nn sequential channels

After nn applications of the bit-flip channel with parameter pp, the population of 0|0\rangle satisfies the recurrence

Pn(0)=(1p)Pn1(0)+pPn1(1),P_n(0) = (1-p)\,P_{n-1}(0) + p\,P_{n-1}(1),

with P0(0)=1P_0(0) = 1. The closed form is

Pn(0)=12+12(12p)n,P_n(0) = \tfrac{1}{2} + \tfrac{1}{2}(1 - 2p)^n,

which can be verified by induction. As nn \to \infty the population converges to 12\tfrac{1}{2}, the maximally mixed state. This exponential relaxation toward equilibrium is a hallmark of Markovian quantum noise.

For n=1n = 1, p=0.3p = 0.3: P1(0)=12+12(0.4)=0.7P_1(0) = \tfrac{1}{2} + \tfrac{1}{2}(0.4) = 0.7. For n=2n = 2: P2(0)=12+12(0.4)2=12+0.08=0.58P_2(0) = \tfrac{1}{2} + \tfrac{1}{2}(0.4)^2 = \tfrac{1}{2} + 0.08 = 0.58. Both match the direct calculation above.

Try it

Compute P(measure 0)P(\text{measure } 0) after two sequential bit-flip channels with p=0.3p = 0.3, starting from 0|0\rangle. The grader checks the exact numerical answer.

Run your code to see the quantum state.

Sign in on the full site to ask questions and join the discussion.