|q⟩ Bad Qubits

beginner · Programming · Single-Qubit Gates II: H, S, T & Phase

Interference from Phases

Quantum amplitudes are complex numbers, and their phase — the argument of the complex number — carries real physical information. A lone phase difference between 0|0\rangle and 1|1\rangle is completely invisible in a computational-basis measurement: only the absolute squares of the amplitudes determine probabilities. But once we sandwich the phase gate between two Hadamards, that hidden phase becomes a measurable amplitude difference. This is interference.

Relative phase is invisible by itself

Consider the state +=12(0+1)|+\rangle = \tfrac{1}{\sqrt{2}}(|0\rangle + |1\rangle). Applying the TT gate — which adds a phase of eiπ/4e^{i\pi/4} to the 1|1\rangle component — gives

T+=12 ⁣(0+eiπ/41).T|+\rangle = \frac{1}{\sqrt{2}}\!\left(|0\rangle + e^{i\pi/4}|1\rangle\right).

The probabilities are still 50/50: 1/22=1/2|1/\sqrt{2}|^2 = 1/2 for both outcomes. The phase eiπ/4e^{i\pi/4} is there, but a ZZ-basis measurement cannot see it.

H–phase–H reveals the phase

To make the phase visible we apply HH after TT, which mixes the two amplitudes together. Starting from 0|0\rangle:

0H0+12T0+eiπ/412H(1+eiπ/4)0+(1eiπ/4)12.|0\rangle \xrightarrow{H} \frac{|0\rangle+|1\rangle}{\sqrt{2}} \xrightarrow{T} \frac{|0\rangle + e^{i\pi/4}|1\rangle}{\sqrt{2}} \xrightarrow{H} \frac{(1+e^{i\pi/4})|0\rangle + (1-e^{i\pi/4})|1\rangle}{2}.

The probability of measuring 0|0\rangle is now

P(0)=1+eiπ/424=2+2cos(π/4)4=1+cos(π/4)2=cos2 ⁣(π8)0.854,P(0) = \frac{|1+e^{i\pi/4}|^2}{4} = \frac{2 + 2\cos(\pi/4)}{4} = \frac{1+\cos(\pi/4)}{2} = \cos^2\!\left(\frac{\pi}{8}\right) \approx 0.854,

using the identity 1+eiθ2=2+2cosθ|1+e^{i\theta}|^2 = 2+2\cos\theta and the half-angle formula 1+cosθ2=cos2(θ/2)\frac{1+\cos\theta}{2} = \cos^2(\theta/2). Similarly P(1)=sin2(π/8)0.146P(1) = \sin^2(\pi/8) \approx 0.146.

The two outcomes are no longer equally likely. The π/4\pi/4 phase introduced by TT has been turned into a measurable amplitude imbalance by the second HH gate.

General rule

For any phase gate P(θ)P(\theta) (which multiplies 1|1\rangle by eiθe^{i\theta}), the HHP(θ)P(\theta)HH sandwich on 0|0\rangle yields

P(0)=cos2 ⁣(θ2),P(1)=sin2 ⁣(θ2).P(0) = \cos^2\!\left(\frac{\theta}{2}\right), \qquad P(1) = \sin^2\!\left(\frac{\theta}{2}\right).

At θ=0\theta = 0 (no phase) you get P(0)=1P(0)=1, the qubit stays in 0|0\rangle. At θ=π\theta = \pi (the ZZ gate) you get P(0)=0P(0)=0, the qubit flips to 1|1\rangle — which is exactly the identity HZH=XHZH = X we saw in an earlier lesson.

Try it

Build the circuit HTHH \cdot T \cdot H on qubit 0. The statevector grader will check that your final state has the correct complex amplitudes. A circuit that does nothing, or that skips the second HH, will fail — only the full sandwich produces the asymmetric output.

Run your code to see the quantum state.

After running, look at the State vector panel: the amplitude for 0|0\rangle should have magnitude cos(π/8)0.924\cos(\pi/8) \approx 0.924 and the amplitude for 1|1\rangle magnitude sin(π/8)0.383\sin(\pi/8) \approx 0.383. The Probabilities panel should show roughly 85 % and 15 %.

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