# Matrix is singular to working precision

I have a problem while evaluating inverse using inv in MATLAB. My matrix looks like this:

term1 =

29929       29756       29929           0       29756       29756
29756       29584       29756           0       29584       29584
29929       29756       29929           0       29756       29756
0           0           0           0           0           0
29756       29584       29756           0       29584       29584
29756       29584       29756           0       29584       29584


when i try to calculate inverse, MATLAB throws a warning Matrix is singular to working precision and the result is:

ans =

Inf   Inf   Inf   Inf   Inf   Inf
Inf   Inf   Inf   Inf   Inf   Inf
Inf   Inf   Inf   Inf   Inf   Inf
Inf   Inf   Inf   Inf   Inf   Inf
Inf   Inf   Inf   Inf   Inf   Inf
Inf   Inf   Inf   Inf   Inf   Inf


Can anyone tell me why this is happening and any ways to resolve it and get the correct result?

-
Your matrix is exactly singular (its determinant is $0$), and thus it does not have an inverse. Working precision of MATLAB does not have to deal with it. – Ilya Jan 31 '13 at 17:37
should i use pseudo inverse instead? – Abhishek Thakur Jan 31 '13 at 17:47
It depends on your purposes. – Ilya Jan 31 '13 at 17:48
Your matrix is singular, so you may find a pseudoinverse with WA Regards – Amzoti Jan 31 '13 at 17:48
@AbhishekThakur Yes, you could try pinv(A), but it depends on what you're looking for. You can also try $x=A\backslash b$ if you're trying to solve an equation $Ax=b$. – icurays1 Jan 31 '13 at 17:48

Not only is the fourth row (resp. fourth column) identically zero, the last two rows (resp. last two columns) are exact copies of the second row (resp. second column). Also the first and third rows (resp. columns) are equal. Any one of these duplications would make the matrix singular (rank deficient).

This also informs what systems $Ax = b$ can be solved. For example, the fourth component of $b$ must be zero, and the last two components must be the same as $b$'s second component in order for a solution to exist (and similar remarks can be made about the nonuniqueness of solutions when they do exist).

Since the matrix is real symmetric, one might approach such cases by orthogonal diagonalization. As the matrix entries are exact integers, another approach would be the Smith normal form. Either transformation would reveal the singularity of the matrix with more detail than the failed Matlab inversion.

-

The issue is not matlab related, the matrix is really singular (As are all matrices that contain a zero row or column).

If you need some kind of inverse, you can try the pseudo inverse with pinv

If you need to solve equations you can use the backslash operator as such: x=A∖b

-