|q⟩ Bad Qubits

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

The S (Phase) Gate

Every quantum gate acts on amplitudes, not just probabilities. The S gate — sometimes called the phase gate — leaves ∣0⟩|0\rangle unchanged and multiplies the ∣1⟩|1\rangle amplitude by ii:

S∣0⟩=∣0⟩,S∣1⟩=i ∣1⟩.S|0\rangle = |0\rangle, \qquad S|1\rangle = i\,|1\rangle.

Its matrix is diagonal:

S=(100i).S = \begin{pmatrix} 1 & 0 \\ 0 & i \end{pmatrix}.

Because i=eiπ/2i = e^{i\pi/2}, the S gate introduces a relative phase of 90° (a quarter turn) between the two basis amplitudes.

Why relative phase matters

A global phase — a factor eiθe^{i\theta} in front of the entire state — is physically unobservable. A relative phase between ∣0⟩|0\rangle and ∣1⟩|1\rangle is a different story: it changes the state genuinely and is observable when the state is later interfered with other gates.

To see this, start from the equal superposition

∣+⟩=12(∣0⟩+∣1⟩)|+\rangle = \tfrac{1}{\sqrt{2}}\bigl(|0\rangle + |1\rangle\bigr)

and apply SS. Because SS only touches the ∣1⟩|1\rangle amplitude,

S∣+⟩=12(S∣0⟩+S∣1⟩)=12(∣0⟩+i ∣1⟩).S|+\rangle = \tfrac{1}{\sqrt{2}}\bigl(S|0\rangle + S|1\rangle\bigr) = \tfrac{1}{\sqrt{2}}\bigl(|0\rangle + i\,|1\rangle\bigr).

The probabilities are still 50/50 — the magnitudes ∣1/2∣2|1/\sqrt{2}|^2 and ∣i/2∣2|i/\sqrt{2}|^2 are both 12\tfrac{1}{2}. But the relative phase has shifted from 00 to 90°90°, moving the Bloch vector from the +x+x axis to the +y+y axis. This state 12(∣0⟩+i∣1⟩)\tfrac{1}{\sqrt{2}}(|0\rangle + i|1\rangle) is the +y+y eigenstate, often written ∣+i⟩|{+i}\rangle or ∣y⟩|y\rangle.

Try it

Apply H and then S to the single qubit. After pressing Run, look at the amplitudes: the ∣0⟩|0\rangle amplitude should be ≈0.707\approx 0.707 (real), and the ∣1⟩|1\rangle amplitude should be ≈0.707i\approx 0.707i (purely imaginary), confirming the 90° relative phase.

Run your code to see the quantum state.

Notice that the Probabilities tab still shows a 50/50 split — the phase is hidden from measurements in the ZZ basis. It would only become visible if you applied another gate that causes interference, such as a second Hadamard.

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