Mathematica Mathematica eigensystem incorrect?

  • Thread starter Thread starter thoughtgaze
  • Start date Start date
  • Tags Tags
    Mathematica
Click For Summary
SUMMARY

The discussion focuses on computing eigenvalues and eigenvectors of a 4x4 matrix using Mathematica, specifically addressing issues with the TrueQ function returning "False" when checking eigenvalue and eigenvector relationships. The user is advised to utilize the Simplify and FullSimplify functions to enhance Mathematica's ability to recognize equivalent expressions. Additionally, an alternative method is suggested for verifying eigenvector correctness by checking if the result of the matrix operation is zero, which is computationally more efficient.

PREREQUISITES
  • Familiarity with Mathematica 12.0 syntax and functions
  • Understanding of eigenvalues and eigenvectors in linear algebra
  • Knowledge of symbolic computation and simplification techniques
  • Experience with matrix operations and identity matrices
NEXT STEPS
  • Learn how to use the Simplify and FullSimplify functions in Mathematica
  • Explore the Eigensystem function in Mathematica for different matrix types
  • Research best practices for verifying eigenvector correctness in symbolic computations
  • Investigate performance implications of using TrueQ versus direct equality checks in Mathematica
USEFUL FOR

Mathematics students, data scientists, and researchers working with linear algebra in Mathematica, particularly those dealing with symbolic matrices and eigenvalue problems.

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.
 
Physics news 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
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · 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
3K