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.
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
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.
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.
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.