Computing Library › Quantum Foundations
Quantum Foundations

Quantum Gates as Unitaries

Every quantum gate is a unitary matrix; circuits are products of these matrices acting on the qubit register.

Gates are matrices

In the circuit model, computation is a sequence of gates, and each gate is a unitary matrix. A single-qubit gate is a 2x2 unitary; a k-qubit gate is a 2^k by 2^k unitary. Applying a gate means multiplying the state vector by that matrix.

Common single-qubit gates

Kronos motion — thermal gate
Hadamard (times 1/sqrt2)
111-1

Reversibility

Because every gate is unitary and therefore invertible, quantum circuits are reversible: for each gate U there is U-dagger that undoes it. Classical irreversible gates like AND must be embedded in reversible form (for example the Toffoli gate) before they fit the quantum model. This reversibility is not optional — it follows from the physics.

Building any unitary

A finite universal gate set can approximate any unitary to arbitrary accuracy. A common choice is {H, T, CNOT}. The Solovay-Kitaev theorem guarantees efficient approximation, so hardware need only implement a small set of primitive gates and compilers synthesise the rest.

Composition

Gates applied in sequence compose by matrix multiplication, and applied in parallel on different qubits they compose by tensor product. Note the ordering: a circuit that applies A then B corresponds to the matrix B A, because the later gate multiplies on the left of the state vector.

python
import numpy as np
H = np.array([[1,1],[1,-1]])/np.sqrt(2)
print(np.round(H@H@np.array([1,0]),9))  # H twice = identity -> [1 0]