|q⟩ Bad Qubits

beginner · Programming · From Bits to Qubits

Relative Phase Matters

Two quantum states can look identical under one measurement and yet produce completely different results under another. The key ingredient is phase — and not all phase is equal.

Global phase versus relative phase

A single-qubit state ψ=α0+β1|\psi\rangle = \alpha|0\rangle + \beta|1\rangle has an overall global phase eiϕe^{i\phi} if both amplitudes are multiplied by the same complex factor:

eiϕψ=eiϕα0+eiϕβ1.e^{i\phi}|\psi\rangle = e^{i\phi}\alpha|0\rangle + e^{i\phi}\beta|1\rangle.

The Born rule gives P(0)=eiϕα2=α2P(0) = |e^{i\phi}\alpha|^2 = |\alpha|^2, and similarly for P(1)P(1). The factor eiϕe^{i\phi} cancels out of every probability regardless of which basis you measure in, so two states that differ only by a global phase are physically indistinguishable.

Relative phase is different. It is the phase difference between the amplitudes of distinct basis states. Compare these two states:

+=12(0+1),=12(01).|{+}\rangle = \frac{1}{\sqrt{2}}\bigl(|0\rangle + |1\rangle\bigr), \qquad |{-}\rangle = \frac{1}{\sqrt{2}}\bigl(|0\rangle - |1\rangle\bigr).

Both give P(0)=P(1)=12P(0) = P(1) = \tfrac{1}{2} in the computational (ZZ) basis — so far identical. But |{-}\rangle carries a relative phase of 1-1 (equivalently, eiπe^{i\pi}) between 0|0\rangle and 1|1\rangle. That sign is undetectable by a ZZ-basis measurement alone.

Interference reveals the difference

Apply the Hadamard gate to each state. Using H0=12(0+1)H|0\rangle = \tfrac{1}{\sqrt{2}}(|0\rangle + |1\rangle) and H1=12(01)H|1\rangle = \tfrac{1}{\sqrt{2}}(|0\rangle - |1\rangle):

H+=12(0+12H0+012H1)=12(20)=0,H|{+}\rangle = \frac{1}{\sqrt{2}}\Bigl(\underbrace{\frac{|0\rangle+|1\rangle}{\sqrt{2}}}_{H|0\rangle} + \underbrace{\frac{|0\rangle-|1\rangle}{\sqrt{2}}}_{H|1\rangle}\Bigr) = \frac{1}{2}\bigl(2|0\rangle\bigr) = |0\rangle, H=12(0+12012)=12(21)=1.H|{-}\rangle = \frac{1}{\sqrt{2}}\Bigl(\frac{|0\rangle+|1\rangle}{\sqrt{2}} - \frac{|0\rangle-|1\rangle}{\sqrt{2}}\Bigr) = \frac{1}{2}\bigl(2|1\rangle\bigr) = |1\rangle.

Measuring after HH, the two states give opposite deterministic outcomes: +0|{+}\rangle \to 0 and 1|{-}\rangle \to 1. The Hadamard exposed the relative phase by creating an interference experiment: in H+H|{+}\rangle the 1|1\rangle amplitudes cancel (destructive interference), while in HH|{-}\rangle they add (constructive interference on 1|1\rangle and destructive on 0|0\rangle).

This is exactly the mechanism quantum algorithms exploit. Grover's search, Deutsch–Jozsa, and the quantum Fourier transform all work by engineering constructive interference on the answer and destructive interference on wrong paths — the relative phases do the work.

Try it

Prepare the state =12(01)|{-}\rangle = \tfrac{1}{\sqrt{2}}(|0\rangle - |1\rangle). The grader checks the full state vector, so you must set the relative phase correctly — producing +|{+}\rangle instead will not pass.

Run your code to see the quantum state.

After running, inspect the amplitudes: both have magnitude 120.707\tfrac{1}{\sqrt{2}} \approx 0.707, but the 1|1\rangle amplitude is 12-\tfrac{1}{\sqrt{2}}. That minus sign is the relative phase in action.

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