Gates are rotations
A quantum gate changes a qubit's state. For a single qubit, every gate does the same kind of thing to the Bloch sphere: it turns the whole sphere about an axis, by an angle. Learn a gate's axis and angle, and you know what it does to every state.
The turn is rigid, like turning a globe: every point moves together, the arrow with it, and points on the axis stay where they are.
Gates are matrices
In the math, a gate is a 2×2 matrix of complex numbers, and applying it multiplies the state's column vector:
A handy way to read a matrix: column j is where goes. The first column is , the second .
Gate matrices are unitary: they keep the total probability at 1, so the arrow stays on the sphere. That's exactly why each one is a rotation.
Every gate is a rotation
The gates on the app's gate bar, and the turn each one makes:
| Gate | Name | Turns the sphere |
|---|---|---|
| Pauli-X | 180° about x | |
| Pauli-Y | 180° about y | |
| Pauli-Z | 180° about z | |
| Hadamard | 180° about the x+z diagonal | |
| S gate | 90° about z | |
| T gate | 45° about z | |
| S-dagger | 90° about −z | |
| T-dagger | 45° about −z | |
| Rotation gates | θ about x, y or z |
Angles follow the right-hand rule: point your right thumb along the axis, and your fingers curl the way the sphere turns. Put another way, looking down at the sphere from the axis's tip, the turn is counterclockwise.
The states a gate leaves alone
A gate's axis meets the sphere at two opposite points, and the states there are the ones the gate doesn't move: it can only multiply each of them by a factor, which is a global phase. X leaves and where they are; Z, S and T leave and . Unless a gate does nothing at all, every other state moves.
In matrix language, these two states are the gate's eigenvectors, and their factors are its eigenvalues. The angle between the two factors is the angle of the turn. For S:
The factors and are 90° apart, and S is a 90° turn. For X, the factors on and are and , 180° apart: a half turn.
Different matrices, same rotation
Two matrices that differ only by a factor in front, such as or , make the same rotation: the factor is a global phase, which no measurement can detect. For example, Pauli-Z and the 180° rotation about z differ by a factor of :
In general, a rotation by θ about the unit axis is the matrix below, and every one-qubit gate is one of these times a phase :
Order matters
Two gates in a row are two turns in a row, and turns about different axes don't commute: doing them in the other order usually lands somewhere else. Starting from :
- H, then S: goes to .
- S, then H: goes to .
Written as matrices, "H, then S" is the product : the gate applied first stands nearest the state, on the right.
Undoing and combining
Every gate can be undone by turning back the same angle about the same axis. That reverse gate is written ("U dagger"): S† undoes S, and X, Y, Z and H, being half turns, undo themselves.
Any sequence of turns adds up to a single turn, so any sequence of gates is one gate. For example, H, then Z, then H is the same as X:
The Gate Lab shows this for any sequence you build.