A qubit waits in memory. Every clock tick, two kinds of noise act on its density matrix \rho (a 2\times2 list of rows), in this order:
- Amplitude damping with strength \gamma: \rho \mapsto K_0\rho K_0^\dagger + K_1\rho K_1^\dagger withK_0=\begin{pmatrix}1&0\\0&\sqrt{1-\gamma}\end{pmatrix},\qquad K_1=\begin{pmatrix}0&\sqrt\gamma\\0&0\end{pmatrix},where K^\dagger is the conjugate transpose. It moves weight from |1\rangle to |0\rangle.
- Depolarizing with probability p: \rho \mapsto (1-p)\,\rho + p\,I/2, where I/2 is the maximally mixed qubit.
To watch the qubit forget, follow its Bloch vector (x, y, z) = (\mathrm{Tr}(X\rho), \mathrm{Tr}(Y\rho), \mathrm{Tr}(Z\rho)), which for a 2\times2 density matrix is
x = 2\,\mathrm{Re}\,\rho_{01},\qquad y = -2\,\mathrm{Im}\,\rho_{01},\qquad z = \rho_{00} - \rho_{11}.
Write fade(rho, gamma, p, steps) that returns a list of steps + 1 Bloch vectors [x, y, z] (each a list of three real numbers): the first for rho as given, then one after each tick. Press Run with plot([v[2] for v in fade([[0, 0], [0, 1]], 0.2, 0.05, 30)]) to watch z climb from -1 toward a resting value below 1.
Examples
Input: rho = [[0, 0], [0, 1]], gamma = 0.36, p = 0, steps = 2
Output: [[0, 0, -1], [0, 0, -0.28], [0, 0, 0.1808]]
Input: rho = [[0.5, 0.5], [0.5, 0.5]], gamma = 0, p = 0.1, steps = 2
Output: [[1, 0, 0], [0.9, 0, 0], [0.81, 0, 0]]
Input: rho = [[0.5, 0.5], [0.5, 0.5]], gamma = 0.36, p = 0.5, steps = 1
Output: [[1, 0, 0], [0.4, 0, 0.18]]
Explanation: damping gives x = 0.8, z = 0.36; depolarizing then halves both.
Constraints
0 <= gamma <= 1,0 <= p <= 1,0 <= steps <= 30.- Each number is compared with a tolerance of
1e-6.
Goals
- Apply amplitude damping and depolarizing noise to a qubit's density matrix, in a stated order
- Track the Bloch vector as it shrinks and drifts toward $|0\rangle$ over many steps