Unitary and Hermitian Matrices
Unitary and Hermitian matrices are the complex versions of orthogonal and symmetric matrices. Unitary matrices preserve the complex inner product, Hermitian matrices have real eigenvalues, and both can be diagonalized by an orthonormal basis of .
The conjugate transpose
For a complex matrix , the conjugate transpose (adjoint) is : transpose, then conjugate every entry. It satisfies , , and the key identity for the complex inner product :
In NumPy, is A.conj().T; in SymPy, A.H.
Definitions side by side
| Real | Complex | Definition | Eigenvalues |
|---|---|---|---|
| symmetric () | Hermitian | real | |
| skew-symmetric () | skew-Hermitian | purely imaginary | |
| orthogonal () | unitary | on the unit circle, |
A Hermitian matrix has real numbers on its diagonal (since ) and mirrored conjugates off it, for example . A real matrix is Hermitian exactly when it is symmetric, and unitary exactly when it is orthogonal.
Unitary matrices
is unitary when its columns form an orthonormal basis of . Then:
- , so inverting costs nothing.
- : inner products and lengths are preserved.
- If with , then , so .
- .
The DFT matrix from the previous lesson, divided by , is unitary. So is every quantum gate.
Hermitian matrices and the spectral theorem
Real eigenvalues. If with and , then
and , so is real. The same calculation with two eigenvectors for different eigenvalues shows they are orthogonal. This is the argument from symmetric diagonalization, now done properly in .
Spectral theorem (complex). Every Hermitian matrix can be written with unitary and real diagonal. More generally, a complex matrix is unitarily diagonalizable exactly when it is normal, , which includes Hermitian, skew-Hermitian and unitary matrices.
import numpy as np
A = np.array([[2, 1 - 1j],
[1 + 1j, 3]])
print("Hermitian:", np.allclose(A, A.conj().T))
w, U = np.linalg.eigh(A)
print("eigenvalues (real):", np.round(w, 4))
print("U unitary:", np.allclose(U.conj().T @ U, np.eye(2)))
print("A = U diag(w) U*:", np.allclose(U @ np.diag(w) @ U.conj().T, A))
x = np.array([1 + 2j, -1j])
print("<Ax, x> is real for Hermitian A:", np.round(np.vdot(x, A @ x), 10))Hermitian: True
eigenvalues (real): [1. 4.]
U unitary: True
A = U diag(w) U*: True
<Ax, x> is real for Hermitian A: (7+0j)
The quadratic form of a Hermitian matrix is always real, so "positive definite" makes sense for Hermitian matrices just as in the real case.
Real rotations, diagonalized over
A real rotation matrix has no real eigenvectors, but it is orthogonal, hence unitary and normal, so it can be diagonalized by a unitary matrix with complex entries:
from sympy import Matrix, I, sqrt, simplify, symbols, cos, sin, exp
t = symbols("theta", real=True)
R = Matrix([[cos(t), -sin(t)], [sin(t), cos(t)]])
U = Matrix([[1, 1], [-I, I]]) / sqrt(2) # columns (1, -i)/√2 and (1, i)/√2
print("U unitary:", simplify(U.H * U) == Matrix.eye(2))
D = (U.H * R * U).applyfunc(lambda e: simplify(e.rewrite(exp)))
print("U* R U =", D.tolist())
print("|e^(i*theta)| =", simplify(abs(D[0, 0])))U unitary: True
U* R U = [[exp(I*theta), 0], [0, exp(-I*theta)]]
|e^(i*theta)| = 1
A rotation by is "multiply by " along one complex direction and by along the other, which connects to complex eigenvalues and the geometry of complex numbers.
In software
- Quantum computing. States are unit vectors in , gates are unitary matrices (so probabilities still add to 1), and measurable quantities (observables) are Hermitian matrices whose real eigenvalues are the possible measurement results.
- Signal processing. The normalized DFT is unitary, which is why the FFT preserves energy (Parseval) and inverts with a conjugate.
- Numerics.
np.linalg.eighaccepts complex Hermitian matrices; complex QR and SVD produce unitary factors. - Deep learning research. Unitary recurrent networks keep hidden-state norms constant to avoid exploding or vanishing gradients.
Exercises
Exercise 1: Recognize the type
Classify and .
Answer
is Hermitian and unitary; is unitary but not Hermitian.
Solution
, and . , but .
Exercise 2: Eigenvalues of a Hermitian matrix
Find the eigenvalues of .
Answer
−1 and 3.
Solution
Note . Both eigenvalues are real, as they must be.
Exercise 3: Make it unitary
For which real is unitary?
Answer
.
Solution
The columns and are orthogonal: . Each has squared length , which must be 1.
Exercise 4: Check a quantum gate (code)
The Hadamard gate is . Check that it is unitary and Hermitian, apply it to the state , and give the measurement probabilities.
Answer
, so each outcome has probability .
Solution
is real symmetric, so ; , so . The probabilities are each.
import numpy as np
H = np.array([[1, 1], [1, -1]]) / np.sqrt(2)
psi = H @ np.array([1.0, 0.0])
print(np.allclose(H.conj().T @ H, np.eye(2)), np.allclose(H, H.conj().T))
print(np.round(psi, 4), np.round(np.abs(psi) ** 2, 4))True True
[0.7071 0.7071] [0.5 0.5]
Test yourself
Which matrix is Hermitian?
Every eigenvalue of a unitary matrix satisfies…
- is real
- is purely imaginary
In quantum computing, gates are unitary because…
- they must have real entries
- they must preserve the total probability (the norm of the state)
- they must be diagonal
- they must be Hermitian