Mathematica eigensystem incorrect?

  • Context: Mathematica 
  • Thread starter Thread starter thoughtgaze
  • Start date Start date
  • Tags Tags
    Mathematica
thoughtgaze
Messages
74
Reaction score
0
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.
 
on Phys.org
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]
 
phyzguy said:
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.
 
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.
 
Simon_Tyler said:
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.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 2 ·
Replies
2
Views
9K
  • · Replies 10 ·
Replies
10
Views
4K
  • · Replies 10 ·
Replies
10
Views
13K
  • · Replies 2 ·
Replies
2
Views
4K