Matrix is singular to working precision

39.7k Views Asked by At

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?

2

There are 2 best solutions below

0
On

As described in the comments:

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

0
On

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.