|q⟩ Bad Qubits

beginner · Programming · Mini-Projects: Coin Flips, RNG & Bell Tests

Project: State Tomography (Intro)

Every qubit state corresponds to a point on the Bloch sphere: a unit sphere where the north pole is 0|0\rangle, the south pole is 1|1\rangle, and every other point is a superposition. Knowing where a state lives on that sphere means knowing its Bloch vector r=(X,Y,Z)\vec{r} = (\langle X \rangle, \langle Y \rangle, \langle Z \rangle), the triple of expectation values of the three Pauli operators.

A single measurement cannot reveal all three components — each measurement collapses the state and gives only a single bit. State tomography gets around this by repeating the preparation many times and measuring in three different bases, extracting one component per basis.

The three basis measurements

Z basis (the default)

Measure the qubit as-is. The Born rule gives

P(0)=12(1+Z),P(1)=12(1Z),P(0) = \tfrac{1}{2}(1 + \langle Z \rangle), \qquad P(1) = \tfrac{1}{2}(1 - \langle Z \rangle),

so

Z=P(0)P(1).\langle Z \rangle = P(0) - P(1).

For 0|0\rangle this yields Z=1\langle Z \rangle = 1 (north pole); for 1|1\rangle it yields 1-1 (south pole); for +|+\rangle it gives 00 (equator).

X basis

Applying a Hadamard before measuring rotates the XX axis onto the ZZ axis:

H+=0,H=1.H\,|+\rangle = |0\rangle, \qquad H\,|-\rangle = |1\rangle.

The measurement outcome then encodes the XX component:

X=P(0after H)P(1after H).\langle X \rangle = P(0\,|\,\text{after }H) - P(1\,|\,\text{after }H).

For +|+\rangle, applying HH gives 0|0\rangle, so the outcome is always 00 and X=1\langle X \rangle = 1. The Bloch vector tip is on the +x+x axis — exactly as expected.

Y basis

To extract Y\langle Y \rangle, first apply SS^\dagger (the inverse phase gate) and then HH. Together the two gates satisfy (HS)Y(HS)=Z(HS^\dagger)\,Y\,(HS^\dagger)^\dagger = Z, so the composite rotation maps YZY \to Z for measurement purposes. The protocol is identical in structure:

Y=P(0after SH)P(1after SH).\langle Y \rangle = P(0\,|\,\text{after }S^\dagger H) - P(1\,|\,\text{after }S^\dagger H).

Together the three measurements reconstruct r\vec{r} completely. For a pure state r=1|\vec{r}| = 1; for a mixed state r<1|\vec{r}| < 1.

Try it

Measure +|+\rangle in the X basis. Prepare the state with a Hadamard, rotate to the Z basis with a second Hadamard, then measure. The grader checks the output distribution: because H+=0H|+\rangle = |0\rangle, the result should be 00 with probability 11, confirming X=1\langle X \rangle = 1.

Run your code to see the quantum state.

After running, open the Probabilities panel. The bar for outcome 0 should be at 1.01.0 and the bar for 1 at 0.00.0. That single number — X=10=1\langle X \rangle = 1 - 0 = 1 — tells you the Bloch vector is exactly on the +x+x axis, which is the definition of +|+\rangle.

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