Skip to content
Tutorials Center
My learning

Topics

Lesson 44 of 62 ยท Eigenvalues and Decompositions

Complex Matrices: Conjugate Transpose, Hermitian and Unitary

Extend linear algebra to complex numbers: conjugate transpose, complex inner products, Hermitian and unitary matrices, the Fourier matrix, all in NumPy.

Real matrices sometimes have complex eigenvalues (a rotation, for example), so complex numbers cannot be avoided for long. Many applications use complex matrices from the start: signal processing, quantum mechanics, electrical engineering. The good news is that almost everything you know carries over. The one change you must internalize is that the transpose becomes the conjugate transpose.

This lesson explains why, defines the complex inner product and length, and introduces the complex counterparts of symmetric and orthogonal matrices: Hermitian and unitary matrices. It assumes you have seen special matrices, eigenvalues and the spectral theorem.

Complex numbers in one paragraph

A complex number is z = a + bi with iยฒ = -1. Its conjugate is zฬ„ = a - bi. The product z zฬ„ = aยฒ + bยฒ is a non-negative real number, and its square root is the modulus |z|. In Python, 1 + 2j is a complex number, z.conjugate() or np.conj(z) is its conjugate, and abs(z) is the modulus. A NumPy array holds complex numbers when its dtype is complex128.

Why the transpose must change

For a real vector x, the squared length is xแต€x = xโ‚ยฒ + ... + xโ‚™ยฒ. For a complex vector such as x = (1, i), that formula gives 1 + iยฒ = 0: a nonzero vector with zero length, which is nonsense. The fix is to conjugate while transposing. The conjugate transpose (or Hermitian adjoint) of A is

TEXT
A^H = (ฤ€)^T          so  (A^H)[i, j] = conj(A[j, i])

and the complex inner product of two vectors is โŸจx, yโŸฉ = y^H x, giving the length โ€–xโ€–ยฒ = x^H x = ฮฃ |x_i|ยฒ. Now x = (1, i) has length sqrt(2), and every nonzero vector has a positive length.

In NumPy, A.conj().T is the conjugate transpose, and np.vdot(y, x) computes y^H x (it conjugates its first argument). The rules look like the real ones with one twist: (AB)^H = B^H A^H, (A^H)^H = A, and (cA)^H = cฬ„ A^H.

Hermitian matrices

A square matrix is Hermitian if A^H = A. This means A[j, i] = conj(A[i, j]): the diagonal must be real, and entries mirrored across the diagonal are conjugates of each other. A real symmetric matrix is a Hermitian matrix. Example:

TEXT
[ 2      1 - i ]
[ 1 + i    3   ]

Hermitian matrices have the same wonderful properties as symmetric ones:

  • All eigenvalues are real. (If Av = ฮปv, then ฮป โ€–vโ€–ยฒ = v^H A v, and this number equals its own conjugate, so ฮป is real.)
  • Eigenvectors for different eigenvalues are orthogonal in the complex sense.
  • A Hermitian matrix can be diagonalized as A = U ฮ› U^H with U unitary and ฮ› real: the complex spectral theorem. Use np.linalg.eigh, which handles Hermitian input and returns real eigenvalues.

In quantum mechanics, observable quantities are represented by Hermitian matrices precisely because measurements must be real numbers. A matrix with A^H = -A is skew-Hermitian, and its eigenvalues are purely imaginary. You can write any square matrix as the sum of a Hermitian and a skew-Hermitian part, exactly as with the symmetric/skew split.

Unitary matrices

A square matrix U is unitary if U^H U = I, so U^(-1) = U^H. It is the complex version of an orthogonal matrix, with the same key properties:

  • The columns form an orthonormal set (under the complex inner product).
  • It preserves lengths and inner products: โ€–Uxโ€– = โ€–xโ€–.
  • Every eigenvalue has modulus 1 (a point on the unit circle), and |det U| = 1.
  • Products and inverses of unitary matrices are unitary.

The most famous example is the discrete Fourier transform (DFT) matrix: entry (j, k) is ฯ‰^(jk) / sqrt(n) with ฯ‰ = e^(-2ฯ€i/n). Multiplying a signal by it reveals its frequencies, and its unitarity says that the energy of a signal is the same in the time and frequency domains. (np.fft.fft computes the same thing quickly without building the matrix, scaled by sqrt(n).)

Python Conjugate transpose, Hermitian eigenvalues and the unitary Fourier matrix

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Normal matrices and the complex spectral theorem

A matrix is normal if it commutes with its conjugate transpose: A A^H = A^H A. Hermitian, skew-Hermitian and unitary matrices are all normal. The spectral theorem in its general form says: a matrix can be diagonalized by a unitary matrix, A = U ฮ› U^H, if and only if it is normal. A rotation matrix in 2D is not symmetric, so over the reals it cannot be diagonalized by an orthogonal matrix, but it is normal, so over the complex numbers it can: its eigenvalues are e^(ยฑiฮธ), and its eigenvectors are (1, โˆ“i)/sqrt(2).

Python A real rotation diagonalized over the complex numbers

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Do not write A.T when you mean A^H for complex data. NumPy will happily transpose without conjugating, and your results will silently be wrong: negative "squared lengths", complex "variances" and Gram matrices that are not Hermitian. Use A.conj().T.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What is the conjugate transpose of [[1, 2i], [3, 4]]?

    Transpose swaps rows and columns to give [[1, 3], [2i, 4]], then conjugating turns 2i into -2i.
  2. 2. What do all Hermitian matrices have in common?

    Hermitian matrices can have complex entries but their eigenvalues are always real.
  3. 3. Which condition defines a unitary matrix U?

    U^H U = I, equivalently U^-1 = U^H. Option 3 describes Hermitian matrices.
  4. 4. All eigenvalues of a unitary matrix have which property?

    Unitary matrices preserve length, so |lambda| = 1. The eigenvalues lie on the complex unit circle.
  5. 5. Why does the length of x = (1, i) need x^H x instead of x^T x?

    1^2 + i^2 = 0 for a nonzero vector. Conjugating gives |1|^2 + |i|^2 = 2.

Summary

  • Replace the transpose with the conjugate transpose A^H = conj(A)^T; lengths come from x^H x = ฮฃ |x_i|ยฒ.
  • Hermitian (A^H = A) matrices have real eigenvalues and orthogonal eigenvectors; they generalize symmetric matrices. Use np.linalg.eigh.
  • Unitary (U^H U = I) matrices preserve lengths, have eigenvalues of modulus 1 and generalize orthogonal matrices; the DFT matrix is the classic example.
  • A matrix is unitarily diagonalizable exactly when it is normal (A A^H = A^H A), which includes real rotations.
  • In NumPy, use .conj().T and np.vdot, never a plain .T, with complex data.

Next: Singular Value Decomposition, which works for every matrix, real or complex.