Hadamard, S and T on the Bloch Sphere
The Hadamard gate is a half-turn about a diagonal axis, and S and T are partial twists about the vertical one. Seen on a live Bloch sphere, the H, S and T gates stop being matrices and start being furniture-moving.
Part 2 established that a single-qubit gate is a rotation, and worked through the three that turn 180° about the three coloured axes. This part relaxes both restrictions. The Hadamard gate rotates about an axis that is not drawn on the sphere at all, and the S and T gates turn by less than a half-turn.
H is a half-turn about the diagonal
Almost everyone first meets the Hadamard as “the gate that creates superposition”. That description is true and nearly useless, because it does not tell you what H does to anything except |0⟩.
Here is what it actually is. Reset the simulator and press H, catching it mid-rotation:
The axis is (X + Z)/√2: the direction exactly halfway between “up” and “toward |+⟩”. H is a 180° rotation about that diagonal. Nothing more.
Once you know the axis, everything about H follows without any matrix arithmetic. A half-turn about the diagonal swaps the two things the diagonal sits between. So H swaps the Z axis and the X axis:
H: |0⟩ ↔ |+⟩
|1⟩ ↔ |−⟩
Watch it land:
Two consequences fall straight out of the axis picture.
H is its own inverse. Two half-turns about the same axis make a full turn. Press H twice and you are home. That is why H appears in matched pairs at the start and end of so many circuits.
H swaps the X and Z bases. This is the real job of the Hadamard, and it is why “H then measure” is how you measure a qubit in the X basis. You cannot rotate your measuring device, so you rotate the qubit instead, bringing the axis you care about into line with the one the hardware can actually read. Part 5 returns to this.
The swap gives you a party trick that would be an exercise in matrix multiplication otherwise. What is H followed by Z followed by H? Z is a half-turn about the Z axis, but H has just swapped Z with X, so the whole sandwich must be a half-turn about the X axis. In other words, HZH should equal X. Press H, Z, H starting from |0⟩:
S and T only twist
The Pauli Z gate turns 180° about the vertical axis. S and T do the same thing, just less far:
- S turns 90° about Z.
- T turns 45° about Z.
They are partial Z rotations, which is why they are called phase gates. Everything Part 2 said about Z applies to them, only in smaller increments. In particular, they do nothing at all to the poles. Reset to |0⟩ and press S:
Phase gates need something to work with. Give the qubit a Hadamard first to get it onto the equator, then press S:
That quarter-turn is the whole gate. φ goes from 0° to 90°, the odds stay at 50/50, and the state is now genuinely different, as Part 1 explained.
T does the same in 45° steps. So four T gates in a row should add up to 180°, which is a Z gate. Reset, press H to get onto the equator, then press T four times:
φ reads 180°, the state is named |−⟩, and the probabilities never flinched. T⁴ = Z, straight off the readout.
Why T is the expensive one
S and T look like siblings on the sphere. One turns 90°, the other 45°. On real hardware they are anything but siblings, and the Bloch sphere quietly explains why.
Gates that map the six labelled points onto each other form the Clifford group. X, Y, Z, H and S are all Cliffords: every one of them sends a labelled axis endpoint to another labelled axis endpoint. You can check this on the sphere, and you have just watched most of it happen.
T does not. A 45° twist lands the arrow between labelled points, at a longitude no Clifford can reach. That makes T the odd one out, and it matters enormously: the Gottesman-Knill theorem says a Clifford-only circuit can be simulated efficiently on a classical computer. A Clifford-only quantum computer is not a quantum computer worth building. T is the gate that breaks out of the simulable set and buys you universality.
The bill arrives during error correction. Cliffords can usually be applied to error-corrected logical qubits fairly cheaply. T cannot, and has to be distilled from noisy magic states in a process that can dominate the entire resource budget of a fault-tolerant algorithm. When people quote “T-count” as the cost of a quantum algorithm, this 45° twist is what they are counting.
Confirming it in Qiskit
Each visual claim above, checked numerically.
import numpy as np
from qiskit.quantum_info import Statevector, Operator
H = Operator.from_label("H")
S = Operator.from_label("S")
T = Operator.from_label("T")
X = Operator.from_label("X")
Z = Operator.from_label("Z")
zero = Statevector([1, 0])
one = Statevector([0, 1])
plus = Statevector(np.array([1, 1]) / np.sqrt(2))
minus = Statevector(np.array([1, -1]) / np.sqrt(2))
# H swaps the Z basis with the X basis.
print("H|0> = |+> ?", zero.evolve(H).equiv(plus))
print("H|1> = |-> ?", one.evolve(H).equiv(minus))
print("H|+> = |0> ?", plus.evolve(H).equiv(zero))
print("HH = I ?", np.allclose(H.compose(H).data, np.eye(2)))
H|0> = |+> ? True
H|1> = |-> ? True
H|+> = |0> ? True
HH = I ? True
The HZH sandwich, which the screenshot showed landing on |1⟩:
# Operator.compose applies left to right, so this is "H, then Z, then H".
hzh = H.compose(Z).compose(H)
print("HZH = X (up to global phase) ?", Operator(hzh).equiv(X))
print("HZH|0> = |1> ?", zero.evolve(hzh).equiv(one))
HZH = X (up to global phase) ? True
HZH|0> = |1> ? True
And the phase gates, including the four-T stack:
i_state = Statevector(np.array([1, 1j]) / np.sqrt(2))
print("S does nothing to |0> ?", zero.evolve(S).equiv(zero))
print("S|+> = |i> ?", plus.evolve(S).equiv(i_state))
t4 = T.compose(T).compose(T).compose(T)
print("T^4 = Z ?", Operator(t4).equiv(Z))
print("S^2 = Z ?", Operator(S.compose(S)).equiv(Z))
# H then four T gates, the exact sequence in the screenshot.
final = plus.evolve(t4)
print("H then T,T,T,T = |-> ?", final.equiv(minus))
S does nothing to |0> ? True
S|+> = |i> ? True
T^4 = Z ? True
S^2 = Z ? True
H then T,T,T,T = |-> ? True
The state of play
You now have every gate in the simulator’s top two rows accounted for as a rotation:
| Gate | Axis | Angle |
|---|---|---|
| X, Y, Z | X, Y, Z | 180° |
| H | (X+Z)/√2, the diagonal | 180° |
| S | Z | 90° |
| S† | Z | −90° |
| T | Z | 45° |
| T† | Z | −45° |
The daggered gates are just the same twists run backwards, which is all an inverse is when every gate is a rotation. S† undoes S, and T† undoes T.
Which raises the obvious question. If a gate is just an axis and an angle, why be limited to the four axes and three angles somebody chose to put on the buttons? Why not any axis, any angle?
You can, and Part 4 hands you the slider.
Try it yourself: Interactive Bloch Sphere
Open full screen ↗Apply X, Y, Z, H, S, T, and rotation gates and watch the qubit state rotate in 3D in real time. It runs entirely in your browser, no signup or install.
Was this tutorial helpful?