Clear Filters
Clear Filters

How to eliminate the following warning: matrix singular to machine precision

17 views (last 30 days)
Hello all, 
In the following equation, Az = b;
z = A\b;
When I solve for z by the inverse of A, I get this message:
warning: matrix singular to machine precision
My [A] matrix is actually non-singular. But the warning message seems to be explaining that the [A] matrix is singular (its determinant is 0) somewhere in my big matrix, and thus it does not have an inverse.
Can this be avoided? And will such a warning influence the results significantly?
Thank you

Answers (1)

Manish
Manish on 23 Aug 2024
Hi,
I understand that you are using the "mldivide(\)" function on your matrices and are encountering a warning. You are seeking a way to bypass this warning.
The warning "Matrix is singular to working precision" is generated when the condition number of a matrix is zero. This condition number is independent of the matrix's singularity. The condition number is determined using the "rcond" function.
Refer to the Linear System with Singular Matrix section of the document.
There may be instances where a matrix is non-singular, yet the "rcond" value can still be zero.
%Example
A = [1, 1; 1, 1 + 1e-16];
determinant = det(A);
if determinant == 0
disp('The matrix is singular.');
else
disp('The matrix is non-singular.');
end
rcond_value = rcond(A);
disp(rcond_value)
Refer to the “rcond” documentation in the below link:
To bypass this warning, you can try the following:
1) Regularization: Techniques such as Tikhonov regularization add a small value to the diagonal elements of the matrix, effectively improving its condition number.
2) Rescaling: Adjusting the scales of the matrix's columns or rows can sometimes improve conditioning.
Hope it helps!

Categories

Find more on Mathematics 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!