|q⟩ Bad Qubits

beginner · Physics · Math Foundations: Linear Algebra

Unitary Matrices

Definition

A square matrix UU with complex entries is unitary if its conjugate transpose equals its inverse:

U†U=UU†=I.U^\dagger U = U U^\dagger = I.

Equivalently, the columns of UU form an orthonormal set in Cn\mathbb{C}^n: each column has unit norm and every pair of distinct columns is orthogonal. The same is true of the rows.

Two ways to verify unitarity

Method 1 — column norms and inner products. Extract the columns c1,c2,…\mathbf{c}_1, \mathbf{c}_2, \ldots and check:

  1. ∥ck∥=1\|\mathbf{c}_k\| = 1 for every kk (unit norm).
  2. ⟨cj,ck⟩=0\langle \mathbf{c}_j, \mathbf{c}_k \rangle = 0 for every j≠kj \neq k (mutual orthogonality).

Method 2 — direct product. Compute U†UU^\dagger U explicitly and check that it equals the identity matrix II.

Both methods are equivalent; which is faster depends on the matrix.

Why unitarity is the right condition for quantum gates

In quantum mechanics a state ∣ψ⟩|\psi\rangle must remain normalised: ⟨ψ∣ψ⟩=1\langle \psi | \psi \rangle = 1. If evolution is described by a matrix UU, the evolved state is ∣ψ′⟩=U∣ψ⟩|\psi'\rangle = U|\psi\rangle. Normalisation after evolution requires

⟨ψ′∣ψ′⟩=⟨ψ∣U†U∣ψ⟩=1\langle \psi' | \psi' \rangle = \langle \psi | U^\dagger U | \psi \rangle = 1

for every choice of ∣ψ⟩|\psi\rangle. The only matrices that satisfy this for all unit vectors ∣ψ⟩|\psi\rangle are the unitary matrices U†U=IU^\dagger U = I. Unitarity is therefore the algebraic expression of conservation of total probability.

Key properties of unitary matrices

From the definition several useful facts follow immediately.

Determinant has unit modulus. If U†U=IU^\dagger U = I then det⁡(U†)det⁡(U)=1\det(U^\dagger)\det(U) = 1, so ∣det⁡(U)∣2=1|\det(U)|^2 = 1 and therefore ∣det⁡(U)∣=1|\det(U)| = 1. The determinant lies on the unit circle in the complex plane but is not necessarily 11.

Eigenvalues have unit modulus. If U ∣ψ⟩=λ ∣ψ⟩U\,|\psi\rangle = \lambda\,|\psi\rangle then ∥λ ∣ψ⟩∥=∥U ∣ψ⟩∥=∥∣ψ⟩∥\|\lambda\,|\psi\rangle\| = \|U\,|\psi\rangle\| = \||\psi\rangle\|, which forces ∣λ∣=1|\lambda| = 1.

Unitary matrices form a group. The product of two unitary matrices is unitary: (UV)†(UV)=V†U†UV=V†V=I(UV)^\dagger(UV) = V^\dagger U^\dagger UV = V^\dagger V = I. The inverse of a unitary matrix is its conjugate transpose, also unitary. This group structure matches the physical requirement that composing two valid quantum operations gives another valid quantum operation.

A worked example — the Hadamard matrix

The Hadamard matrix is

H=12(111−1).H = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}.

Its entries are real, so H†=HTH^\dagger = H^T. Let us compute H†HH^\dagger H directly.

Reading off the columns, the first column is c1=12(11)\mathbf{c}_1 = \tfrac{1}{\sqrt{2}}\binom{1}{1} and the second is c2=12(1−1)\mathbf{c}_2 = \tfrac{1}{\sqrt{2}}\binom{1}{-1}.

Column norms:

∥c1∥2=(12)2+(12)2=12+12=1,∥c2∥2=(12)2+(−12)2=12+12=1.\|\mathbf{c}_1\|^2 = \left(\frac{1}{\sqrt{2}}\right)^2 + \left(\frac{1}{\sqrt{2}}\right)^2 = \frac{1}{2} + \frac{1}{2} = 1, \qquad \|\mathbf{c}_2\|^2 = \left(\frac{1}{\sqrt{2}}\right)^2 + \left(\frac{-1}{\sqrt{2}}\right)^2 = \frac{1}{2} + \frac{1}{2} = 1.

Cross inner product:

⟨c1,c2⟩=12⋅12+12⋅−12=12−12=0.\langle \mathbf{c}_1, \mathbf{c}_2 \rangle = \frac{1}{\sqrt{2}}\cdot\frac{1}{\sqrt{2}} + \frac{1}{\sqrt{2}}\cdot\frac{-1}{\sqrt{2}} = \frac{1}{2} - \frac{1}{2} = 0.

Both columns are unit vectors and they are orthogonal, so HH is unitary: H†H=IH^\dagger H = I. Equivalently, since HH is also symmetric (HT=HH^T = H) and H†H=IH^\dagger H = I, we have H=H−1H = H^{-1}, confirming that H2=IH^2 = I — applying the Hadamard gate twice returns any state to its original form.

Complex unitary matrices

The condition U†U=IU^\dagger U = I extends beyond real orthogonal matrices. Consider the phase matrix

P(θ)=(eiθ00e−iθ).P(\theta) = \begin{pmatrix} e^{i\theta} & 0 \\ 0 & e^{-i\theta} \end{pmatrix}.

Here P(θ)†=(e−iθ00eiθ)P(\theta)^\dagger = \begin{pmatrix} e^{-i\theta} & 0 \\ 0 & e^{i\theta} \end{pmatrix}, so

P(θ)†P(θ)=(e−iθeiθ00eiθe−iθ)=(1001)=I.P(\theta)^\dagger P(\theta) = \begin{pmatrix} e^{-i\theta}e^{i\theta} & 0 \\ 0 & e^{i\theta}e^{-i\theta} \end{pmatrix} = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix} = I.

This matrix is unitary for every real θ\theta even though its entries are in general not real. The standard quantum gates S=(100i)S = \begin{pmatrix} 1 & 0 \\ 0 & i \end{pmatrix} and T=(100eiπ/4)T = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\pi/4} \end{pmatrix} are diagonal unitaries of exactly this kind — each column is a unit-modulus phase times a standard basis vector — and they appear throughout quantum computing. They coincide with members of the family P(θ)P(\theta) only up to an overall global phase (for example P(π/4)=eiπ/4 diag(1,e−iπ/2)P(\pi/4) = e^{i\pi/4}\,\mathrm{diag}(1, e^{-i\pi/2})), and such a global phase has no physical effect.

Try it

This is a numerical exercise — your code should return a number, not a circuit. The Hadamard matrix H=12(111−1)H = \tfrac{1}{\sqrt{2}}\begin{pmatrix}1&1\\1&-1\end{pmatrix} is real, so H†=HTH^\dagger = H^T. Compute the (0,0)(0,0) entry of H†HH^\dagger H. A unitary matrix satisfies H†H=IH^\dagger H = I, so the result should be exactly 11.

Run your code to see the quantum state.

Sign in on the full site to ask questions and join the discussion.