|q⟩ Bad Qubits

beginner · Programming · Measurement & Probability in Code

Born Rule in Practice

Every time you measure a qubit, the quantum state you built — with all its amplitudes — collapses to a single classical outcome. The Born rule is the bridge from those amplitudes to the probabilities you can observe.

From amplitudes to probabilities

A one-qubit state is a superposition

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

where the complex numbers α\alpha and β\beta satisfy α2+β2=1|\alpha|^2 + |\beta|^2 = 1. Measuring in the computational basis gives outcome 00 with probability α2|\alpha|^2 and outcome 11 with probability β2|\beta|^2. That is the Born rule.

For example, if α=12\alpha = \tfrac{1}{\sqrt{2}} and β=12\beta = \tfrac{1}{\sqrt{2}} (the +|+\rangle state), then

P(0)=122=12,P(1)=122=12.P(0) = \left|\tfrac{1}{\sqrt{2}}\right|^2 = \tfrac{1}{2}, \qquad P(1) = \left|\tfrac{1}{\sqrt{2}}\right|^2 = \tfrac{1}{2}.

As a less symmetric example, consider α=cos(π/6)=32\alpha = \cos(\pi/6) = \tfrac{\sqrt{3}}{2} and β=sin(π/6)=12\beta = \sin(\pi/6) = \tfrac{1}{2}. Then

P(0)=(32)2=34,P(1)=(12)2=14.P(0) = \left(\tfrac{\sqrt{3}}{2}\right)^2 = \tfrac{3}{4}, \qquad P(1) = \left(\tfrac{1}{2}\right)^2 = \tfrac{1}{4}.

The probabilities sum to one, as required.

Preparing a state with Ry

The rotation gate Ry(θ)R_y(\theta) acts on 0|0\rangle as

Ry(θ)0=cos ⁣(θ2)0+sin ⁣(θ2)1.R_y(\theta)|0\rangle = \cos\!\left(\tfrac{\theta}{2}\right)|0\rangle + \sin\!\left(\tfrac{\theta}{2}\right)|1\rangle.

To reach α=cos(π/6)\alpha = \cos(\pi/6) and β=sin(π/6)\beta = \sin(\pi/6), set θ/2=π/6\theta/2 = \pi/6, giving θ=π/3\theta = \pi/3. Applying c.ry(Math.PI / 3, 0) places the qubit in exactly this state.

Try it

Prepare the state cos(π/6)0+sin(π/6)1\cos(\pi/6)|0\rangle + \sin(\pi/6)|1\rangle and measure it. The grader checks that P(0)3/4P(0) \approx 3/4 and P(1)1/4P(1) \approx 1/4.

Run your code to see the quantum state.

Open the Probabilities tab after running to confirm the 3:1 ratio of bar heights.

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