04 — Global vs Relative Phase
When does a gate actually do something? Trace the eigenvalues to find out.
The setup

Every gate has two eigenstates with two eigenvalues. When the gate acts on a superposition, each component picks up its own eigenvalue. The question: did anything observable change?

The rule

Same eigenvalue on both components → global phase → invisible → gate "did nothing"

Different eigenvalues → relative phase → state moved → gate did something

Example 1: Z gate on |0⟩ — eigenstate, nothing happens

Z's eigenvalues: \(\lambda_0 = +1\) for \(|0\rangle\), \(\lambda_1 = -1\) for \(|1\rangle\).

Input: \(|0\rangle = 1\cdot|0\rangle + 0\cdot|1\rangle\)

Apply Z:

\(|0\rangle\) component: \(1 \times \lambda_0 = 1 \times (+1) = 1\)

\(|1\rangle\) component: \(0 \times \lambda_1 = 0 \times (-1) = 0\)

Output: \(1\cdot|0\rangle + 0\cdot|1\rangle = |0\rangle\)

Verdict: State unchanged. \(|0\rangle\) is an eigenstate of Z — the gate does nothing to it.

Example 2: Z gate on |+⟩ — superposition, relative phase appears

Same gate, different input. Now the input is a superposition of BOTH eigenstates.

Input: \(|+\rangle = \frac{1}{\sqrt{2}}|0\rangle + \frac{1}{\sqrt{2}}|1\rangle\)

Apply Z:

\(|0\rangle\) component: \(\frac{1}{\sqrt{2}} \times \lambda_0 = \frac{1}{\sqrt{2}} \times (+1) = \frac{1}{\sqrt{2}}\)

\(|1\rangle\) component: \(\frac{1}{\sqrt{2}} \times \lambda_1 = \frac{1}{\sqrt{2}} \times (-1) = \frac{-1}{\sqrt{2}}\)

Output: \(\frac{1}{\sqrt{2}}|0\rangle - \frac{1}{\sqrt{2}}|1\rangle = |-\rangle\)

Verdict: State changed! \(|+\rangle \to |-\rangle\). The two eigenvalues (+1 and −1) created a relative sign flip between the components.

Measurement probabilities are still 50/50 — but the STATE is different. Apply H and measure: you'd get different results.

Example 3: S gate on |+⟩ — subtler phase rotation

S's eigenvalues: \(\lambda_0 = +1\) for \(|0\rangle\), \(\lambda_1 = i\) for \(|1\rangle\).

Input: \(|+\rangle = \frac{1}{\sqrt{2}}|0\rangle + \frac{1}{\sqrt{2}}|1\rangle\)

Apply S:

\(|0\rangle\) component: \(\frac{1}{\sqrt{2}} \times (+1) = \frac{1}{\sqrt{2}}\)

\(|1\rangle\) component: \(\frac{1}{\sqrt{2}} \times (i) = \frac{i}{\sqrt{2}}\)

Output: \(\frac{1}{\sqrt{2}}|0\rangle + \frac{i}{\sqrt{2}}|1\rangle = |{+i}\rangle\)

Verdict: State moved from \(|+\rangle\) (X-axis) to \(|{+i}\rangle\) (Y-axis). The eigenvalue \(i\) rotated the \(|1\rangle\) component by 90° in the complex plane.

Still 50/50 measurement probabilities. But the relative phase changed from 0° to 90°.

Example 4: S gate on |0⟩ — eigenstate, nothing happens

Input: \(|0\rangle = 1\cdot|0\rangle + 0\cdot|1\rangle\)

Apply S:

\(|0\rangle\) component: \(1 \times (+1) = 1\)

\(|1\rangle\) component: \(0 \times (i) = 0\)

Output: \(|0\rangle\)

Verdict: Nothing happened. Only one component is nonzero, so there's nothing to create a relative phase against.

Example 5: T gate on |+⟩ — tiny phase rotation

T's eigenvalues: \(\lambda_0 = +1\) for \(|0\rangle\), \(\lambda_1 = e^{i\pi/4}\) for \(|1\rangle\).

Input: \(|+\rangle = \frac{1}{\sqrt{2}}|0\rangle + \frac{1}{\sqrt{2}}|1\rangle\)

Apply T:

\(|0\rangle\) component: \(\frac{1}{\sqrt{2}} \times (+1) = \frac{1}{\sqrt{2}}\)

\(|1\rangle\) component: \(\frac{1}{\sqrt{2}} \times e^{i\pi/4} = \frac{e^{i\pi/4}}{\sqrt{2}}\)

Output: \(\frac{1}{\sqrt{2}}|0\rangle + \frac{e^{i\pi/4}}{\sqrt{2}}|1\rangle\)

Verdict: State moved 45° around the equator (from \(|+\rangle\) toward \(|{+i}\rangle\), but only halfway). Relative phase = \(\pi/4\).

Apply T again → another 45° → total 90° → that's \(|{+i}\rangle\) → same as S.

Example 6: Z gate on |1⟩ — eigenstate, phase is global

Input: \(|1\rangle = 0\cdot|0\rangle + 1\cdot|1\rangle\)

Apply Z:

\(|0\rangle\) component: \(0 \times (+1) = 0\)

\(|1\rangle\) component: \(1 \times (-1) = -1\)

Output: \(-|1\rangle\)

Verdict: Output is \(-|1\rangle\). Looks different! But the minus sign is a global phase — it multiplies the ENTIRE state. \(-|1\rangle\) and \(|1\rangle\) are the same physical state. No measurement can tell them apart.

Only one component is nonzero, so the eigenvalue has nothing to be "relative" to.

Example 7: X gate on |+i⟩ — non-eigenstate, state changes

X's eigenvalues: \(\lambda_+ = +1\) for \(|+\rangle\), \(\lambda_- = -1\) for \(|-\rangle\).

But our input \(|{+i}\rangle = \frac{1}{\sqrt{2}}|0\rangle + \frac{i}{\sqrt{2}}|1\rangle\) isn't in the eigenbasis. To use eigenvalues, we'd need to rewrite it in the X-basis. Instead, let's just do the matrix multiply:

Input: \(|{+i}\rangle = \frac{1}{\sqrt{2}}\binom{1}{i}\)

Apply X: \(\begin{pmatrix}0&1\\1&0\end{pmatrix}\frac{1}{\sqrt{2}}\binom{1}{i} = \frac{1}{\sqrt{2}}\binom{i}{1}\)

Output: \(\frac{i}{\sqrt{2}}|0\rangle + \frac{1}{\sqrt{2}}|1\rangle\)

Factor out the global phase \(i\): \(= i \cdot \frac{1}{\sqrt{2}}(|0\rangle - i|1\rangle) = i\cdot|{-i}\rangle\)

Verdict: \(|{+i}\rangle \to |{-i}\rangle\) (ignoring global phase). X flipped the Y-axis state to its opposite — because \(|{+i}\rangle\) is NOT an eigenstate of X, so X rotates it.

The pattern

When does a gate "do something"?

A gate changes a state if and only if the state is a superposition of eigenstates with different eigenvalues.

The difference between the two eigenvalues is what determines how far the state moves. Z has eigenvalues +1 and −1 (difference = 180°, big move). T has eigenvalues 1 and \(e^{i\pi/4}\) (difference = 45°, small move).