|q⟩ Bad Qubits

beginner · Programming · The Bloch Sphere

Bloch Coordinates (x, y, z)

Every qubit state can be described by a point on the Bloch sphere — a unit sphere whose poles are 0|0\rangle (north) and 1|1\rangle (south). The Cartesian coordinates (x,y,z)(x, y, z) of that point form the Bloch vector, and knowing how to compute them from the amplitudes is the key to reading the Bloch sphere display.

From amplitudes to the density matrix

A single-qubit pure state is written

ψ=α0+β1,α2+β2=1,|\psi\rangle = \alpha|0\rangle + \beta|1\rangle, \qquad |\alpha|^2 + |\beta|^2 = 1,

where α,βC\alpha, \beta \in \mathbb{C}. Its density matrix is the outer product ρ=ψψ\rho = |\psi\rangle\langle\psi|:

ρ=(α2αβαββ2)=(ρ00ρ01ρ10ρ11).\rho = \begin{pmatrix} |\alpha|^2 & \alpha\overline{\beta} \\ \overline{\alpha}\beta & |\beta|^2 \end{pmatrix} = \begin{pmatrix} \rho_{00} & \rho_{01} \\ \rho_{10} & \rho_{11} \end{pmatrix}.

The diagonal entries ρ00=α2\rho_{00} = |\alpha|^2 and ρ11=β2\rho_{11} = |\beta|^2 are the measurement probabilities. The off-diagonal entry ρ01=αβ\rho_{01} = \alpha\overline{\beta} encodes the coherence — the extent to which the state can interfere.

The Bloch vector formulas

The Bloch coordinates are read directly from the density matrix:

z=ρ00ρ11=α2β2,z = \rho_{00} - \rho_{11} = |\alpha|^2 - |\beta|^2, x=2Re(ρ01)=2Re(αβ),x = 2\,\mathrm{Re}(\rho_{01}) = 2\,\mathrm{Re}(\alpha\overline{\beta}), y=2Im(ρ01)=2Im(αβ).y = -2\,\mathrm{Im}(\rho_{01}) = -2\,\mathrm{Im}(\alpha\overline{\beta}).

These three formulas have clean geometric meaning:

Worked example

Consider the state with real amplitudes α=32\alpha = \tfrac{\sqrt{3}}{2} and β=12\beta = \tfrac{1}{2}. Since both amplitudes are real, ρ01=αβ\rho_{01} = \alpha\beta is real too and Im(ρ01)=0\mathrm{Im}(\rho_{01}) = 0, so y=0y = 0.

z=α2β2=3414=12,z = |\alpha|^2 - |\beta|^2 = \frac{3}{4} - \frac{1}{4} = \frac{1}{2}, x=2αβ=23212=320.866.x = 2\,\alpha\beta = 2 \cdot \frac{\sqrt{3}}{2} \cdot \frac{1}{2} = \frac{\sqrt{3}}{2} \approx 0.866.

A quick sanity check: x2+y2+z2=34+0+14=1x^2 + y^2 + z^2 = \tfrac{3}{4} + 0 + \tfrac{1}{4} = 1. ✓

This state sits in the xzxz-plane, tilted 60°60° from the north pole (since z=cos60°=12z = \cos 60° = \tfrac{1}{2}).

Try it

Apply the zz formula to the example above and return the z-coordinate. Math is available for Math.sqrt.

Run your code to see the quantum state.

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