Skip to content

Eigen Decomposition

Prasant Chidella edited this page Aug 18, 2014 · 1 revision

If there is a square (n x n) matrix A, and if there exist a non zero vector v of dimension N and a scalar λ such that
                         Av = λv
then v is said to be an eigenvector of the matrix A, and λ is termed as the eigenvalue of A corresponding to v. The eigenvectors can be thought of as vectors being elongated or shrunk by the linear transformation A, and their corresponding eigenvalues denote the extent or degree of shrinking/elongation.
Some basic algebraic manipulation gives us
                         Av = λv
                         Av = λIv
                         Av-λIv = 0
                         (A-λI)v = 0
Since v is a non zero vector, this means
                         A-λI must be singular
                         p(λ) := det(A-λI) = 0
this is the characteristic equation for eigenvalues. It will have Nλ solutions where 1 ≤ Nλ ≤ N. Any multiple of an eigenvector is also an eigenvector with the same corresponding eigenvalue.

Eigen Decomposition

If A is a diagonalizable square matrix of size n x n with N linearly independent eigenvectors, q1,. . .,qN, then A can be decomposed into a product of three matrices as:
                         A = QΛQ-1
where Q is an n x n matrix whose ith column is qi, the ith eigen vector of A. and Λ is a diagonal matrix whose diagonal elements are the eigenvalues corresponding to A's eigen vectors. i.e. Λii = qi.
Generally when a matrix is factorized in this way, the eigenvectors are normalized.

you can use the linear/eigen function in core.matrix to perform eigen decomposition on a Matrix.

(let [{:keys [Q rA iA]} (eigen M)] ....)
(let [{:keys [Q rA]} (eigen M {:return [:Q :rA]})] ....)

Inverting a matrix

If we have the eigen decomposition of a matrix A as A = QΛQ-1,
if any of the eigen values are 0, then A is singular and hence doesn't have an inverse, otherwise the inverse of A is:
                         A = QΛQ-1
                         A-1 = (QΛQ-1)-1
                         A-1 = (Q-1)-1Λ-1Q-1
                         A-1 = QΛ-1Q-1
And since Λ is a diagonal matrix, its inverse can be computed easily:
                         [Λ-1]ii = λ-1i

Exponent of a matrix

To compute the nth power of a matrix, we can use eigen decomposition.
If A is eigendecomposed as A = QΛQ-1
                         A2 = (QΛQ-1)2
                         A2 = QΛQ-1QΛQ-1
                         A2 = QΛΛQ-1
                         A2 = QΛ2Q-1
and similarly,
                         An = QΛn-1Q-1QΛQ-1
                         An = QΛn-1ΛQ-1
                         An = QΛnQ-1

Some properties of eigen decomposition

  • i.e. Determinant of A is the same as the product of eigen values of A.
  • i.e. Trace of A is the same as the sum of eigen values of A.
  • Eigen values of A-1 are λ-1i.
  • Eigen values of An are λni.
  • Eigen vectors of A-1 are same as eigen vectors of A.
  • A is invertible if an only if all of its eigen values are non zero.

Eigen decomposition for real symmetric matrices

If the square matrix A being decomposed is symmetric, the eigenvectors can be made to be such that they are real, orthogonal to each other and have norm equal to 1. So the factorization of A as A = QΛQT, where Q is an orthogonal matrix.

With core.matrix, a user can use an optimized algorithm for symmetric matrices which is master that the general purpose eigen decomposition algorithm. This can be done by by passing a :symmetric symbol in the options map.

(let [{:keys [Q rA iA]} (eigen M {:symmetric true)] ....)