> QUANTUM 04 :: quantum gates

Non-graded · offline · explore at your own pace

Single-qubit gates are rotations of the sphere

A classical NOT gate flips a bit. Quantum gates do something richer: each single-qubit gate is a 2×2 matrix that turns the qubit's vector, which on the Bloch sphere means rotating the arrow around an axis. Two-qubit gates such as CNOT can't be drawn as a rotation of one sphere. In the ideal model every gate can be undone and none destroys information. Measurement is the exception: it isn't a gate, and it can't be reversed.

X|0⟩= 0  11  010= 01=|1⟩

Matrix times vector: the same rule for every gate on this page. The 1 moved from the top row to the bottom row, so |0⟩ became |1⟩.

01 · Gate catalog

The single-qubit gates

Click a gate to see its matrix, what it does, and which axis it rotates around.

02 · The core idea

Gate lab: apply gates and watch the arrow turn

Try it: build a circuit one gate at a time

Choose a starting state, then apply gates. Each step shows the matrix multiplication and animates the rotation on the sphere.

drag to rotate the view

P(0)
P(1)
Watch for global phase: try Y on |0⟩. The result is i|1⟩, not |1⟩. That extra factor of i multiplies the whole state, so it changes no probabilities and doesn't move the arrow. Physicists call it a global phase and ignore it.

03 · Identities

Gates combine in surprising ways

Because gates are matrices, a sequence of gates multiplies into a single matrix. Some sequences collapse into something simple. Click one to run it from |0⟩ in the lab above, then check the result.

04 · Two qubits

CNOT: the gate that connects qubits

The controlled-NOT acts on two qubits. If the first (control) qubit is |1⟩, it flips the second (target). Otherwise it does nothing. Because two qubits have four basis states, CNOT is a 4×4 matrix.

CNOT (controlled-NOT, also CX) — the standard two-qubit gate. Together with single-qubit rotations it can build any quantum circuit. When the control is in superposition, CNOT creates entanglement.

Try it: set the inputs

Click the bits. The highlighted column of the matrix is your input, and the 1 in that column marks the output.

control
target
CNOT =
The cliffhanger: what if the control qubit is in superposition, say |+⟩? CNOT can't "decide" whether to flip, so the two qubits end up linked. That's entanglement, and it's the subject of page 05.

05 · Security connection

Reversible by design

Every quantum gate is unitary, meaning it can be run backward to recover the input exactly. Classical cryptographic hash functions are deliberately the opposite: they throw information away. Quantum algorithms like Shor's still evaluate math functions, but they must do it with reversible circuits, which is part of why they need so many qubits.

Unitary — a matrix U whose conjugate transpose U† is its inverse (U†U = I). Unitary operations preserve the total probability of 1 and can always be undone.
H GATE
Creates superposition. Every algorithm on the following pages begins with Hadamard gates.
CNOT
Creates entanglement. It's the workhorse inside quantum arithmetic, including Shor's modular exponentiation.
SUMMARY SLIDESView the Quantum 04 slide deck: Quantum Gates
PREVIOUS03 · The Bloch sphere