MATLAB: Rcond warning differs from computed value of rcond

ill-conditionedinverse

Suppose I have a matrix M.
M = [1, 2, 3; 3, 4, 5; 5, 6, 7]
M =
1 2 3
3 4 5
5 6 7
This is obviously a singular matrix, so the following orange warning is no surprise if I try to invert the matrix.
>> inv(M)
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 7.031412e-18.
I can compute the value of RCOND displayed in the warning with the MATLAB command rcond:
>> rcond(M)
ans =
7.0314e-18
So now I want to solve a large system Ax=b where A is sparse (which is 5185×5185 and I unfortunately can't easily share) and I get the singular matrix warning.
>> A\b
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 6.163871e-22.
My question is, why does the following computation not agree with what MATLAB outputs in the warning?
>> rcond(full(A))
ans =
6.7160e-10
Any ideas on how I can isolate this issue? I have a hard time believing this large discrepancy is due to using sparse matrices, but have no other leads on what could be happening.
Unfortunately this forum is flooded with people asking why their specific problem is ill-conditioned so searching did me no good.

Best Answer

When your matrix is ill-conditionned, everything computing that is related to the subspaces of the smallest eigen values are affected by numerical noise and truncation, including the estimation of the smallest eigen value.
(However the largest engen space is still stable numerically).
So when the condition number is large, the estimation of the condition number itself become unstable. Since the condition number is estimated as the ratio of the largest eigen values (stable) and the smallest ones, which is instable.
Rule of thumb if true your condition number is >= 1e10, the estimate of condition number by various methods become meaningless.
Bellow that it's OK.