Mathematica eigensystem incorrect?

  • Mathematica
  • Thread starter thoughtgaze
  • Start date
  • #1

Main Question or Discussion Point

I'm trying to compute the eigenvalues and eigenvectors of a 4x4 matrix using mathematica.
The problem comes when I try to check the values using the commands:

{vals, vecs} = Eigensystem[m]

TrueQ[m.vecs[[1]] == vals[[1]] vecs[[1]]]

Which should return "True"; instead it returns "False"

I tested a different matrix and it returns true. So I'm not sure what to think about that. I would try it by hand, and might end up doing so, but I'm pressed for time and the calculation looks like it could get pretty hairy since the matrix is necessarily in symbolic form. Any help is appreciated. Thanks.
 

Answers and Replies

  • #2
phyzguy
Science Advisor
4,549
1,484
Mathematica isn't always capable of recognizing that two expressions are equivalent if they are sufficiently complicated. Try:

TrueQ[m.vecs[[1]] == vals[[1]] vecs[[1]]//Simplify]

or

TrueQ[m.vecs[[1]] == vals[[1]] vecs[[1]]//FullSimplify]
 
  • #3
Mathematica isn't always capable of recognizing that two expressions are equivalent if they are sufficiently complicated. Try:

TrueQ[m.vecs[[1]] == vals[[1]] vecs[[1]]//Simplify]

or

TrueQ[m.vecs[[1]] == vals[[1]] vecs[[1]]//FullSimplify]
Thanks! This works.
 
  • #4
313
1
Just a couple of comments:

1) You probably shouldn't use TrueQ unless it's in the logic of some procedure where you need a definite True/False answer.

2) It's easier to test for a-b==0 than a==b

So I would write something like:

m = RandomReal[{0, 1}, {4, 4}]
{vals, vecs} = Eigensystem[m]
Table[(m - vals[] IdentityMatrix[4]).vecs[], {i, 1, 4}] // Chop

and check that the result is all zeros.
 
  • #5
Just a couple of comments:

m = RandomReal[{0, 1}, {4, 4}]
{vals, vecs} = Eigensystem[m]
Table[(m - vals[] IdentityMatrix[4]).vecs[], {i, 1, 4}] // Chop



I see, and by easier I assume you mean easier on the cpu? I understand that simplifying can take some time for complicated symbolic expressions.
 

Related Threads on Mathematica eigensystem incorrect?

Replies
1
Views
2K
Replies
5
Views
7K
Replies
1
Views
2K
Replies
9
Views
2K
Replies
7
Views
3K
  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
4
Views
2K
Replies
5
Views
2K
  • Last Post
Replies
1
Views
984
Top