pinv of a singular matrix
6 views (last 30 days)
Show older comments
Hi,
I'm trying to solve for x in: Ax=b, but my A matrix is singular. An example of the A matrix is
-1 0 0 1 0 0 0
0 -1 1 0 0 0 0
0 1 -1 0 0 0 0
1 0 0 -1 0 0 0
0 1 0 0 -1 0 0
0 0 1 0 0 -1 0
0 0 0 1 0 0 -1
When I use pinv(A) to solve for x, I get spikes at intervals, and these intervals correspond to the spacing between 1's and -1's in the A matrix. An example is shown in the graph below:
Does anyone know why the spikes are there or how I can get rid of them? Or please suggest another decomposition technique or approach to solve the equation.
I know the way to get an exact (not approximate) solution is if I can make A non-singular. I've tried adding rows to A, each containing 1's and -1's with different number of 0 spacings but that doesn't make A full rank. I want 1's and -1's on each row because I need the b column vector to be a difference between 2 points in x. Please, any suggestion on how to make A non-singular is welcome.
Thanks!
5 Comments
John D'Errico
on 5 Jan 2016
Adding noise to your matrix will not really solve the problem. It will mask the issue. The issue is one of poor definition of your problem, leading to a singular matrix.
Answers (2)
John D'Errico
on 4 Jan 2016
Edited: John D'Errico
on 4 Jan 2016
The problem here is not pinv, but a lack of proper definition of the matrix you are trying to do the solution with. That matrix, and the problems you are having reflect a poorly posed problem. Sorry, but true.
Adding arbitrary rows to the matrix makes no sense at all, IF those rows do not mean something. A matrix is just a set of numbers in a regular form. And since only you know what those numbers mean, how the matrix as derived, then we will have a hard time helping you without more information from you.
Why does having a smooth curve there make sense? What is the meaning of that curve at all?
If I must guess, from the information you have bothered to give us, is that you expect a smooth curve out. Why? The crystal ball is sooooo foggy. HOWEVER........
You lack sufficient information in that matrix to ensure the result will be unique. That is one aspect of a singular problem. So IF you expect the result to be smooth across those boundaries, then adding a few CAREFULLY chosen rows to your matrix will help. (Think about the meaning of those rows as I have added them.)
A = [-1 0 0 1 0 0 0;
0 -1 1 0 0 0 0;
0 1 -1 0 0 0 0;
1 0 0 -1 0 0 0;
0 1 0 0 -1 0 0;
0 0 1 0 0 -1 0;
0 0 0 1 0 0 -1;
1 -2 1 0 0 0 0;
0 0 1 -2 1 0 0];
0 0 0 0 1 -2 1];
The right hand sides (elements of b) for those rows of A will be zeros.
Effectively, the idea is to provide additional information that the result be smooth. Add one such row to span each of your problem areas. I also added a similar row at the beginning, since you apparently also have this problem at each end.
Again, if I actually knew what you were doing or how you created the matrix, I might be able to offer a semi-intelligent answer. You get what you pay for.
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!