MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

# Thread Subject: Improve Condition Number of Matrix

 Subject: Improve Condition Number of Matrix From: Michael Date: 8 Aug, 2012 21:56:14 Message: 1 of 17 Hi, I am trying to invert a 8x8 matrix with a poor condition number. The equation I am trying to solve is X=inv(A)Y where A is my poorly conditioned matrix. I managed to improve the condition number to 1.7559e+16 with some techniques mentioned below (but is still too high): -Diagonal Balance- inv(DA)DY=X -Using pinv instead of inv (which solves X to within 10% of the values I was expecting, I need <1%) - Left division- X=A\Y Are there any other ways to improve the condition of the matrix so it inverts better? or methods to estimate the inverse?
 Subject: Improve Condition Number of Matrix From: Matt J Date: 8 Aug, 2012 22:06:17 Message: 2 of 17 "Michael " wrote in message ... > > > Are there any other ways to improve the condition of the matrix so it inverts better? or methods to estimate the inverse? ================= Isn't it possible that you simply have an (approximately) under-determined system? Give the system more information by including more equations...
 Subject: Improve Condition Number of Matrix From: John D'Errico Date: 8 Aug, 2012 22:12:15 Message: 3 of 17 "Michael " wrote in message ... > Hi, > > I am trying to invert a 8x8 matrix with a poor condition number. The equation I am trying to solve is X=inv(A)Y where A is my poorly conditioned matrix. I managed to improve the condition number to 1.7559e+16 with some techniques mentioned below (but is still too high): > > -Diagonal Balance- inv(DA)DY=X > > -Using pinv instead of inv (which solves X to within 10% of the values I was expecting, I need <1%) > > - Left division- X=A\Y > > Are there any other ways to improve the condition of the matrix so it inverts better? or methods to estimate the inverse? The matrix is numerically singular. You can get an infinite number of solutions. Take your pick. Wanting 1% accuracy is a foolish expectation from a singular matrix when you can choose infinitely many solutions. John
 Subject: Improve Condition Number of Matrix From: Michael Date: 8 Aug, 2012 22:33:14 Message: 4 of 17 "Matt J" wrote in message ... > "Michael " wrote in message ... > > > > > > Are there any other ways to improve the condition of the matrix so it inverts better? or methods to estimate the inverse? > ================= > > Isn't it possible that you simply have an (approximately) under-determined system? Give the system more information by including more equations... I have more data so I could use a least squares approach and use more equations. However I know before hand that the 8 Y values should follow the relationship dictated by the 8 linear equations exactly (and by exactly i mean ~11 significant digits), so I would like 8 equations to be sufficient. The problem is that the condition of the matrix is so poor that the very insignificant error associated in Y gets exploded when solving for X. What I would like is recommendations to improve the condition value of the A matrix through scaling or similar means.
 Subject: Improve Condition Number of Matrix From: Michael Date: 8 Aug, 2012 22:37:17 Message: 5 of 17 "John D'Errico" wrote in message ... > "Michael " wrote in message ... > > Hi, > > > > I am trying to invert a 8x8 matrix with a poor condition number. The equation I am trying to solve is X=inv(A)Y where A is my poorly conditioned matrix. I managed to improve the condition number to 1.7559e+16 with some techniques mentioned below (but is still too high): > > > > -Diagonal Balance- inv(DA)DY=X > > > > -Using pinv instead of inv (which solves X to within 10% of the values I was expecting, I need <1%) > > > > - Left division- X=A\Y > > > > Are there any other ways to improve the condition of the matrix so it inverts better? or methods to estimate the inverse? > > The matrix is numerically singular. You can get an > infinite number of solutions. Take your pick. > > Wanting 1% accuracy is a foolish expectation from > a singular matrix when you can choose infinitely > many solutions. > > John The matrix is almost singular yes. There should be methods by scaling, that could improve the matrix condition number, and make it more invertible.
 Subject: Improve Condition Number of Matrix From: Matt J Date: 9 Aug, 2012 10:58:10 Message: 6 of 17 "Michael Himmelfarb" wrote in message ... > > > The matrix is almost singular yes. There should be methods by scaling, that could improve the matrix condition number, and make it more invertible. =========== I doubt it. Not when the 1./cond(A) is so close to the numerical precision threshold, eps. And even if the condition number were more manageable, it seems like nondiagonal scaling is required here, which would be more computationally demanding than simply adding more equations to the system. You would have to start taking QR decompositions or SVDs, probably, to find the principal axes that need to be scaled...
 Subject: Improve Condition Number of Matrix From: Bruno Luong Date: 9 Aug, 2012 11:13:15 Message: 7 of 17 "Matt J" wrote in message ... > "Michael Himmelfarb" wrote in message You would have to start taking QR decompositions or SVDs, probably, to find the principal axes that need to be scaled... But SVD is what PINV command does. Just a quick note to stop people to believe into miracle: If the problem is ill-conditioned there is no thing one can do about it. One can transform the problem by another parametrization in which the matrix _looks_ better conditioned. But the ill-conditioned characteristic of the original problem is not going away. As John said, hopping 1% error on a singular matrix (CDN ~1e16) is foolish. The condition number must be at most (0.01/eps) = 4.5036e+13 for such precision. Bruno
 Subject: Improve Condition Number of Matrix From: Matt J Date: 9 Aug, 2012 14:03:17 Message: 8 of 17 "Bruno Luong" wrote in message ... > > One can transform the problem by another parametrization in which the matrix _looks_ better conditioned. But the ill-conditioned characteristic of the original problem is not going away. ============= OK, but it's more than just that it _looks_ better conditioned, right? As long as you're willing to stick to the new space of parameters, you should get well-conditioned results there, no?
 Subject: Improve Condition Number of Matrix From: Steven_Lord Date: 9 Aug, 2012 15:03:37 Message: 9 of 17 "Michael " wrote in message news:jvupfa\$2dm\$1@newscl01ah.mathworks.com... > "Matt J" wrote in message ... >> "Michael " wrote in message >> ... >> > >> > >> > Are there any other ways to improve the condition of the matrix so it >> > inverts better? or methods to estimate the inverse? >> ================= >> >> Isn't it possible that you simply have an (approximately) >> under-determined system? Give the system more information by including >> more equations... > > I have more data so I could use a least squares approach and use more > equations. > However I know before hand that the 8 Y values should follow the > relationship dictated by the 8 linear equations exactly (and by exactly i > mean ~11 significant digits), so I would like 8 equations to be > sufficient. Is this data something that you collected via physical processes (measuring length, weight, time, angles, etc.)? If so, are the processes you used to collect the data that accurate? Theoretically your data may allow such an exact fitting. In theory there is no difference between theory and practice. In practice there is. > The problem is that the condition of the matrix is so poor that the very > insignificant error associated in Y gets exploded when solving for X. > > What I would like is recommendations to improve the condition value of the > A matrix through scaling or similar means. -- Steve Lord slord@mathworks.com To contact Technical Support use the Contact Us link on http://www.mathworks.com
 Subject: Improve Condition Number of Matrix From: Bruno Luong Date: 9 Aug, 2012 15:11:14 Message: 10 of 17 "Matt J" wrote in message ... > > OK, but it's more than just that it _looks_ better conditioned, right? As long as you're willing to stick to the new space of parameters, you should get well-conditioned results there, no? If such thing was true, Heisenberg's uncertainty principe would never exist. Bruno
 Subject: Improve Condition Number of Matrix From: Matt J Date: 9 Aug, 2012 18:25:15 Message: 11 of 17 "Bruno Luong" wrote in message ... > "Matt J" wrote in message ... > > > > > OK, but it's more than just that it _looks_ better conditioned, right? As long as you're willing to stick to the new space of parameters, you should get well-conditioned results there, no? > > If such thing was true, Heisenberg's uncertainty principe would never exist. ============== I need a clearer example than Heisenberg, I'm afraid. How can the new condition number not describe the error sensitivity of the _new_ parameters?
 Subject: Improve Condition Number of Matrix From: Bruno Luong Date: 9 Aug, 2012 18:54:07 Message: 12 of 17 Who care about the new parameters? One can define the new parameters as the observers, the condition number is then 1. How does it helps? Bruno
 Subject: Improve Condition Number of Matrix From: Matt J Date: 9 Aug, 2012 19:27:10 Message: 13 of 17 "Bruno Luong" wrote in message ... > Who care about the new parameters? > > One can define the new parameters as the observers, the condition number is then 1. How does it helps? ============ Well, not in a big way. Maybe just to find a more natural scaling for your variables, so that your errors are always <<1 unit.
 Subject: Improve Condition Number of Matrix From: Michael Himmelfarb Date: 9 Aug, 2012 20:50:16 Message: 14 of 17 "Matt J" wrote in message ... > "Bruno Luong" wrote in message ... > > Who care about the new parameters? > > > > One can define the new parameters as the observers, the condition number is then 1. How does it helps? > ============ > > Well, not in a big way. Maybe just to find a more natural scaling for your variables, so that your errors are always <<1 unit. Yes that is exactly what I needed because the error sensitivity was too high. I managed to improve the condition number enough to solve within 0.1% of the actual values using SVD to precondition my matrix for inverse (essentially pinv). Unfortunately now I need to reproduce this with a similar matrix that is 24x24 with a condition number of ~1e19.
 Subject: Improve Condition Number of Matrix From: Matt J Date: 9 Aug, 2012 21:35:23 Message: 15 of 17 "Michael Himmelfarb" wrote in message ... > "Matt J" wrote in message ... > > "Bruno Luong" wrote in message ... > > > Who care about the new parameters? > > > > > > One can define the new parameters as the observers, the condition number is then 1. How does it helps? > > ============ > > > > Well, not in a big way. Maybe just to find a more natural scaling for your variables, so that your errors are always <<1 unit. > > Yes that is exactly what I needed because the error sensitivity was too high. I managed to improve the condition number enough to solve within 0.1% of the actual values using SVD to precondition my matrix for inverse (essentially pinv). Unfortunately now I need to reproduce this with a similar matrix that is 24x24 with a condition number of ~1e19. ============= No, I don't think we're talking about the same thing. I was saying that reparametrizing could be helpful if you want the _absolute errors_ (not the percent errors) to be much less than 1 unit. If your variables fluctuate by miles, you might not want to be measuring them in millimeters. It's not clear to us, though, how you think you've helped yourself by transforming the matrix. You've achieved lower percent error in a set of transformed variables, yes, but not in the original variables of interest.
 Subject: Improve Condition Number of Matrix From: long zhang Date: 24 Aug, 2012 21:44:07 Message: 16 of 17 Hi, This is Will. My research topic is to solve ill-conditioned matrix. Could you please email me your matrix and then I will try to solve it using a new method I know? Best wishes Will "Michael Himmelfarb" wrote in message ... > Hi, > > I am trying to invert a 8x8 matrix with a poor condition number. The equation I am trying to solve is X=inv(A)Y where A is my poorly conditioned matrix. I managed to improve the condition number to 1.7559e+16 with some techniques mentioned below (but is still too high): > > -Diagonal Balance- inv(DA)DY=X > > -Using pinv instead of inv (which solves X to within 10% of the values I was expecting, I need <1%) > > - Left division- X=A\Y > > Are there any other ways to improve the condition of the matrix so it inverts better? or methods to estimate the inverse?
 Subject: Improve Condition Number of Matrix From: Michael Himmelfarb Date: 24 Aug, 2012 22:28:07 Message: 17 of 17 "long zhang" wrote in message ... > Hi, > > This is Will. My research topic is to solve ill-conditioned matrix. Could you please email me your matrix and then I will try to solve it using a new method I know? > > Best wishes > Will > > "Michael Himmelfarb" wrote in message ... > > Hi, > > > > I am trying to invert a 8x8 matrix with a poor condition number. The equation I am trying to solve is X=inv(A)Y where A is my poorly conditioned matrix. I managed to improve the condition number to 1.7559e+16 with some techniques mentioned below (but is still too high): > > > > -Diagonal Balance- inv(DA)DY=X > > > > -Using pinv instead of inv (which solves X to within 10% of the values I was expecting, I need <1%) > > > > - Left division- X=A\Y > > > > Are there any other ways to improve the condition of the matrix so it inverts better? or methods to estimate the inverse? Ok, I emailed you my unconditioned matrix. This one is a little larger than the one I mentioned earlier but if you are up to the challenge I would appreciate help with solving this set of linear equations. Let me know what solution you get.