Talk:QR algorithm

message: Some day this article could use a little fine tuning. To that end, here are a few notes.
The eigenvalues are roots of the characteristic polynomial, so in general we cannot compute them by a fixed predetermined sequence. That's why we use an open-ended iteration to achieve convergence.
This also implies that we cannot directly bring a matrix into upper triangular (or diagonal, for symmetric) form. However, we can use a fixed sequence to bring a matrix into upper Hessenberg (or tridiagonal, for symmetric) form. This gives us a mass of known zeros that will be preserved by the iterations to follow.
Clever as it is that reversing the QR factors effects a similarity transform, it is not at all obvious that doing this repeatedly will produce the convergence we seek. And by itself, it may not.
Success depends critically on use of shifts. That we choose to do the shifts implicitly is a numerical nicety; but decent convergence requires dealing with close eigenvalues somehow. The article really must explain shifting (or link to an explanation).
The most important special case is that of real symmetric matrices. For a real matrix, the characteristic polynomial will have real coefficients; thus any complex eigenvalues occur in complex conjugate pairs. The algorithm may not be able to achieve a real diagonal, and provision must be made for recognizing the 2×2 blocks giving a conjugate pair.
In counting costs, we must distinguish between a QR step, which is iterated an uncertain number of times, and a fixed cost like reduction to upper Hessenberg form. Also the QR factorization gets cheaper as we succeed in isolating roots, because we can ignore more and more of the matrix. Note that for symmetric matrices we can store the matrix as just the diagonal and subdiagonal; this is why the QR factorization is O(n) at worst. Without symmetry, we must touch half the matrix, so we can't beat O(n2). If we can count on a bounded number of iterations per eigenvalue, then the total cost of the iteration phase is n times the cost of an iteration: O(n3) in general, and O(n2) in the symmetric case.
The speed of convergence is one of the most remarkable aspects of the QR algorithm. It was a tremendous improvement over its predecessors. However, today we know that a Jacobi algorithm can give better numeric results, and is more amenable to parallelization. Some mention should be made of these issues, even though QR deservedly remains a workhorse.
Of all these points, the need for an extended discussion of shifting seems most urgent. --KSmrqT 13:13, 19 August 2006 (UTC)
thread_title:  Some possible improvements 

message: Is it possible to decide if this algorithm terminates which means the given matrix has
actually eigenvalues? If so it should be mentioned here I suppose. Nulli 10:28, 15 November 2006 (UTC)
thread_title:  Termination 

message: Why don't we merge this page in the QR decomposition one, and then link this one to QR decomposition ?
--Fbianco 22:14, 15 April 2007 (UTC)
replies: text: If anything, this article could be expanded into a series of articles including multishift versions and the modern forms of the algorithm that do the QR decomposition only in a very hidden implicit form.--LutzL (talk) 07:36, 16 July 2008 (UTC)
thread_title:  QR decomposition 

message: The claimed operation counts for reduction to Hessenberg form in the article seem to be off by a factor of two.
The Householder method for reduction to Hessenberg form requires 10/3 n^3 + O(n^2) arithmetic operations for general square matrices, and 4/3 n^3 + O(n^2) for Hermitian matrices (where Hessenberg = tridiagonal).  See, for example, Trefethen and Bau, Numerical Linear Algebra, or Demmel, Applied Numerical Linear Algebra.
There is another non-Householder method based on a Gaussian-elimination-like procedure that takes fewer arithmetic operations.  However, this algorithm (although it was used in EISPACK I believe, but not in LAPACK) seems to have fallen out of favor because it is sometimes unstable (Businger, 1969).  The best reference for that method seems to be Wilkenson's 1965 book, which I don't have in front of me; my recollection is that it requires half as many as the Householder method, which may explain the numbers in the article (which are incorrectly attributed to Householder).  However, it would be good to check a good reference for this.  (Numerical Recipes uses the Gaussian-elimination method, but I think erroneously gives the operation count as  5/6 n^3 + O(n^2) instead of  5/3 n^3 + O(n^2).
—Steven G. Johnson (talk) 02:44, 6 November 2008 (UTC)
replies: text: Okay, I've changed the article to correctly give the Householder-algorithm counts.  It seems to me that a further discussion of this algorithm belongs in the Hessenberg matrix article.  —Steven G. Johnson (talk) 02:57, 6 November 2008 (UTC)
replies: text: Your memory is fine. Golub & van Loan says that elimination to Hessenberg form via Gaussian elimination costs 5/3 n^3 + O(n^2) operations, just like you say. -- Jitse Niesen (talk) 14:26, 6 November 2008 (UTC)
thread_title:  incorrect operation counts in article 

message: This page does not make it clear what the starting Q and R are. It says we let A_0:=A and then
:A_{k+1}:= R_k Q_k = Q_k^\top A_k Q_k
which I guess implies that
:R_k = Q_k^\top A_k Q_k Q_k^\top = Q_k^\top A_k
but what's Q_0 and Q_{k+1}? —Ben FrantzDale (talk) 10:59, 6 June 2011 (UTC)
replies: text: Qk and Rk are the QR factors of Ak.  So Q0 and A0 are the QR factors of A.  i.e. A = Q0 R0.  See QR decomposition. — Steven G. Johnson (talk) 12:55, 6 June 2011 (UTC)
thread_title:  Q_0, R_0? 

message: As of 2016-04-20, the opening paragraph ends, "The basic idea is to perform a QR decomposition, writing the matrix as a product of an orthogonal matrix and an upper triangular matrix, multiply the factors in the reverse order, and iterate."  
This will NOT work for a matrix that is not square, because Q and R are not conformable in the reverse order.  
??? Thanks, DavidMCEddy (talk) 17:54, 20 April 2016 (UTC)
thread_title:  What about eigenvalues and vectors of non-square matrices? 

message: Hello fellow Wikipedians,
I have just modified  on QR algorithm. Please take a moment to review my edit. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit this simple FaQ for additional information. I made the following changes:
*Added  tag to http://www.alglib.net/matrixops/general/svd.php.
*Added archive http://web.archive.org/web/20081209042103/http://math.fullerton.edu:80/mathews/n2003/QRMethodMod.html to http://math.fullerton.edu/mathews/n2003/QRMethodMod.html
When you have finished reviewing my changes, please set the checked parameter below to true or failed to let others know (documentation at ).
Cheers.—InternetArchiveBot (Report bug) 10:21, 21 July 2016 (UTC)
thread_title:  External links modified 

message: The code (right now pretty terrible) can be found here: https://github.com/ogogmad/la-vis. I don't know if the discussion around computability is clear or of interest to people. --Svennik (talk) 17:36, 9 August 2021 (UTC)
replies: text: The following Youtube video is by me, based on the visualization I provided here: https://www.youtube.com/watch?v=XGAaHoppcvE --Svennik (talk) 20:09, 16 March 2022 (UTC)
thread_title:  Added visualizations and even discussion surrounding computability