# [Numpy-discussion] Question on LinAlg Inverse Algorithm

Bruce Southey bsouthey@gmail....
Wed Aug 31 13:10:56 CDT 2011

```On 08/31/2011 12:56 PM, Mark Janikas wrote:
> Right indeed... I have spent a lot of time looking at this and it seems a waste of time as the results are garbage anyways when the columns are collinear.  I am just going to set a threshold, check the condition number, continue is satisfied, return error/warning if not.... now, what is too large?.... Ill poke around.  TY!
>
> MJ
The results are not 'garbage' as if you have collinear columns as these
have very well-known and understandable meaning. But if you don't expect
this then you really need to examine how you are modeling or measuring
your data because that is where the problem lies. For example, if you
are measuring two variables then it means that those measurements are
not independent as you are assuming.

Bruce

> -----Original Message-----
> From: numpy-discussion-bounces@scipy.org [mailto:numpy-discussion-bounces@scipy.org] On Behalf Of Pauli Virtanen
> Sent: Wednesday, August 31, 2011 2:00 AM
> To: numpy-discussion@scipy.org
> Subject: Re: [Numpy-discussion] Question on LinAlg Inverse Algorithm
>
> On Tue, 30 Aug 2011 15:48:18 -0700, Mark Janikas wrote:
>> Last week I posted a question involving the identification of linear
>> dependent columns of a matrix... but now I am finding an interesting
>> result based on the linalg.inv() function... sometime I am able to
>> invert a matrix that has linear dependent columns and other times I get
>> the LinAlgError()... this suggests that there is some kind of random
>> component to the INV method.  Is this normal?
> I suspect that this is a case of floating-point rounding errors.
> Floating-point arithmetic is inexact, so even if a certain matrix
> is singular in exact arithmetic, for a computer it may still be
> invertible (by a given algorithm). This type of things are not
> unusual in floating-point computations.
>
> The matrix condition number (`np.linalg.cond`) is a better measure
> of whether a matrix is invertible or not.
>

```