Matrix inversion failed?

I used method explained in example
to inverse a 36*36 matrix with small numbers. It fails for the method Invert() and InvertFast(), saying the matrix is singular. However, I managed to run third method in the above example using TDecompLU, by changing tolerance from default 2.2e-16 to 2.2e-20 to avoid zero(or less than Tolerance) number in diagonal elements of decomposed matrix.
However, the product of the original matrix and the inverse one is not a identity matrix. Most of the diagonal elements are close to one, but there are also 0.3 or 1.4 as instances. Also, non-diagonals elements are non-zero, with some cases close to e.g. 1.5 .

I also tried a second approach: multiplying original matrix with a fixed number(e.g. 1e+5) and finding the inverse of the new matrix. This way apparently avoid singularity of matrix, leads to an answer for the inverse matrix , but same issue of non-unity product of matrix and its inverse.

Any help is really appreciated,

What is the condition value returned ? TDecompLU::GetCondition()

You might try another also another decomposition, for example TDecompSVD


Hi Lorenzo,

Yes indeed matrix seems to be ill-conditioned. I report here numbers I got in different methods.
Determinant :-2e-214,
TDecompLU::GetCondition() : 0.0067
TDecompLU::Condition() : -9.6e+18
Maximum off-diagonal = 1.16064

Determinant : 0 ,
TDecompSVD::GetCondition() : 3.9e+17
TDecompSVD::Condition() : 3.9e+17
Maximum off-diagonal = 0.189259

What could be the solution ? (out of ROOT ? )
In TDecompLU, why do the
Condition() and GetCondition() give different numbers while this is not the case in SVD ? SVD gives determinant equal to zero , even if the tolerance is set to 2.2e-50, is that mean that SVD could not useful here ?

Thanks and cheers,


You can try to use different tools to invert the matrix, but with a such large condition 10^17-18, there is little hope. Maybe with Mathematica with very high numerical precision you can do something.
But do you really need an inverse of such a singular matrix ? Maybe one can find a solution avoiding to convert the matrix


Your posting raises some alarm bells. Please remind yourself what is the difference between precision and accuracy.
There is no obvious relation between the size of the matrix entries and possible singularity. In the link below is a nice example of a Hilbert matrix.

Please have a look at the description of the condition number in TDecompBase.cxx:

A condition number larger than 10^15 gives 0 accuracy with double arithmic.

On a side note, condition number are larger than 0 and GetCondition() and Condition() should result in the same number. Please publish a (small) code example that gave your results