Since the matrix is near to singular I have tried pinv to solve but getting too deviated answers. Can you please let me know if there is any other way to solve the equations

11 次查看(过去 30 天)
A =
0.25 9.59994e-09 0 -1 0
0 0.25 9.59994e-09 0 -1
0.25 7.5e-13 0 -1 0
0 0.25 7.5e-13 0 -1
0.25 8.7634e-10 0 -1 0
B = [-1.30038272588598 ; 14.8832035274747 ;-2.15072625510578 ; 18.9956035209202 ;-1.75244493678615]
B =
-1.30038272588598
14.8832035274747
-2.15072625510578
18.9956035209202
-1.75244493678615
Since the matrix is near to singular I have tried pinv to solve but getting too deviated answers. Can you please let me know if there is any other way to solve the equations
  4 个评论

请先登录,再进行评论。

采纳的回答

David Goodmanson
David Goodmanson 2020-12-18
编辑:David Goodmanson 2020-12-18
Hi VS,
Usually in these cases, finding the determinant is not as useful as finding the condition number. Unless you can show that the determinant is exactly zero. And in this case it is. You have
A = [0.2500000000 0.00000000959994 0 -1 0
0 0.2500000000000 0.0000000095999400 0 -1
0.2500000000 0.00000000000075 0 -1 0
0 0.2500000000000 0.0000000000007500 0 -1
0.2500000000 0.00000000087634 0 -1 0]
Subtract row 1 from row 3 to make a new row 3, which does not affect the determinant. Then subtract row 1 from row 5 to make a new row 5, which does not affect the determinant.
newrow3 = 1.0e-08 *
0 -0.9599 0 0 0
newrow5 = 1.0e-08 *
0 -0.8724 0 0 0
But these two new rows are proporional to each other, which means that they are not linearly independent, which means that the determinant is exactly zero. Which means that A does not have an inverse..

更多回答(2 个)

John D'Errico
John D'Errico 2020-12-18
So what can we say about the solution? David and Walter have both told you the matrix really is singular. A singular matrix will offer no (unique) solution, even if a solution does exist.
format long g
A = [0.2500000000 0.00000000959994 0 -1 0 ; 0 0.2500000000000 0.0000000095999400 0 -1 ; 0.2500000000 0.00000000000075 0 -1 0 ; 0 0.2500000000000 0.0000000000007500 0 -1 ; 0.2500000000 0.00000000087634 0 -1 0]
A = 5×5
0.25 9.59994e-09 0 -1 0 0 0.25 9.59994e-09 0 -1 0.25 7.5e-13 0 -1 0 0 0.25 7.5e-13 0 -1 0.25 8.7634e-10 0 -1 0
B = [-1.30038272588598 ; 14.8832035274747 ;-2.15072625510578 ; 18.9956035209202 ;-1.75244493678615]
B = 5×1
-1.30038272588598 14.8832035274747 -2.15072625510578 18.9956035209202 -1.75244493678615
So, first, is A singular? Yes, I am afraid it is so. Frequently this means you have some fundamental problem in what the problem itsef means. It usually indicates there is insufficient information provided, or that there are numerical issues with how the problem was formulated. I cannot get into that, since only you know the source of this system.
As has been said, A is singular. How singular is it? We can lean a lot by looking at the singular values of A.
svd(A)
ans = 5×1
1.78535710713571 1.45773797371133 7.2817214828277e-09 6.7876523428981e-09 6.26786446143732e-19
And this clearly tells us that A is singular, at least numerically so. Comparing the number of singular values that are no larger than eps times the largest singular value is a way to determine the rank. Essentially since there is one tiny singular value in that set, then we know your matrix has one row or column that is a linear combination of the rest. The rank of A will be 4. However, even given that, A is still a matrix with some numerical issues, since I see there are two singular values as small as 1e-9.
rank(A)
ans =
4
Even given that however, a solution may still exist. We can learn if an exact solution exists by looking at the rank of the new matrix [A,B].
rank([A,B])
ans =
5
svd([A,B])
ans = 5×1
24.3688338660988 1.7807585310089 0.178093625927577 7.26504934395921e-09 5.42536835540766e-10
Essentially, this tells us that NO exact solution exists, because there is no way to write the vector B as a linear combination of the columns of the matrix A. Thus the matrix [A,B] now has rank 5, instead of rank 4.
Are we done then? Well, we can still try to flog this dead horse yet a few more times. How closely can we approximate the vector B?
You had a problem in working with pin, because there are tow small singular values of A that are not truly zero. They are actually relatively rather large, so they cause numerical problems.
format short g
pinv(A)
ans = 5×5
0.10209 -1.7044e-10 0.064906 -7.426e-11 0.068298 1.0841e+08 -5.217e-09 -6.1976e+07 5.217e-09 -4.6435e+07 -0.20149 1.0418e+08 0.11519 -1.0418e+08 0.086301 0.070798 -4.2609e-11 -0.53355 -1.8565e-11 -0.47842 2.7103e+07 7.8136e-05 -1.5494e+07 -1.0001 -1.1609e+07
You should see that pinv(A) has some relatively large numbers in it, as well as some quite small numbers. And this is why pinv(A)*B gives you crap. So let me see how well we can approximate B, using only TWO pieces of information, instead of trying to use all 4 of the technically linearly independent pieces of information in A.
[U,S,V] = svd(A);
Now, if we recall that A had two relatively large singular values, we might try to approximate A by a low rank (rank 2) approximation using the singular value decomposition.
k = 1:2;
pinvapprox = U(:,k)*diag(1./diag(S(k,k)))*V(:,k)';
xhat2 = pinvapprox*B;
So we might try this:
[B,A*xhat2]
ans = 5×2
-1.3004 -4.091 14.883 6.7053 -2.1507 -4.091 18.996 6.7053 -1.7524 -4.091
The first column is B, the second column is the best rank 2 approximation to B given the matrix A. They are very different, and that is a bad thing. It tells me that there will be no solution to your problem that does not involve quite large numbers. Another way of seeing this is to look at the projections of B onto the vectors in the columns of V.
V'*B
ans = 5×1
18.744 -5.3098 14.014 -2.1507 -3.3456
That the first two elements of that vector are relatively large is good. But we wanted the other three elements to be small. And they were not. In fact, B has a significantly large projectino onto the nullspace vector. We see that in the last element of thos product.
So I am sorry, but there exists NO solution for the problem A*x==b with small numbers in it that comes even remotely close to solving this linear system.

Walter Roberson
Walter Roberson 2020-12-18
Your matrix is not just near to singular, it is singular. Your rows [1 3 5] are all the same except for column 2, so any one of them is a linear combination of the other two, so your matrix is singular.
You encounter significant round-off problems in calculating pinv(A) . If you have the symbolic toolbox, pinv(sym(A)) will have some important differences.
With that A matrix, the numeric calculation pinv(A) cannot be said to follow the second property of https://en.wikipedia.org/wiki/Moore%E2%80%93Penrose_inverse#Definition -- that (weak inverse). But if you use pinv(sym(A)) then that does hold.
Using pinv(sym(A)) does not help your situation -- you still get values in the millions when you multiply the pseudo-inverse by B.

类别

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