TExcelTAD
Home › Linear Algebra & Matrix Theory › Unitary and Hermitian Matrices

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 Cn\mathbb{C}^n.

The conjugate transpose

For a complex matrix AA, the conjugate transpose (adjoint) is A∗=AˉTA^* = \bar{A}^T: transpose, then conjugate every entry. It satisfies (AB)∗=B∗A∗(AB)^* = B^*A^*, (A∗)∗=A(A^*)^* = A, and the key identity for the complex inner product ⟨u,v⟩=v∗u\langle \mathbf{u}, \mathbf{v} \rangle = \mathbf{v}^*\mathbf{u}:

⟨Au,v⟩=⟨u,A∗v⟩\langle A\mathbf{u}, \mathbf{v} \rangle = \langle \mathbf{u}, A^*\mathbf{v} \rangle

In NumPy, A∗A^* is A.conj().T; in SymPy, A.H.

Definitions side by side

Real Complex Definition Eigenvalues
symmetric (AT=AA^T = A) Hermitian A∗=AA^* = A real
skew-symmetric (AT=−AA^T = -A) skew-Hermitian A∗=−AA^* = -A purely imaginary
orthogonal (QTQ=IQ^TQ = I) unitary U∗U=IU^*U = I on the unit circle, ∣λ∣=1\lvert \lambda \rvert = 1

A Hermitian matrix has real numbers on its diagonal (since aii=aii‾a_{ii} = \overline{a_{ii}}) and mirrored conjugates off it, for example [21−i1+i3]\begin{bmatrix} 2 & 1 - i \\ 1 + i & 3 \end{bmatrix}. A real matrix is Hermitian exactly when it is symmetric, and unitary exactly when it is orthogonal.

Unitary matrices

UU is unitary when its columns form an orthonormal basis of Cn\mathbb{C}^n. Then:

  • U−1=U∗U^{-1} = U^*, so inverting costs nothing.
  • ⟨Ux,Uy⟩=(Uy)∗Ux=y∗U∗Ux=y∗x=⟨x,y⟩\langle U\mathbf{x}, U\mathbf{y} \rangle = (U\mathbf{y})^*U\mathbf{x} = \mathbf{y}^*U^*U\mathbf{x} = \mathbf{y}^*\mathbf{x} = \langle \mathbf{x}, \mathbf{y} \rangle: inner products and lengths are preserved.
  • If Uv=λvU\mathbf{v} = \lambda\mathbf{v} with v≠0\mathbf{v} \ne \mathbf{0}, then ∥v∥=∥Uv∥=∣λ∣∥v∥\lVert \mathbf{v} \rVert = \lVert U\mathbf{v} \rVert = \lvert \lambda \rvert\lVert \mathbf{v} \rVert, so ∣λ∣=1\lvert \lambda \rvert = 1.
  • ∣det⁡U∣=1\lvert \det U \rvert = 1.

The DFT matrix from the previous lesson, divided by N\sqrt{N}, is unitary. So is every quantum gate.

Hermitian matrices and the spectral theorem

Real eigenvalues. If Av=λvA\mathbf{v} = \lambda\mathbf{v} with v≠0\mathbf{v} \ne \mathbf{0} and A∗=AA^* = A, then

λ⟨v,v⟩=⟨Av,v⟩=⟨v,A∗v⟩=⟨v,Av⟩=λˉ⟨v,v⟩\lambda\langle \mathbf{v}, \mathbf{v} \rangle = \langle A\mathbf{v}, \mathbf{v} \rangle = \langle \mathbf{v}, A^*\mathbf{v} \rangle = \langle \mathbf{v}, A\mathbf{v} \rangle = \bar{\lambda}\langle \mathbf{v}, \mathbf{v} \rangle

and ⟨v,v⟩>0\langle \mathbf{v}, \mathbf{v} \rangle > 0, so λ=λˉ\lambda = \bar{\lambda} 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 Cn\mathbb{C}^n.

Spectral theorem (complex). Every Hermitian matrix can be written A=UΛU∗A = U\Lambda U^* with UU unitary and Λ\Lambda real diagonal. More generally, a complex matrix is unitarily diagonalizable exactly when it is normal, A∗A=AA∗A^*A = AA^*, which includes Hermitian, skew-Hermitian and unitary matrices.

python · try it yourself
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 x∗Ax\mathbf{x}^*A\mathbf{x} 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 C\mathbb{C}

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:

python · try it yourself
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 θ\theta is "multiply by eiθe^{i\theta}" along one complex direction and by e−iθe^{-i\theta} along the other, which connects to complex eigenvalues and the geometry of complex numbers.

In software

  • Quantum computing. States are unit vectors in C2n\mathbb{C}^{2^n}, 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.eigh accepts 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 H=[0−ii0]H = \begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix} and S=[100i]S = \begin{bmatrix} 1 & 0 \\ 0 & i \end{bmatrix}.

Answer

HH is Hermitian and unitary; SS is unitary but not Hermitian.

Solution

H∗=[0i−i0]‾=[0−ii0]=HH^* = \overline{\begin{bmatrix} 0 & i \\ -i & 0 \end{bmatrix}} = \begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix} = H, and H∗H=H2=IH^*H = H^2 = I. S∗=[100−i]≠SS^* = \begin{bmatrix} 1 & 0 \\ 0 & -i \end{bmatrix} \ne S, but S∗S=diag⁡(1,(−i)(i))=diag⁡(1,1)=IS^*S = \operatorname{diag}(1, (-i)(i)) = \operatorname{diag}(1, 1) = I.

Exercise 2: Eigenvalues of a Hermitian matrix

Find the eigenvalues of [12i−2i1]\begin{bmatrix} 1 & 2i \\ -2i & 1 \end{bmatrix}.

Answer

−1 and 3.

Solution
det⁡[1−λ2i−2i1−λ]=(1−λ)2−(2i)(−2i)=(1−λ)2−4=0  ⟹  1−λ=±2  ⟹  λ=−1 or 3\begin{aligned} &\det \begin{bmatrix} 1 - \lambda & 2i \\ -2i & 1 - \lambda \end{bmatrix} = (1 - \lambda)^2 - (2i)(-2i) = (1 - \lambda)^2 - 4 = 0 \\ &\implies 1 - \lambda = \pm 2 \implies \lambda = -1 \text{ or } 3 \end{aligned}

Note (2i)(−2i)=−4i2=4(2i)(-2i) = -4i^2 = 4. Both eigenvalues are real, as they must be.

Exercise 3: Make it unitary

For which real aa is U=[aaa⋅i−a⋅i]U = \begin{bmatrix} a & a \\ a \cdot i & -a \cdot i \end{bmatrix} unitary?

Answer

a=±1/2a = \pm 1/\sqrt{2}.

Solution

The columns (a,ai)(a, ai) and (a,−ai)(a, -ai) are orthogonal: a⋅a+(ai)⋅−ai‾=a2+(ai)(ai)=a2−a2=0a \cdot a + (ai) \cdot \overline{-ai} = a^2 + (ai)(ai) = a^2 - a^2 = 0. Each has squared length a2+a2=2a2a^2 + a^2 = 2a^2, which must be 1.

Exercise 4: Check a quantum gate (code)

The Hadamard gate is H=12[111−1]H = \frac{1}{\sqrt{2}}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}. Check that it is unitary and Hermitian, apply it to the state (1,0)(1, 0), and give the measurement probabilities.

Answer

H(1,0)=(1/2,1/2)H(1, 0) = (1/\sqrt{2}, 1/\sqrt{2}), so each outcome has probability 12\frac{1}{2}.

Solution

HH is real symmetric, so H∗=HH^* = H; H2=IH^2 = I, so H∗H=IH^*H = I. The probabilities are ∣amplitude∣2=12\lvert \text{amplitude} \rvert^2 = \frac{1}{2} each.

python · try it yourself
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?

  1. [1ii1]\begin{bmatrix} 1 & i \\ i & 1 \end{bmatrix}
  2. [1i−i2]\begin{bmatrix} 1 & i \\ -i & 2 \end{bmatrix}
  3. [i001]\begin{bmatrix} i & 0 \\ 0 & 1 \end{bmatrix}
  4. [01−10]\begin{bmatrix} 0 & 1 \\ -1 & 0 \end{bmatrix}

Every eigenvalue λ\lambda of a unitary matrix satisfies…

  1. λ\lambda is real
  2. λ=1\lambda = 1
  3. ∣λ∣=1\lvert \lambda \rvert = 1
  4. λ\lambda is purely imaginary

In quantum computing, gates are unitary because…

  1. they must have real entries
  2. they must preserve the total probability (the norm of the state)
  3. they must be diagonal
  4. they must be Hermitian