Jacobi eigenvalue algorithm

Last updated

In numerical linear algebra, the Jacobi eigenvalue algorithm is an iterative method for the calculation of the eigenvalues and eigenvectors of a real symmetric matrix (a process known as diagonalization). It is named after Carl Gustav Jacob Jacobi, who first proposed the method in 1846, [1] but only became widely used in the 1950s with the advent of computers. [2]

Contents

Description

Let be a symmetric matrix, and be a Givens rotation matrix. Then:

is symmetric and similar to .

Furthermore, has entries:

where and .

Since is orthogonal, and have the same Frobenius norm (the square-root sum of squares of all components), however we can choose such that , in which case has a larger sum of squares on the diagonal:

Set this equal to 0, and rearrange:

if

In order to optimize this effect, Sij should be the off-diagonal element with the largest absolute value, called the pivot.

The Jacobi eigenvalue method repeatedly performs rotations until the matrix becomes almost diagonal. Then the elements in the diagonal are approximations of the (real) eigenvalues of S.

Convergence

If is a pivot element, then by definition for . Let denote the sum of squares of all off-diagonal entries of . Since has exactly off-diagonal elements, we have or . Now . This implies or ; that is, the sequence of Jacobi rotations converges at least linearly by a factor to a diagonal matrix.

A number of Jacobi rotations is called a sweep; let denote the result. The previous estimate yields

;

that is, the sequence of sweeps converges at least linearly with a factor ≈ .

However the following result of Schönhage [3] yields locally quadratic convergence. To this end let S have m distinct eigenvalues with multiplicities and let d > 0 be the smallest distance of two different eigenvalues. Let us call a number of

Jacobi rotations a Schönhage-sweep. If denotes the result then

.

Thus convergence becomes quadratic as soon as

Cost

Each Givens rotation can be done in O(n) steps when the pivot element p is known. However the search for p requires inspection of all N  1/2 n2 off-diagonal elements. We can reduce this to O(n) complexity too if we introduce an additional index array with the property that is the index of the largest element in row i, (i = 1, ..., n  1) of the current S. Then the indices of the pivot (k, l) must be one of the pairs . Also the updating of the index array can be done in O(n) average-case complexity: First, the maximum entry in the updated rows k and l can be found in O(n) steps. In the other rows i, only the entries in columns k and l change. Looping over these rows, if is neither k nor l, it suffices to compare the old maximum at to the new entries and update if necessary. If should be equal to k or l and the corresponding entry decreased during the update, the maximum over row i has to be found from scratch in O(n) complexity. However, this will happen on average only once per rotation. Thus, each rotation has O(n) and one sweep O(n3) average-case complexity, which is equivalent to one matrix multiplication. Additionally the must be initialized before the process starts, which can be done in n2 steps.

Typically the Jacobi method converges within numerical precision after a small number of sweeps. Note that multiple eigenvalues reduce the number of iterations since .

Algorithm

The following algorithm is a description of the Jacobi method in math-like notation. It calculates a vector e which contains the eigenvalues and a matrix E which contains the corresponding eigenvectors; that is, is an eigenvalue and the column an orthonormal eigenvector for , i = 1, ..., n.

procedure jacobi(SRn×n; outeRn; outERn×n)   vari, k, l, m, stateNs, c, t, p, y, d, rRindNnchangedLnfunction maxind(kN) ∈ N ! index of largest off-diagonal element in row km := k+1     fori := k+2 tondoifSki│ > │Skmthenm := iendifendforreturnmendfuncprocedure update(kN; tR) ! update ek and its statusy := ek; ek := y+tifchangedk and (y=ek) thenchangedk := false; state := state−1     elsif (not changedk) and (yek) thenchangedk := true; state := state+1     endifendprocprocedure rotate(k,l,i,jN) ! perform rotation of Sij, Skl┐    ┌     ┐┌ ┐     │Skl│    │cs││Skl│     │ │ := │     ││ │     │Sij│    │sc││Sij│     └ ┘    └     ┘└ endproc    ! init e, E, and arrays ind, changedE := I; state := nfork := 1 tondoindk := maxind(k); ek := Skk; changedk := true endforwhilestate≠0 do ! next rotationm := 1 ! find index (k,l) of pivot pfork := 2 ton−1 doifSk indk│ > │Sm indmthenm := kendifendfork := m; l := indm; p := Skl     ! calculate c = cos φ, s = sin φy := (elek)/2; d := │y│+√(p2+y2)     r := √(p2+d2); c := d/r; s := p/r; t := p2/dify<0 thens := −s; t := −tendifSkl := 0.0; update(k,−t); update(l,t)     ! rotate rows and columns k and lfori := 1 tok−1 do rotate(i,k,i,l) endforfori := k+1 tol−1 do rotate(k,i,i,l) endforfori := l+1 tondo rotate(k,i,l,i) endfor     ! rotate eigenvectorsfori := 1 tondo┐    ┌     ┐┌ ┐       │Eik│    │cs││Eik│       │ │ := │     ││ │       │Eil│    │sc││Eil│       └ ┘    └     ┘└ endfor     ! update all potentially changed indifori := 1 tondoindi := maxind(i) endforloopendproc

Notes

1. The logical array changed holds the status of each eigenvalue. If the numerical value of or changes during an iteration, the corresponding component of changed is set to true, otherwise to false. The integer state counts the number of components of changed which have the value true. Iteration stops as soon as state = 0. This means that none of the approximations has recently changed its value and thus it is not very likely that this will happen if iteration continues. Here it is assumed that floating point operations are optimally rounded to the nearest floating point number.

2. The upper triangle of the matrix S is destroyed while the lower triangle and the diagonal are unchanged. Thus it is possible to restore S if necessary according to

fork := 1 ton−1 do ! restore matrix Sforl := k+1 tondoSkl := Slkendforendfor

3. The eigenvalues are not necessarily in descending order. This can be achieved by a simple sorting algorithm.

fork := 1 ton−1 dom := kforl := k+1 tondoifel > emthenm := lendifendforifkmthen         swap em,ek         swap Em,Ekendifendfor

4. The algorithm is written using matrix notation (1 based arrays instead of 0 based).

5. When implementing the algorithm, the part specified using matrix notation must be performed simultaneously.

6. This implementation does not correctly account for the case in which one dimension is an independent subspace. For example, if given a diagonal matrix, the above implementation will never terminate, as none of the eigenvalues will change. Hence, in real implementations, extra logic must be added to account for this case.

Example

Let

Then jacobi produces the following eigenvalues and eigenvectors after 3 sweeps (19 iterations) :

Applications for real symmetric matrices

When the eigenvalues (and eigenvectors) of a symmetric matrix are known, the following values are easily calculated.

Singular values
The singular values of a (square) matrix are the square roots of the (non-negative) eigenvalues of . In case of a symmetric matrix we have of , hence the singular values of are the absolute values of the eigenvalues of
2-norm and spectral radius
The 2-norm of a matrix A is the norm based on the Euclidean vectornorm; that is, the largest value when x runs through all vectors with . It is the largest singular value of . In case of a symmetric matrix it is the largest absolute value of its eigenvectors and thus equal to its spectral radius.
Condition number
The condition number of a nonsingular matrix is defined as . In case of a symmetric matrix it is the absolute value of the quotient of the largest and smallest eigenvalue. Matrices with large condition numbers can cause numerically unstable results: small perturbation can result in large errors. Hilbert matrices are the most famous ill-conditioned matrices. For example, the fourth-order Hilbert matrix has a condition of 15514, while for order 8 it is 2.7 × 108.
Rank
A matrix has rank if it has columns that are linearly independent while the remaining columns are linearly dependent on these. Equivalently, is the dimension of the range of . Furthermore it is the number of nonzero singular values.
In case of a symmetric matrix r is the number of nonzero eigenvalues. Unfortunately because of rounding errors numerical approximations of zero eigenvalues may not be zero (it may also happen that a numerical approximation is zero while the true value is not). Thus one can only calculate the numerical rank by making a decision which of the eigenvalues are close enough to zero.
Pseudo-inverse
The pseudo inverse of a matrix is the unique matrix for which and are symmetric and for which holds. If is nonsingular, then .
When procedure jacobi (S, e, E) is called, then the relation holds where Diag(e) denotes the diagonal matrix with vector e on the diagonal. Let denote the vector where is replaced by if and by 0 if is (numerically close to) zero. Since matrix E is orthogonal, it follows that the pseudo-inverse of S is given by .
Least squares solution
If matrix does not have full rank, there may not be a solution of the linear system . However one can look for a vector x for which is minimal. The solution is . In case of a symmetric matrix S as before, one has .
Matrix exponential
From one finds where exp  is the vector where is replaced by . In the same way, can be calculated in an obvious way for any (analytic) function .
Linear differential equations
The differential equation has the solution . For a symmetric matrix , it follows that . If is the expansion of by the eigenvectors of , then .
Let be the vector space spanned by the eigenvectors of which correspond to a negative eigenvalue and analogously for the positive eigenvalues. If then ; that is, the equilibrium point 0 is attractive to . If then ; that is, 0 is repulsive to . and are called stable and unstable manifolds for . If has components in both manifolds, then one component is attracted and one component is repelled. Hence approaches as .

Julia implementation

The following code is a straight-forward implementation of the mathematical description of the Jacobi eigenvalue algorithm in the Julia programming language.

usingLinearAlgebra,Testfunctionfind_pivot(Sprime)n=size(Sprime,1)pivot_i=pivot_j=0pivot=0.0forj=1:nfori=1:(j-1)ifabs(Sprime[i,j])>pivotpivot_i=ipivot_j=jpivot=abs(Sprime[i,j])endendendreturn(pivot_i,pivot_j,pivot)end# in practice one should not instantiate explicitly the Givens rotation matrixfunctiongivens_rotation_matrix(n,i,j,θ)G=Matrix{Float64}(I,(n,n))G[i,i]=G[j,j]=cos(θ)G[i,j]=sin(θ)G[j,i]=-sin(θ)returnGend# S is a symmetric n by n matrixn=4sqrtS=randn(n,n);S=sqrtS*sqrtS';# the largest allowed off-diagonal element of U' * S * U# where U are the eigenvectorstol=1e-14Sprime=copy(S)U=Matrix{Float64}(I,(n,n))whiletrue(pivot_i,pivot_j,pivot)=find_pivot(Sprime)ifpivot<tolbreakendθ=atan(2*Sprime[pivot_i,pivot_j]/(Sprime[pivot_j,pivot_j]-Sprime[pivot_i,pivot_i]))/2G=givens_rotation_matrix(n,pivot_i,pivot_j,θ)# update Sprime and USprime.=G'*Sprime*GU.=U*Gend# Sprime is now (almost) a diagonal matrix# extract eigenvaluesλ=diag(Sprime)# sort eigenvalues (and corresponding eigenvectors U) by increasing valuesi=sortperm(λ)λ=λ[i]U=U[:,i]# S should be equal to U * diagm(λ) * U'@testSU*diagm(λ)*U'

Generalizations

The Jacobi Method has been generalized to complex Hermitian matrices, general nonsymmetric real and complex matrices as well as block matrices.

Since singular values of a real matrix are the square roots of the eigenvalues of the symmetric matrix it can also be used for the calculation of these values. For this case, the method is modified in such a way that S must not be explicitly calculated which reduces the danger of round-off errors. Note that with .

The Jacobi Method is also well suited for parallelism.

Related Research Articles

<span class="mw-page-title-main">Pauli matrices</span> Matrices important in quantum mechanics and the study of spin

In mathematical physics and mathematics, the Pauli matrices are a set of three 2 × 2 complex matrices that are Hermitian, involutory and unitary. Usually indicated by the Greek letter sigma, they are occasionally denoted by tau when used in connection with isospin symmetries.

<span class="mw-page-title-main">Symmetric matrix</span> Matrix equal to its transpose

In linear algebra, a symmetric matrix is a square matrix that is equal to its transpose. Formally,

In mathematics, particularly in linear algebra, a skew-symmetricmatrix is a square matrix whose transpose equals its negative. That is, it satisfies the condition

In linear algebra, a diagonal matrix is a matrix in which the entries outside the main diagonal are all zero; the term usually refers to square matrices. Elements of the main diagonal can either be zero or nonzero. An example of a 2×2 diagonal matrix is , while an example of a 3×3 diagonal matrix is. An identity matrix of any size, or any multiple of it is a diagonal matrix called a scalar matrix, for example, . In geometry, a diagonal matrix may be used as a scaling matrix, since matrix multiplication with it results in changing scale (size) and possibly also shape; only a scalar matrix results in uniform change in scale.

In mathematics, a Hermitian matrix is a complex square matrix that is equal to its own conjugate transpose—that is, the element in the i-th row and j-th column is equal to the complex conjugate of the element in the j-th row and i-th column, for all indices i and j:

In the mathematical discipline of linear algebra, a matrix decomposition or matrix factorization is a factorization of a matrix into a product of matrices. There are many different matrix decompositions; each finds use among a particular class of problems.

<span class="mw-page-title-main">Cayley graph</span> Graph defined from a mathematical group

In mathematics, a Cayley graph, also known as a Cayley color graph, Cayley diagram, group diagram, or color group, is a graph that encodes the abstract structure of a group. Its definition is suggested by Cayley's theorem, and uses a specified set of generators for the group. It is a central tool in combinatorial and geometric group theory. The structure and symmetry of Cayley graphs makes them particularly good candidates for constructing expander graphs.

In numerical analysis, one of the most important problems is designing efficient and stable algorithms for finding the eigenvalues of a matrix. These eigenvalue algorithms may also find eigenvectors.

In linear algebra, a tridiagonal matrix is a band matrix that has nonzero elements only on the main diagonal, the subdiagonal/lower diagonal, and the supradiagonal/upper diagonal. For example, the following matrix is tridiagonal:

In linear algebra, a rotation matrix is a transformation matrix that is used to perform a rotation in Euclidean space. For example, using the convention below, the matrix

Sylvester's law of inertia is a theorem in matrix algebra about certain properties of the coefficient matrix of a real quadratic form that remain invariant under a change of basis. Namely, if is the symmetric matrix that defines the quadratic form, and is any invertible matrix such that is diagonal, then the number of negative elements in the diagonal of is always the same, for all such ; and the same goes for the number of positive elements.

In mathematics, the discrete Laplace operator is an analog of the continuous Laplace operator, defined so that it has meaning on a graph or a discrete grid. For the case of a finite-dimensional graph, the discrete Laplace operator is more commonly called the Laplacian matrix.

In linear algebra, it is often important to know which vectors have their directions unchanged by a given linear transformation. An eigenvector or characteristic vector is such a vector. More precisely, an eigenvector of a linear transformation is scaled by a constant factor when the linear transformation is applied to it: . The corresponding eigenvalue, characteristic value, or characteristic root is the multiplying factor .

In mathematics, the square root of a matrix extends the notion of square root from numbers to matrices. A matrix B is said to be a square root of A if the matrix product BB is equal to A.

In mathematics, preconditioning is the application of a transformation, called the preconditioner, that conditions a given problem into a form that is more suitable for numerical solving methods. Preconditioning is typically related to reducing a condition number of the problem. The preconditioned problem is then usually solved by an iterative method.

The Wigner D-matrix is a unitary matrix in an irreducible representation of the groups SU(2) and SO(3). It was introduced in 1927 by Eugene Wigner, and plays a fundamental role in the quantum mechanical theory of angular momentum. The complex conjugate of the D-matrix is an eigenfunction of the Hamiltonian of spherical and symmetric rigid rotors. The letter D stands for Darstellung, which means "representation" in German.

<span class="mw-page-title-main">Gaussian network model</span>

The Gaussian network model (GNM) is a representation of a biological macromolecule as an elastic mass-and-spring network to study, understand, and characterize the mechanical aspects of its long-time large-scale dynamics. The model has a wide range of applications from small proteins such as enzymes composed of a single domain, to large macromolecular assemblies such as a ribosome or a viral capsid. Protein domain dynamics plays key roles in a multitude of molecular recognition and cell signalling processes. Protein domains, connected by intrinsically disordered flexible linker domains, induce long-range allostery via protein domain dynamics. The resultant dynamic modes cannot be generally predicted from static structures of either the entire protein or individual domains.

In linear algebra, eigendecomposition is the factorization of a matrix into a canonical form, whereby the matrix is represented in terms of its eigenvalues and eigenvectors. Only diagonalizable matrices can be factorized in this way. When the matrix being factorized is a normal or real symmetric matrix, the decomposition is called "spectral decomposition", derived from the spectral theorem.

In the mathematical field of linear algebra, an arrowhead matrix is a square matrix containing zeros in all entries except for the first row, first column, and main diagonal, these entries can be any number. In other words, the matrix has the form

In the theory of random matrices, the circular ensembles are measures on spaces of unitary matrices introduced by Freeman Dyson as modifications of the Gaussian matrix ensembles. The three main examples are the circular orthogonal ensemble (COE) on symmetric unitary matrices, the circular unitary ensemble (CUE) on unitary matrices, and the circular symplectic ensemble (CSE) on self dual unitary quaternionic matrices.

References

  1. Jacobi, C.G.J. (1846). "Über ein leichtes Verfahren, die in der Theorie der Säkularstörungen vorkommenden Gleichungen numerisch aufzulösen". Crelle's Journal (in German). 1846 (30): 51–94. doi:10.1515/crll.1846.30.51. S2CID   199546177.
  2. Golub, G.H.; van der Vorst, H.A. (2000). "Eigenvalue computation in the 20th century". Journal of Computational and Applied Mathematics. 123 (1–2): 35–65. doi: 10.1016/S0377-0427(00)00413-1 .
  3. Schönhage, A. (1964). "Zur quadratischen Konvergenz des Jacobi-Verfahrens". Numerische Mathematik (in German). 6 (1): 410–412. doi:10.1007/BF01386091. MR   0174171. S2CID   118301078.

Further reading