Trying to do product of eigenvalues collected from a matrix
6 views (last 30 days)
Show older comments
I have a matrix that I have used eig() to find the eigenvectors and eigenvalues, but I cannot determine whether the matrix is invertible or not. I have to use the product of eigenvalues. Here is what I have my code to be.
T = [5 -2 -2 0; -51 30 -26 39; -14 -10 6 -10; 34 -31 25 -48]
[V,D] = eig(T)
k = V(:,2);
T*k - (-8.2242)*k
If the matrix is invertible, then the solution of
T*k - (-8.2242)*k
should equal 0.
For some reason my answer to that comes out as
ans =
1.0e-04 *
0.0963
0.2841
0.3524
0.0823
Does anyone know why that is and how I can fix it?
0 Comments
Answers (2)
John D'Errico
on 17 Nov 2021
Edited: John D'Errico
on 17 Nov 2021
You don't want to use the product of eigenvalues to determine if a matrix is singular. This is equivalent to computing the determinant, another terribly bad way to test for singularity.
Instead, learn to use tools like rank or cond to make that determination.
T = [5 -2 -2 0; -51 30 -26 39; -14 -10 6 -10; 34 -31 25 -48];
rank(T)
T is a 4x4 matrix. It has rank 4, so it is technically invertible. How close it is?
cond(T)
In fact, T is quite well conditioned. Singular matrices will have condition numbers on the order of 1e16 or larger.
In context of your actual questiion, what did you do wrong?
[V,D] = eig(T);
you used -8.2242, which you APPARENTLY think is one of the eigenvalues. But is it?
NO. That is approximately an eigenvalue.
format long g
D(2,2)
In fact, it was not an eigenvalue. The value you used was incorrect. Close. But using 5 significant digit approximations to things is a bad idea, something you need to relearn as you learn mathematics.
k = V(:,2);
lambda = D(2,2);
T*k - lambda*k
As you can see, here the difference is on the order of floating point trash, so effectively zero.
0 Comments
Chunru
on 17 Nov 2021
First the difference "e" (as below) will not be perfectly 0 and it is subjected to computational accuracy. Second, the eigen value you keyed in is not up to the computational accuracy. Use D(2,2) instead, which will result in much smaller difference "e" (close to 0).
T = [5 -2 -2 0; -51 30 -26 39; -14 -10 6 -10; 34 -31 25 -48]
[V,D] = eig(T)
k = V(:,2);
e = T*k - D(2,2)*k;
e.'
2 Comments
Chunru
on 17 Nov 2021
These numbers are sufficiently small (due to the rounding error of floating point operations). All straight zero cases are really rare for arbitrary matrix.
See Also
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!