Finding eigenvalues with QR method

In summary, the conversation is about the difficulty of finding eigenvalues for a general square symmetric matrix using the QR algorithm in C. The speaker has implemented a function using the Householder method to put the matrix in Hessenberg form, but is struggling with finding the QR decomposition of the matrix in a useful computational way. They are seeking advice on how to decompose the matrix and where to find an algorithm for this process. The expert suggests looking into LAPACK routines and doing a Google search for more information on the QR algorithm. They also recommend getting a textbook on matrix computations for a better understanding of the algorithms.
  • #1
Thor90
10
0
Hi, I am trying to solve the problem of finding eigenvalus for a general square symmetric matrix with the QR algorithm.
I have understood that this task is much easier if the matrix is in an Hessemberg form, so I have implemented a function that does that with the Housholder method, but I can't understand how to find the qr decomposition of the given matrix in a useful computational way. The algebric algorithm is clear for me but I don't know how to reproduce it in C since I'm not understanding how to work with the decomposition process.
Can someone explain this for me?
That is, given the original matrix A in an Hessemberg form, how can I find the two matrices Q (orthogonal) and R (upper triangular) so that A=Q*R?
 
Technology news on Phys.org
  • #2
Test your code with matrices that have a known form at each step to see which step is not working.
 
  • #3
There is nothing that doesn't work with my program. I am simply not understanding how to decompose a matrix this way in C (I am a physics not a computer scientist), that means in an iterative way. Where can I find an algorithm to decompose a matrix like this? How does the Hessemberg form come in help?
 
  • #4
Thor90 said:
There is nothing that doesn't work with my program. I am simply not understanding how to decompose a matrix this way in C (I am a physics not a computer scientist), that means in an iterative way. Where can I find an algorithm to decompose a matrix like this? How does the Hessemberg form come in help?
It's Hessenberg, not Hessemberg.

There's any number of web pages describing QR and using QR to find eigenvalues. You could take a look at the routines in LAPACK which are written in Fortran.
You can either use a C wrapper for the LAPACK and run it with your code, or you can use a Fortran-to-C translation called CLAPACK.

http://www.netlib.org/clapack/

The netlib is a good source for all sorts of algorithms of this nature.

This page has a description of the QR method:

http://mathfaculty.fullerton.edu/mathews/n2003/QRMethodMod.html

In any event, you can find a lot of information about these algorithms, along with actual code, by doing a Google search. This saves a lot of time.

I wouldn't write a routine from scratch unless it was absolutely, positively necessary.
 
  • #5
SteamKing said:
It's Hessenberg, not Hessemberg.

Sorry for the mistake

SteamKing said:
There's any number of web pages describing QR and using QR to find eigenvalues. You could take a look at the routines in LAPACK which are written in Fortran.

I know that, the fact is that is my first time doing this kind of things and I have no idea how to use/install lapack, but if it's the only way I will try to do that.

SteamKing said:
This page has a description of the QR method:

http://mathfaculty.fullerton.edu/mathews/n2003/QRMethodMod.html

In any event, you can find a lot of information about these algorithms, along with actual code, by doing a Google search. This saves a lot of time.

I have already done my search but as I said before I am not an expert and I am not able to understandand how to do this routine if only a code is posted without any explanation.
Anyway the page you linked me only has mathematica subrutines. I agree that it would be much easier to do with mathematica but I need to use C++ to solve this problem.
And beside that in every page I found about the qr algorithm anyone seems to take as granted that I know how to decompose a matrix in a product of Q and R, which is not.
 
  • #6
Well, did you check out CLAPACK? There are versions of these routines translated into C++.

As far as the QR page is concerned, there is some pseudocode there along with the Mathematica. If you are going to write code, you must develop a rudimentary knowledge of other programming languages in order to understand the structure of how routines written in them work.

As I mentioned, the page I linked to about QR was one of many. Google "QR algorithm" to get other pages so that you can understand how QR works, then you can narrow your search to eigenvalue specific pages.

BTW, I think most eigenvalue finding routines use the Singular Value Decomposition method over QR, although the two methods use similar features from linear algebra.

I also recommend that you get a copy of Golub and van Loan's "Matrix Computations" if you want to figure out the various algorithms and how to code them.
 
  • Like
Likes Thor90

1. How does the QR method help in finding eigenvalues?

The QR method is an efficient numerical algorithm used to find eigenvalues of a matrix. It involves iteratively transforming the original matrix into an upper triangular matrix by using orthogonal transformations. Once the matrix is in upper triangular form, the eigenvalues can be easily read off from the diagonal entries.

2. What are the advantages of using the QR method over other methods for finding eigenvalues?

The QR method is more stable and efficient compared to other methods such as power iteration or the Jacobi method. It also works for a wider range of matrices, including non-symmetric and complex matrices.

3. How does the QR method handle matrices with repeated eigenvalues?

In the case of repeated eigenvalues, the QR method may require more iterations to converge, but it will still find the correct eigenvalues. It also has the advantage of being able to handle a large number of repeated eigenvalues without significant loss of accuracy.

4. Can the QR method be used to find all the eigenvalues of a matrix at once?

Yes, the QR method can be used to find all the eigenvalues of a matrix simultaneously. By using shifts in the QR algorithm, all the eigenvalues can be obtained without having to repeat the process for each individual eigenvalue.

5. Are there any limitations to the QR method?

The QR method may not work well for matrices with very large or very small eigenvalues. This is because the algorithm involves dividing by the largest entry in each column, which can lead to numerical instability. In these cases, other methods may be more suitable for finding eigenvalues.

Similar threads

  • Quantum Physics
Replies
2
Views
978
Replies
9
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
18
Views
2K
  • Calculus and Beyond Homework Help
Replies
1
Views
3K
  • Linear and Abstract Algebra
Replies
5
Views
4K
  • Linear and Abstract Algebra
Replies
1
Views
1K
  • Calculus and Beyond Homework Help
Replies
2
Views
531
  • Calculus and Beyond Homework Help
Replies
8
Views
1K
  • Programming and Computer Science
Replies
2
Views
951
  • Programming and Computer Science
Replies
1
Views
962
Back
Top