# [SciPy-dev] Reliability of results

Nils Wagner nwagner at mecha.uni-stuttgart.de
Mon Oct 31 07:49:56 CST 2005

```Hi all,

We should take care of using linalg.inv blindly (test_inv.py).

So how can we improve the behaviour of linalg.solve, linalg.lu,
linalg.inv etc.
with respect to  "nearly" singular  matrices (floating point arithmetic) ?

Any pointer would be appreciated.

Is it possibe to add the condition number to the output of linalg.solve,
linalg.inv, ... ?

For example linalg.lstsq returns the singular values.

lstsq(a, b, cond=None, overwrite_a=0, overwrite_b=0)
lstsq(a, b, cond=None, overwrite_a=0, overwrite_b=0) -> x,resids,rank,s

Return least-squares solution of a * x = b.

Inputs:

a -- An M x N matrix.
b -- An M x nrhs matrix or M vector.
cond -- Used to determine effective rank of a.

Outputs:

x -- The solution (N x nrhs matrix) to the minimization problem:
2-norm(| b - a * x |) -> min
resids -- The residual sum-of-squares for the solution matrix x
(only if M>N and rank==N).
rank -- The effective rank of a.
s -- Singular values of a in decreasing order. The condition number
of a is abs(s[0]/s[-1]).

Nils

-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_inv.py
Type: text/x-python
Size: 475 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/scipy-dev/attachments/20051031/96a249e1/attachment.py
```