Skip to content

Quantum Gates

A gate moves a state. The move can always be undone.

From Picture to Motion

On the previous page, a state became a point on a sphere. A point can sit anywhere on it, but we did not yet know how to move one.

BeforeA state is a point on a sphere
NowA point can sit anywhere, but we do not know how to move it

How can we move a state from one point to another?

You have already pressed the answer once. The "Apply mix (H)" button in What Is Quantum Computing? was a quantum gate, the first one you met. This page treats gates properly: what they do to a point, what they do to the probabilities, and what happens when one follows another.

What a Gate Is

A gate is a reversible operation that moves a state to another point. Three words are easy to mix up, so keep them apart:

  • Gate — an operation.
  • State — what the gate acts on.
  • Outcome — what a measurement shows.

Is a gate a measurement?

No. A gate moves a state and can be undone. A measurement gives 0 or 1, and no later gate undoes it. A gate does not read the state at all.

Here are the five gates this page starts with, and what each one does to the sphere:

Every gate here is a rotation of the sphere. X, Y, and Z each turn the point half way round, about one of the three axes. H does the same about an axis halfway between x and z. The table shows where each gate sends the six named states:

Read a column down. X sends |0⟩ to |1⟩ and |1⟩ to |0⟩, but |+⟩ stays where it is. H swaps |0⟩ with |+⟩. Every gate on this page can be undone: apply the gate again, or turn the other way.

Gate Explorer

Choose a start state, then press gates to add them one after another. The sphere shows where the state started and where it is now.

1. Choose a start state

2. Add gates (up to four)

Rotation gate: choose an axis and an angle

3. The chain

4. The result

The faded diamond is where the state started. The solid point is where it is now.

Result

The sphere, the chain, the description, and the bars each sit in their own place. The sphere is a picture of the state. The bars show what that state would give if it were measured in the Z basis.

Z and the Hidden Phase

On the Bloch sphere page, moving around the equator changed the state but not the height. The Z gate does exactly that: it turns the point half way round the vertical axis. Apply Z to |+⟩ and the point moves to |−⟩, at the same height.

The state changed, but the Z-basis probabilities did not. Z changes the phase, and nothing in an immediate Z-basis measurement shows it.

Phase is not invisible for good. Apply H to both states and look at the bars:

Before H, |+⟩ and |−⟩ look the same: 50% and 50%. After H, one is certain 0 and the other is certain 1. H turns a phase difference into a probability difference. This is how |+⟩ and |−⟩ can be told apart. A later page measures them with shots; here we only look at the probabilities.

Check your understanding. Predict first, then compare:

Rotation Gates

X, Y, and Z are half turns. A rotation gate generalizes them: choose an axis and an angle, and the point turns by that angle about the axis. X, Y, and Z are the 180° cases.

The turn follows the right-hand rule: viewed from the positive end of the axis, looking toward the centre, a positive angle turns the point counterclockwise.

Turn about z: the point moves around the equator and the height stays the same
Turn about x or y: the height changes
↓
The angle sets the result

Turning about z is the phase angle from the previous page, now as an operation. Try each axis and some angles in the explorer, starting from |0⟩.

Now try one yourself, using the explorer:

Use a rotation to make |0⟩ give outcome 1 about 25% of the time. Start from |0⟩, add a rotation, then check.

Order Matters, Sometimes

Gates are applied one after another, and a circuit diagram reads left to right. Does the order matter? Start at |+⟩ and load two chains into the explorer:

The same two gates, H and Z, give different points in different orders: H then Z ends at |0⟩, and Z then H ends at |1⟩. They also give different probabilities.

Some pairs do not care. X and Z give the same point in either order, the same move as the Y gate. The two results differ only by a shared overall phase, which the sphere does not show. So order can matter, and sometimes it does not.

Check your understanding:

Beyond the Core

Gates as matrices

A gate is a \(2\times 2\) matrix. It acts on the two amplitudes written as a column:

\[ \begin{pmatrix}\alpha'\\ \beta'\end{pmatrix} = \begin{pmatrix}a & b\\ c & d\end{pmatrix}\begin{pmatrix}\alpha\\ \beta\end{pmatrix} . \]

The five gates are

\[ I = \begin{pmatrix}1&0\\0&1\end{pmatrix},\quad X = \begin{pmatrix}0&1\\1&0\end{pmatrix},\quad Y = \begin{pmatrix}0&-i\\ i&0\end{pmatrix},\quad Z = \begin{pmatrix}1&0\\0&-1\end{pmatrix},\quad H = \frac{1}{\sqrt 2}\begin{pmatrix}1&1\\1&-1\end{pmatrix}. \]

Matrix–vector multiplication. Each new amplitude is a row of the matrix times the column. For \(H\) acting on \(|0\rangle = (1, 0)\):

\[ H|0\rangle = \frac{1}{\sqrt 2}\begin{pmatrix}1&1\\1&-1\end{pmatrix}\begin{pmatrix}1\\0\end{pmatrix} = \frac{1}{\sqrt 2}\begin{pmatrix}1\\1\end{pmatrix} = |+\rangle . \]

The explorer's matrix panel does this multiplication for each gate you apply, with the matrix, the input column, and the output column.

Y has imaginary entries. \(Y|0\rangle = i|1\rangle\). The amplitude \(i\) is a global phase, so on the sphere Y sends |0⟩ to |1⟩, as X does. Y is X and Z together, up to a global phase.

A worked check: HZH = X. Multiply the matrices, applying \(H\) first and \(H\) last, so the product is written right to left:

\[ HZH = \frac{1}{2}\begin{pmatrix}1&1\\1&-1\end{pmatrix}\begin{pmatrix}1&0\\0&-1\end{pmatrix}\begin{pmatrix}1&1\\1&-1\end{pmatrix} = \begin{pmatrix}0&1\\1&0\end{pmatrix} = X . \]

On the sphere: turn to the x axis, flip the phase, turn back. The net effect is a half turn about x.

Rotations, S and T, and inverses

Rotation matrices. A rotation by \(\theta\) turns the point by \(\theta\), and the amplitudes use the half angle:

\[ R_X(\theta) = \begin{pmatrix}\cos\frac\theta2 & -i\sin\frac\theta2\\ -i\sin\frac\theta2 & \cos\frac\theta2\end{pmatrix},\quad R_Y(\theta) = \begin{pmatrix}\cos\frac\theta2 & -\sin\frac\theta2\\ \sin\frac\theta2 & \cos\frac\theta2\end{pmatrix},\quad R_Z(\theta) = \begin{pmatrix}e^{-i\theta/2} & 0\\ 0 & e^{i\theta/2}\end{pmatrix}. \]

So \(R_Y(\theta)|0\rangle = \cos\frac\theta2\,|0\rangle + \sin\frac\theta2\,|1\rangle\), and the probability of outcome 1 is \(\sin^2(\theta/2)\). For \(\theta = 60^\circ\) it is \(\sin^2 30^\circ = 25\%\), the result of the transfer task above.

S and T. Two further gates turn the point about z: \(S\) by a quarter turn and \(T\) by an eighth of a turn. As matrices,

\[ S = \begin{pmatrix}1&0\\0&i\end{pmatrix},\qquad T = \begin{pmatrix}1&0\\0&e^{i\pi/4}\end{pmatrix}. \]

They add 90° and 45° to the phase angle. The explorer now offers both buttons.

Composing gates: two reading orders. Applying \(A\) first and then \(B\) gives the matrix product \(BA\). A circuit diagram and the explorer's chain read left to right, and the matrix product reads right to left:

  • Circuit and chain: H, then Z. Apply H first.
  • Matrix: \(ZH\). The gate applied first is written last, next to the state.

Order matters in the product too: \(ZH \neq HZ\) in general.

Inverse gates. The inverse of a gate is its conjugate transpose, \(U^\dagger\), and applying a gate and then its inverse gives the identity. \(X\), \(Y\), \(Z\), and \(H\) are their own inverses. The inverse of \(R_Y(\theta)\) is \(R_Y(-\theta)\), and the inverse of \(S\) is \(\operatorname{diag}(1, -i)\).

A global-phase caveat. A rotation gate and the named gate it matches can differ by a global factor. \(R_X(180^\circ) = -iX\), so \(X = i\,R_X(180^\circ)\). Likewise \(S = e^{i\pi/4}R_Z(90^\circ)\). The sphere and the probabilities cannot see a global factor, so the points are the same. The matrix panel shows the amplitudes as the multiplication gives them, global factors included.

Naming the formalism

Every ideal gate is a unitary operation: a reversible change that keeps the probabilities adding to 1. A small set of gates can be combined to approximate any single-qubit operation, which is called universality, and a gate can be broken into a product of simpler ones, a decomposition. Later material makes these ideas precise.

From One Qubit to Two

Compare what you can do now with what is still unknown.

So far
Move one qubit's state anywhere
Predict where it lands
Undo the move
Still unknown
Use more than one qubit
Write their outcomes together
Link them

Here are two qubits, each with its own state, side by side:

Each qubit can be moved with the gates above. One qubit's state is now something we can move and undo. We have not yet said what a second qubit adds.

Takeaway

A gate moves the point
↓
Height sets the probabilities, and Z changes phase only
↓
H makes phase visible, and a rotation's angle sets the result
↓
Order can matter, and every gate can be undone

A gate is a reversible move of a state. On the sphere each gate here is a rotation: Z changes phase only, H turns a phase difference into a probability difference, a rotation's angle sets the result, and the order of gates can matter.

What changes when there is more than one qubit?

Next: Multi-Qubit Systems →