Trying to do product of eigenvalues collected from a matrix

4 次查看(过去 30 天)
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?

回答(2 个)

John D'Errico
John D'Errico 2021-11-17
编辑:John D'Errico 2021-11-17
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)
ans = 4
T is a 4x4 matrix. It has rank 4, so it is technically invertible. How close it is?
cond(T)
ans = 33.1588
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)
ans =
-8.2242470030545
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
ans = 4×1
1.0e+00 * 2.66453525910038e-15 1.33226762955019e-14 3.5527136788005e-15 -2.66453525910038e-15
As you can see, here the difference is on the order of floating point trash, so effectively zero.

Chunru
Chunru 2021-11-17
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]
T = 4×4
5 -2 -2 0 -51 30 -26 39 -14 -10 6 -10 34 -31 25 -48
[V,D] = eig(T)
V = 4×4
-0.0332 -0.2048 -0.1094 -0.2725 -0.5728 -0.6045 0.8391 -0.2603 0.0622 -0.7497 -0.1511 0.8566 0.8166 -0.1751 -0.5110 0.3524
D = 4×4
-25.7352 0 0 0 0 -8.2242 0 0 0 0 17.5820 0 0 0 0 9.3774
k = V(:,2);
e = T*k - D(2,2)*k;
e.'
ans = 1×4
1.0e+-13 * 0.0266 0.1332 0.0355 -0.0266
  2 个评论
ssmith
ssmith 2021-11-17
@Chunru But
ans = 1×4
1.0e+-13 *
0.0266 0.1332 0.0355 -0.0266
still does not equal all straight 0s so does that mean it is not invertible.
Chunru
Chunru 2021-11-17
These numbers are sufficiently small (due to the rounding error of floating point operations). All straight zero cases are really rare for arbitrary matrix.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Linear Algebra 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by