I would like to know the mathematical concepts behind singular matrices. Matrices that do not have inverses in R throw one of two errors. I have provided some examples of both errors below:

Error in solve.default(W) : system is computationally singular: reciprocal condition number = 1.58603e-17

Error in solve.default(Z) : Lapack routine dgesv: system is exactly singular: U[2,2] = 0

Can anyone explain the difference between the two? Why is the first "nearly singular" whereas the second is "exactly singular"?

**Contents**hide

#### Best Answer

The condition number that is typically used in linear algebra to describe a matrix $A$ indicates, very roughly, how many significant digits of accuracy you can expect to lose when solving a linear system $Ax=b$ using infinite-point accurate arithmetic. In the first case (condition number of of $1.58603e-17$), the matrix is so close to singular that you are losing about 17 digits of accuracy. Double precision floats, according to the IEEE 754 standard, have about 16 digits of accuracy, so losing 17 digits means there's no accuracy left, basically. The matrix does have an inverse, but, at some point, a responsible algorithm will tell you that you are losing more accuracy than your data has rather than return a result that is almost certainly meaningless and letting subsequent calculations (including your analysis of the results) continue on unaware of this problem. That is what "computationally singular" means in this context.

The condition number is a function of the matrix $A$, not of the algorithms operating on $A$, so, for example, changing to a different linear solver won't change the condition number.

A system that is exactly singular is one for which some of the columns are linear combinations of each other; in this case, the matrix does not have an inverse at all.

### Similar Posts:

- Solved – Intuition as to why estimates of a covariance matrix are numerically unstable
- Solved – Mahalanobis Distance on Singular Data
- Solved – Mahalanobis Distance on Singular Data
- Solved – Number of combinations for a 4- digit code lock
- Solved – How to fit an ARMAX model with more than one exogenous time series