Solution for a homogeneous equation using null space

6 ビュー (過去 30 日間)
harry wang
harry wang 2012 年 2 月 22 日
コメント済み: Dipendra Subedi 2021 年 3 月 21 日
I have a homogeneous equation group as follows
A*b=0;where A is a 8 by 8 matrix, b is a 8 by 1 vector.
I have calculated that det(A)=5.141078303798737e-010, close to zero, so i use null(A) to find out the solution b, however i got a result like "Empty matrix: 8-by-0", I have checked the rank of the matrix A and got Rank(A)=8, since the determinant of A is close to zero, i thought that rank(A) should be smaller than 8 and I should be able to use null space to solve b. Any one can suggest a way to solve b?
Thanks.
Mike
  5 件のコメント
Sean de Wolski
Sean de Wolski 2012 年 2 月 22 日
post it as a full matrix so Wayne can copy and paste it:
full(A)
Wayne King
Wayne King 2012 年 2 月 22 日
Oh, thank you Sean!! sorry I don't why it didn't occur to me that was sparse(A)

サインインしてコメントする。

回答 (6 件)

John D'Errico
John D'Errico 2012 年 2 月 22 日
Sigh. The determinant is a TERRRRRRRRRRRIBLE way to check for singularity. Godawful. A miserable computational tool, good only for homework problems. Did I say it was bad? Three times I've said it, so this must be true.
Do you need an example? Compute the determinant of
A = eye(8);
det(A)
ans =
1
Yes, it is clearly nonsingular, and det predicted that. Since you used 1e-10 as a measure that a matrix must be singular, can we modify A just so subtly and get a determinant that small? How about this?
det(A*.05)
ans =
3.9063e-11
Oops. I could have sworn that this matrix is also diagonal, just with 0.05 elements down the diagonal. Surely this is just as nonsingular as the original identity matrix was.
Gosh. I wonder why I should think it is singular just because det says so? I suppose if I go to extremes I can get a true underflow zero.
det(A*1e-50)
ans =
0
Is that matrix any more singular than the others?
Why do people insist on using det?
  3 件のコメント
Walter Roberson
Walter Roberson 2012 年 2 月 23 日
John, I guess nobody ever expects the det() to be a boojum.
John D'Errico
John D'Errico 2012 年 2 月 23 日
Don't use det. Period. PERIOD. PERIOD! Need I repeat myself? Under NO circumstances would I EVER advise that someone use det to test for singularity.
Rank is a good choice. An svd is a good choice, but of course rank is based on the svd.

サインインしてコメントする。


harry wang
harry wang 2012 年 2 月 23 日
OK, i find the solution, if i use the similar solution as the "null" function, it works! if i use "null" directly, i will still get "empty matrix 8 by 0". Is it a bug of Matlab "null" function? the following is the code to simulate "null" function, Z is the null space for my matrix A.
[m,n] = size(A);
[U,S,V] = svd(A,0);
s = diag(S);
tol = max(m,n) * max(s) * eps;
r = sum(s > tol);
Z = V(:,r+1:n);
  1 件のコメント
Dipendra Subedi
Dipendra Subedi 2021 年 3 月 21 日
I have the same issue. The null(A) returns empty matrix (specially when used inside a loop which is very strange) but the above implementation works fine (in and out of the loop).

サインインしてコメントする。


harry wang
harry wang 2012 年 2 月 22 日
sorry about that, the following is the matrix in format short
-7.2570 1.2829 -10.9984 -10.9984 0.0000 0.0000 11.0280 -11.0280
-2.4403 1.2016 5.2093 5.2093 -0.0000 0.0000 2.4732 -2.4732
0.0000 -0.0000 -6.3383 6.3383 -3.6586 0.8524 -8.8819 -8.8819
-0.0000 0.0000 -0.0000 0.0000 -0.0000 -0.0000 0.0000 0.0000
-0.0000 -0.0000 -11.0280 11.0280 -7.2570 1.2829 -10.9984 -10.9984
0.0000 -0.0000 -2.4732 2.4732 -2.4403 1.2016 5.2093 5.2093
3.6586 -0.8524 8.8819 8.8819 0.0000 -0.0000 -6.3383 6.3383
0.0000 0.0000 -0.0000 -0.0000 -0.0000 0.0000 -0.0000 0.0000

Wayne King
Wayne King 2012 年 2 月 22 日
Hi Harry, I get a rank of 6 for this matrix and therefore expect the nullspace to have dimension 2. I get the following ONB for the nullspace:
-0.000000000000020 -0.756171511092082
0.000000000000013 0.434311342718816
0.339775797713826 -0.065890507565062
-0.339775797713829 -0.065890507565044
-0.756171511092085 0.000000000000021
0.434311342718811 -0.000000000000010
-0.065890507565062 -0.339775797713825
-0.065890507565044 0.339775797713829
  1 件のコメント
harry wang
harry wang 2012 年 2 月 22 日
Yeah, but if i recover the orginal long format, i would not be able to use "null" to solve it. Are there any way i can post the long format matrix?

サインインしてコメントする。


harry wang
harry wang 2012 年 2 月 22 日
This is the only way i can think to post the original long format matrix, each row of the matrix is seperated by space. you can copy the whole matrix into matlab editor and delete the space. thanks
-7.257023337091996 1.282933883035595 -10.998441425187863 -10.998441425188025 0.000000000000000 0.000000000000000 11.027957706237926 -11.027957706238094
-2.440329565883115 1.201628321295855 5.209283612003834 5.209283612003911 -0.000000000000003 0.000000000000000 2.473178531845574 -2.473178531845598
0.000000000000001 -0.000000000000000 -6.338289276250228 6.338289276250308 -3.658635913629607 0.852367515277986 -8.881879896588558 -8.881879896588693
-0.000000000000000 0.000000000000000 -0.000000000035585 0.000000000035585 -0.000000000170258 -0.000000000156291 0.000000000236824 0.000000000236824
-0.000000000000000 -0.000000000000000 -11.027957706237926 11.027957706238094 -7.257023337091996 1.282933883035595 -10.998441425187863 -10.998441425188025
0.000000000000003 -0.000000000000000 -2.473178531845574 2.473178531845598 -2.440329565883115 1.201628321295855 5.209283612003834 5.209283612003911
3.658635913629607 -0.852367515277986 8.881879896588558 8.881879896588693 0.000000000000001 -0.000000000000000 -6.338289276250228 6.338289276250308
0.000000000170258 0.000000000156291 -0.000000000236824 -0.000000000236824 -0.000000000000000 0.000000000000000 -0.000000000035585 0.000000000035585
  1 件のコメント
Wayne King
Wayne King 2012 年 2 月 23 日
I see what you mean, but do you really need this kind of precision in your matrix?

サインインしてコメントする。


harry wang
harry wang 2012 年 2 月 22 日
I have calculate the condition number of this matrix, it is 5.144376827909181e+012, quite large, so the matrix is close to a singular matrix, but how can i tell MATLAB that this is a singular matrix and i can use "null" to solve "b"?

カテゴリ

Help Center および File ExchangeOperating on Diagonal Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by