# [Numpy-discussion] Question on LinAlg Inverse Algorithm

Mark Janikas mjanikas@esri....
Wed Aug 31 12:56:28 CDT 2011

```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

-----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.

--
Pauli Virtanen

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

```