# Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 2.240406e-24.

10 views (last 30 days)
mirewuti muhetaer on 14 Jan 2020
Commented: mirewuti muhetaer on 15 Jan 2020
Hi, I have an operation like this: inv(A)*B; and i get this warning:
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 2.240406e-24.
I checked everything and the matrix's inputs are just badly scaled ( but the data is exacly what it is). Besides, determinents of both A, inv(A) are not zero. But the determinent of A is very very very small, nearly to zero.
Do i have to worry about the accurace of my operation or can do further operation on inv(A)*B?. I just want to make sure no mistakes happened because of ill-seriesness.
Thanks.

Walter Roberson on 14 Jan 2020
Do i have to worry about the accurace of my operation
You should always be worried about the accuracy of your calculation any time you use inv() . Do not use it: use A\B instead .
mirewuti muhetaer on 14 Jan 2020
Really appreciated!!!

Matt J on 14 Jan 2020
Even with A\B, you cannot expect reliable behavior with RCOND as small as 2.240406e-24. For all intents and purposes, your matrix is singular.

Walter Roberson on 15 Jan 2020
Sometimes you can side-step the errror message by using
sym(A)\sym(B)
sym() applied to the arrays would approximate each floating point number as an extended algebraic number (square roots, pi). But it will not always use the approximation you might expect. For example it would approximate 2.7178-1.414 as 6519/5000 instead of exp(1) - 2^(1/2) . Or it would approximate pi-313*eps as pi instead of as 1768559438007071/562949953421312
You can get more consistency by using
sym(A, 'f')\sym(B, 'f')
... Though chances are that if you get pushed to the point where you are using sym(A)\sym(B) to avoid error messages, then you should have been using symbolic computations to build up A and B in the first place
Using this technique with sym() to avoid the error message is, most of the time, a case Garbage In, Garbage Out: it takes in your garbage coefficients, and says, "For the sake of following rules blindly, we will pretend that those numbers are infinitely accurate, and give you the result as if they were, even though mathematically if even one of those numbers had been different in the 16th decimal place, you would have gotten a very different answer"
mirewuti muhetaer on 15 Jan 2020
Hi, really thanks. It helps a lot.