http://faculty.salina.k-state.edu/tim/DAT/linAlg/appendixLA/matlabEig.html
Eigenvalue Computation in MATLAB
function eigs = myQReig(A) % MYQREIG - iterative QR algorithm to find eigenvalues % % NOTE: The purpose of this code is to illustrate the algorithm. % It converges reasonably quick for most matrices, but not all matrices. % So use MATLAB's eig function when you just want the eigenvalues of % a matrix. A1 = A; count = 0; % just to track the performance % limit the precision and test convergence to upper triangular while ~istriu(round(A1, 7)) count = count+1; [Q, R] = qr(A1); A1 = R*Q; end eigs = diag(A1); fprintf('iterations = %g\n', count); end
Eigenvalue Computation in MATLAB
The eigenvalue computation algorithm in MATLAB’s eig()
function is quite complex. It looks at the data and performs pre-conditoning transformations to make the computation quicker. It uses different algorithms to compute the eigenvalues depending on the size and relationships of the values in the matrix.
It does not usually (maybe never, but I’m not certain about that) find the eigenvalues by finding the roots of the characteristic polynomial, i.e., find the s that satisfy the equation .
6.11.6.1. QR Factorization
One of the more well known algorithms for finding eigenvalues without computing determinants is an iterative method based on QR factorization. MATLAB’s eig()
will sometimes use an advanced implementation of this algorithm. What is described here is just the basics of the algorithm and does not have good performance for all matrices.
QR factorization factors the matrix into sub-matrices of orthonormal column vectors and an upper triangular matrix, (see Gram Schmidt and Orthogonal (QR) Factoring). After is computed, a new matrix is found. Then QR factorization is done again on to find continuing until is upper triangular and additional iterations will not change the result. These are Similar Matrices to the original matrix, which means that they have the same eigenvalues. When a matrix is upper triangular, the eigenvalues are on the diagonal.
The algorithm for finding the QR factorization is called Gram-Schmidt. See Gram Schmidt and Orthogonal (QR) Factoring for a quick description of the Gram-Schmidt algorithm and why and are Similar Matrices. It is described in many Linear Algebra textbooks and online videos such as Professor Strang’s Linear Algebra course (18.06) on MIT Open Courseware. [STRANG99]
A more complex question about this algorithm is why does it converge to a stable upper triangular matrix. The complete explanation of convergence is quite advanced and beyond the scope of this course. For the brave, an explanation of the convergence is found at http://pi.math.cornell.edu/~web6140/TopTenAlgorithms/QRalgorithm.html.
What happens after the loop has been repeated many () times is that the orthogonal matrix becomes the identity matrix and then .
Since , then . We can see that if as , then as , so converges to final values as an upper triangular matrix with the eigenvalues on the diagonal.
No hay comentarios:
Publicar un comentario