• Mathematics

Unitary Operator

A linear operator U satisfying U†U = UU† = I, where U† is the conjugate transpose, which preserves the inner product (and hence probability) of quantum states and represents all reversible quantum operations including quantum gates.

Every quantum gate is a unitary operator. This is a consequence of quantum mechanics: time evolution of a closed system is always unitary, and any reversible quantum operation must preserve probability.

Definition

A square matrix UU is unitary if:

UU=UU=IU^\dagger U = U U^\dagger = I

so U1=UU^{-1} = U^\dagger. Unitary matrices are closed under multiplication (composing two gates gives another valid gate) and form the group U(n)U(n).

Probability conservation

Quantum states are unit vectors: ψψ=1\langle\psi|\psi\rangle = 1. After applying UU:

ψUUψ=ψψ=1\langle\psi|U^\dagger U|\psi\rangle = \langle\psi|\psi\rangle = 1

The norm is unchanged, so probabilities still sum to one. Any operation that failed this would create or destroy probability.

Parametrizing single-qubit unitaries

The special unitary group SU(2)SU(2) (unitaries with determinant 1) parametrizes all single-qubit gates up to a global phase:

U=(cos(θ/2)eiλsin(θ/2)eiϕsin(θ/2)ei(ϕ+λ)cos(θ/2))U = \begin{pmatrix} \cos(\theta/2) & -e^{i\lambda}\sin(\theta/2) \\ e^{i\phi}\sin(\theta/2) & e^{i(\phi+\lambda)}\cos(\theta/2) \end{pmatrix}

with three real parameters θ\theta, ϕ\phi, λ\lambda. Every single-qubit gate has this form.

Familiar examples

The Pauli matrices XX, YY, ZZ are both Hermitian and unitary; they are their own inverses:

X=(0110),Y=(0ii0),Z=(1001)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}

The Hadamard gate satisfies H=HH^\dagger = H and H2=IH^2 = I, so it too is its own inverse.

The rotation gates Rx(θ)=eiθX/2R_x(\theta) = e^{-i\theta X/2}, Ry(θ)=eiθY/2R_y(\theta) = e^{-i\theta Y/2}, Rz(θ)=eiθZ/2R_z(\theta) = e^{-i\theta Z/2} are the building blocks of variational circuits.

What is not unitary

Measurement is not unitary: it is irreversible. A projective measurement collapses the state and cannot be undone.

Noise channels map pure states to mixed states via Kraus operators kKkρKk\sum_k K_k \rho K_k^\dagger, where individual KkK_k are not unitary.

Connection to Hamiltonians

Every unitary can be written as U=eiHU = e^{iH} for some Hermitian HH. A qubit driven by Hamiltonian HH for time tt evolves as U=eiHt/U = e^{-iHt/\hbar}. This links gate-level descriptions to pulse-level hardware control.

Code example

import numpy as np
from numpy.linalg import qr

def is_unitary(M, tol=1e-10):
    return np.allclose(M.conj().T @ M, np.eye(M.shape[0]), atol=tol)

H = np.array([[1, 1], [1, -1]]) / np.sqrt(2)
print("Hadamard is unitary:", is_unitary(H))            # True

A = np.array([[1, 1], [0, 1]], dtype=complex)
print("Shear matrix is unitary:", is_unitary(A))         # False

# Random unitary via QR decomposition
rng = np.random.default_rng(42)
M = rng.standard_normal((4, 4)) + 1j * rng.standard_normal((4, 4))
Q, R = qr(M)
D = np.diag(R.diagonal() / np.abs(R.diagonal()))
print("Random 4x4 unitary:", is_unitary(Q @ D))          # True

See also