|q⟩ Bad Qubits

beginner · Programming · From Bits to Qubits

Reading the State Vector Output

When you run a circuit in the simulator, you get back a table with one row per basis state. Each row shows three numbers: an amplitude, a probability, and a phase. Knowing what each column means lets you read the output confidently rather than just stare at numbers.

Amplitudes

The state vector of an nn-qubit system is a list of 2n2^n complex numbers called amplitudes, one for every possible classical bit string. For a single qubit the two amplitudes are labeled by 0|0\rangle and 1|1\rangle:

ψ=α0+β1,α,βC.|\psi\rangle = \alpha|0\rangle + \beta|1\rangle, \qquad \alpha,\beta \in \mathbb{C}.

The simulator displays α\alpha and β\beta either as decimal numbers (when they happen to be real) or as rectangular or polar complex numbers. The entire set of amplitudes completely describes everything you could ever know about the qubit — there is no hidden extra information.

Probabilities

The Born rule converts amplitudes to observable probabilities. The probability of measuring basis state b|b\rangle is

P(b)=bψ2=αb2,P(b) = |\langle b|\psi\rangle|^2 = |\alpha_b|^2,

the squared absolute value of the corresponding amplitude. Because all outcomes are mutually exclusive and exhaustive, the probabilities must sum to one:

bαb2=1.\sum_b |\alpha_b|^2 = 1.

This is why you will often see the simulator report that the amplitudes are "normalised." For example, the equal-superposition state +=120+121|+\rangle = \tfrac{1}{\sqrt{2}}|0\rangle + \tfrac{1}{\sqrt{2}}|1\rangle has α02=α12=12|\alpha_0|^2 = |\alpha_1|^2 = \tfrac{1}{2}, so both outcomes are equally likely.

Phase

The phase of an amplitude α=reiθ\alpha = r e^{i\theta} is the angle θ\theta. Phase has no direct effect on individual measurement probabilities (only r2r^2 appears in the Born rule), but it controls how amplitudes interfere with each other when gates are applied later. The simulator usually displays the phase in degrees or radians alongside the magnitude rr.

Putting it together

When you read a state vector table, the workflow is straightforward:

  1. Find the basis state of interest in the left column.
  2. Read off its amplitude in the next column.
  3. Square the magnitude to get the probability.
  4. Note the phase angle if you care about how this state will interfere with future gates.

A circuit that does nothing (the identity) leaves the qubit in 0|0\rangle with amplitude 11, probability 11, and phase 0°. Apply a Hadamard gate and both amplitudes become 120.7071\tfrac{1}{\sqrt{2}} \approx 0.7071, both probabilities become 0.50.5, and both phases are 0°. Apply a ZZ gate afterward and the amplitude of 1|1\rangle picks up a phase of 180°180° (it becomes 12-\tfrac{1}{\sqrt{2}}) while its probability stays 0.50.5 — a concrete illustration that phase matters for interference even though it is invisible in a single measurement.

Try it

The +|+\rangle state has amplitude 12\tfrac{1}{\sqrt{2}} for 0|0\rangle. Use the Born rule to compute the probability of measuring 0|0\rangle and return it.

Run your code to see the quantum state.

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