The Language of Qubits

Gates Are Just Grids

10 min

A gate is a grid of numbers. Applying it means multiplying that grid by your column. For one qubit the grid is 2×2, and you can genuinely do it in your head.

Four gates that cover most of the course
X =0110Z =100−1H =111−1S =100i

H carries an overall factor of 1/√2 so that its columns stay unit length.

Every quantum gate is a unitary matrix: it is reversible, and it preserves total probability. Run any of these twice and X, Z and H each return you to where you started.

One worked out slowly

Apply H to a plain 0:

H|0⟩ = (1/√2) [ 1   1 ] [ 1 ]  =  (1/√2) [ 1 ]  =  |+⟩
               [ 1  −1 ] [ 0 ]            [ 1 ]

The (1, 0) picks out the first column of the grid, and that is your answer. Now apply H again:

H|+⟩ = (1/√2) [ 1   1 ] (1/√2) [ 1 ]  =  ½ [ 2 ]  =  |0⟩
               [ 1  −1 ]        [ 1 ]        [ 0 ]

Look at the bottom number: 1 − 1 = 0.

That zero is the cancelling from Fundamentals lesson seven, written out as arithmetic. There it is. That is all it ever was.

What makes a grid a legal gate

It has to be unitary. The formal test is U†U = I, and the dagger means "flip the grid over its diagonal and mirror every arrow".

Two things follow, and they are the two you will use:

  • You can undo it. Every gate has an opposite.
  • The total stays 1. Feed it a valid qubit and you get a valid qubit back.

The dagger (†)

Flip the grid diagonally, then mirror every number. For grids of plain old numbers it is just the diagonal flip. Say it out loud as "H dagger".

Stacking gates is just multiplying grids

Run H, then Z, then H. That whole thing is one grid: H·Z·H. Work it out and you get X — the flip.

Mind the order, though. The gate you do first is written last. Pictures read left to right; these read right to left.

Two qubits means a bigger grid

Two qubits have four possible readings — 00, 01, 10, 11 — so the grid is 4×4:

CNOT =1000010000010010

It is the do-nothing grid with the bottom two rows swapped over. In words: leave 00 and 01 alone, swap 10 and 11. Which is exactly "flip the second qubit when the first is a 1".

Worth remembering

  • Applying a gate is grid times column. For one qubit you can do it by hand.
  • Unitary means you can undo it and the total stays 1.
  • Stacked gates multiply — but the first gate is written last.
  • Two qubits need a 4×4 grid. CNOT is the plain grid with two rows swapped.