Warning: Matrix is singular to working precision: What exactly generates this warning?

1 view (last 30 days)
I have a matrix with order 1458x1458. This results from a test simulation using the full set of Maxwell's equations with mixed finite elements. The matrix is constructed in FEniCS 2016.2 and exported to matlab for analysis. This matrix is constructed using Natural Boundary Conditions in this setup (which for this problem are homogeneous Neumann conditions) and generate a (theoretically) singular matrix with a (theoretically confirmed) two dimensional nullspace. When I analyze this matrix, I find:
(1) A two-dimensional nullspace as expected, (running svds and checking out the smallest singular values I find two of them reported as exactly zero).
(2) However, the matrix is severly ill-conditioned as well, rcond reports O(1e-22); and the absolute values of the eig function's output, reports a minimum value of O(1e-17), i.e., the smallest absolute eigenvalue.
An inv on this matrix, or a backslash solve with this matrix does not generate the "singular to working precision" warning, and I'd like to know why not. I.e., what characteristic / property of a matrix exactly generates that warning on using inv or backslash.

Answers (1)

Christine Tobler
Christine Tobler on 24 Mar 2021
The warning is generated based on an estimate of the condition number (specifically, the reciprocal condition number in 1-norm, as in https://www.mathworks.com/help/matlab/ref/rcond.html).
For dense matrices, this uses LAPACK's condition estimator which is quite accurate.
For sparse matrices, much more heuristic choices are made to estimate this condition number, for performance reasons. So it's quite possible for this to not notice when a matrix is badly conditioned.
Another option is to use the condest function to estimate the condition number of a sparse matrix.
In practice, it may be better to apply backslash, compute the residual, and then decide based on this if the matrix was singular to the point of causing an issue with the accuracy of the output.

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!