|q⟩ Bad Qubits

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

The T Gate

Every single-qubit gate can be understood as a rotation or reflection on the Bloch sphere. The T gate is a rotation about the zz-axis by π4\frac{\pi}{4} radians — exactly 45°. Its matrix is

T=(100eiπ/4).T = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\pi/4} \end{pmatrix}.

It leaves 0|0\rangle untouched and multiplies the amplitude of 1|1\rangle by the complex number eiπ/4=12+i2e^{i\pi/4} = \tfrac{1}{\sqrt{2}} + \tfrac{i}{\sqrt{2}}.

Relative phase vs. global phase

A global phase on the whole state vector is physically unobservable: eiθψe^{i\theta}|\psi\rangle and ψ|\psi\rangle give identical measurement probabilities for any observable. A relative phase between two components of a superposition is different — it genuinely changes the quantum state and can be revealed by a later gate.

For the equal superposition +=12(0+1)|+\rangle = \tfrac{1}{\sqrt{2}}(|0\rangle + |1\rangle), applying TT gives

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

The 0|0\rangle amplitude is still 12\tfrac{1}{\sqrt{2}}; the 1|1\rangle amplitude has rotated by 45° in the complex plane. Measuring right now still gives 50/50 — the Born-rule probabilities only depend on magnitudes. The phase difference becomes physically meaningful when you follow TT with another gate that mixes the two components (such as a second Hadamard).

The TT^\dagger gate

The inverse of TT is called TT^\dagger (or Tdg\text{Tdg}) and applies a 45°-45° phase to 1|1\rangle:

T=(100eiπ/4).T^\dagger = \begin{pmatrix} 1 & 0 \\ 0 & e^{-i\pi/4} \end{pmatrix}.

You will need TT^\dagger whenever you want to undo a TT step, for example when uncomputing an ancilla register.

Try it

Starting from 0|0\rangle, the starter code applies HH to create +|+\rangle. Your task is to follow it with a TT gate so the final state is 12(0+eiπ/41)\tfrac{1}{\sqrt{2}}\bigl(|0\rangle + e^{i\pi/4}|1\rangle\bigr). After pressing Run, look at the amplitude of 1|1\rangle in the state-vector panel: it should point at 45°45° in the complex plane rather than along the positive real axis.

Run your code to see the quantum state.

Notice that the probabilities remain 50/50 — phase does not show up in a straight measurement. The visible difference is in the complex amplitude of 1|1\rangle: its angle has rotated from 0° to 45°45°.

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