2

Using Wolfram's software, I have been debugging some code that returns the eigenvalues of a matrix and the eigenvector corresponding to the largest of them. My code works by using a QR algorithm (similar to the one used by JAMA) to produce the eigenvalues and then a simple RREF with back-substitution algorithm to solve $(A-\lambda_{1} I) x=0$. My goal is to create an algorithm that can find the eigenvalues/vectors of any real matrix, if possible.

The code I wrote works flawlessly for every sample matrix I've tried except for one. My program calculated all of the correct eigenvalues, but did not produce the correct RREF matrix. Can anyone tell me what properties make this specific matrix different from the rest and if there is some other process that I should be using instead? If there are multiple procedures for doing this, is there a list of conditions that a computer can use to decide which to perform? (Note: I am very new to this field, so please be patient if I am not familiar with the vocabulary).

Matrices that work:

[  1.00   2.00   3.00 ]
[  3.00   2.00   1.00 ]
[  2.00   1.00   3.00 ]

[  4.00   5.00   0.00 ]
[  1.00   5.00   7.00 ]
[  6.00   2.00   9.00 ]

[  2.00   3.00   4.00 ]
[  4.00   3.00   2.00 ]
[  3.00   2.00   4.00 ]

[  52.00   30.00   49.00   28.00 ]
[  30.00   50.00   8.00   44.00 ]
[  49.00   8.00   46.00   16.00 ]
[  28.00   44.00   16.00   22.00 ]

[  1.00   2.00   1.00 ]
[  0.00   2.00   2.00 ]
[ -3.00   2.00   5.00 ]

The one that doesn't work:

[  9.00  -1.00   2.00 ]
[ -2.00   8.00   4.00 ]
[  1.00   1.00   8.00 ]

Incorrect RREF matrix generated by code:

[  1.00   1.00  -2.00  -0.00 ]
[  0.00   0.00  -0.00   0.00 ]
[  0.00  -0.00  -0.00   0.00 ]

Incorrect eigenvector generated by code:

[ -2.00 ]
[  3.00 ]
[  1.00 ]

If requested, I can provide the steps that the algorithm took to get the answer, but I believe this must be due to some property of the matrix that I am not familiar with.

  • Even though the second one has a repeated eigenvalue, it is diagnolizable. It is not deficient and does not require generalized eigenvectors. I think you'd have to print intermediate results to troubleshoot why it is failing. – Moo May 24 '19 at 19:24
  • Can you explain what "deficient" means and why it is important to eigenvectors? – Cole Petersen May 24 '19 at 19:29
  • You can simplify your code a bit and make it more efficient to boot. It looks like you’re augmenting $A-\lambda I$ as part of computing its RREF, but there’s no good reason to do this. That additional column of zeros is unchanged by the process and contributes no information to the result. – amd May 24 '19 at 19:53
  • @amd This code is just a proof of concept for now, and I will change it later once I have a working model. – Cole Petersen May 24 '19 at 20:04

1 Answers1

1

The RREF is in fact correct. It looks like you haven’t taken into account that an eigenspace might not be one-dimensional. From this RREF we can read that every eigenvector of $10.0$ is a nonzero linear combination of $(1.00,-1.00,0.00)^T$ and $(-2.00,0.00,-1.00)^T$.

amd
  • 53,693
  • Can you explain in simple terms how you derived (-2,0,-1)? I am not sure how to implement this with a naive program. – Cole Petersen May 24 '19 at 19:44
  • @ColePetersen See https://math.stackexchange.com/a/1521354/265466 for a detailed discussion. If you just need one eigenvector, though, you only need to work with the first non-pivot column. – amd May 24 '19 at 19:45
  • Thank you for the link, it was certainly helpful. – Cole Petersen May 24 '19 at 20:03