QR-Algorithm: A much better method for approximating the eigenvalues of an invertible matrix A depends on the factorization (using the Gram-Schmidt algorithm) of A in the form A=QR, where Q is orthogonal and R is invertible and upper triangular. The QR-algorithm uses this repeatedly to create a sequence of matrices A=A1, A2, A3, as follows:
1. Define A=A1 and factor it as A=R.
2. Define A=RQ and factor it as A=R.
3. Define A=RO and factor it as A=QR.
In general, A is factored as A=R and we define A+=R. Then, A+ is similar to A (in fact, A+=R=Al), and hence each A has the same eigenvalues as A. If the eigenvalues of A are real and have distinct absolute values, the remarkable thing is that the sequence of matrices A, A2, A3... converges to an upper triangular matrix with these eigenvalues on the main diagonal. [See below for the case of complex eigenvalues.]
If A=2, use the QR-algorithm to approximate the eigenvalues.