Eig function for symmetric matrices
20 views (last 30 days)
Show older comments
Two of the properties of symmetric matrices are that their eigenvalues are always real, and that they are always orthogonally diagonalizable. Given any two distinct eigenvalues, the corresponding eigenvectors are orthonormal. Yet if some eigenvalue L with multiplicity greater than 1 appear, it is necessary to use, for example, Gram Schmidt for ensuring orthogonality between the vectors representing the span of Ker(A - Id L). I was so glad to see that computing the MatLab function eig over symmetric matrices having multiple eigenvalues would output an orthogonal eigenvector matrix, meaning that MatLab doesn't only normalize the vectors, but also it make them orthogonal! I tried it on a few matrices, I just need to know if I was "lucky" with them, and if usually eig doesn't do that, or, elsewise, what procedure is implemented in eig for dealing with this situation. Thank you for your help.
0 Comments
Answers (2)
Matt J
on 4 Oct 2016
I doubt you were just lucky. I've never seen EIG fail to give orthogonalized eigenvectors for symmetric matrices if it can recognize the matrix as symmetric. If there's a chance you'll have numerical error in the creation of the matrix (such that it is not perfectly symmetric), it would be safest to use SVD instead.
1 Comment
Walter Roberson
on 4 Oct 2016
Or force them to be symmetric by using
A = (A + A.')/2;
Steven Lord
on 4 Oct 2016
Edited: Steven Lord
on 4 Oct 2016
According to the documentation page for eig, specifically the section describing the output argument V:
[V,D] = eig(A) returns matrix V, whose columns are the right eigenvectors of A such
that A*V = V*D. The eigenvectors in V are normalized so that the 2-norm
of each is 1.
If A is real symmetric, then the right eigenvectors, V, are orthonormal.
[Edited to fix formatting of quoted text.]
13 Comments
Christine Tobler
on 21 Sep 2018
Calling SCHUR for a hermitian matrix should be slower than calling EIG. I still think the problem is that your matrix is not exactly hermitian.
Here's an example:
>> n = 1000;
>> A = randn(n) + 1i*randn(n);
>> A = A*diag(rand(n, 1))*A'; % nearly hermitian
>> norm(A - A')
ans =
7.3104e-13
>> tic; [U, D] = eig(A); toc
Elapsed time is 4.432694 seconds.
>> tic; [U, T] = schur(A); toc
Elapsed time is 3.521355 seconds.
>> tic; [U, D] = eig((A+A')/2); toc
Elapsed time is 0.637474 seconds.
Because A is not hermitian, EIG uses the non-hermitian algorithm, which is based on calling SCHUR, and then recovering the eigenvectors from the Schur vectors. Since A is nearly hermitian, its eigenvectors are nearly identical to the Schur vectors.
However, for a hermitian matrix, the Schur decomposition's matrix T is diagonal. There is no need to compute the upper triangle of T, as is done in SCHUR, and the hermitian algorithm is faster because it doesn't do this.
See Also
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!