# [SciPy-user] small error problem

Ryan Krauss ryanlists at gmail.com
Sat Oct 29 13:01:43 CDT 2005

```I have a script that uses row reduction to mind the null space of a
matrix.  I am experiencing some strange behavior.  At the begining of
the script, I have a 2x2 matrix, but it is of rank 1.  (I realize that
find the null space of a 2x2 could be much simpler, but I will
generally have higher ranked matrices.  I have also found the
nullspace using svd, but have gotten the best results from rref in the
past.)

The fact that the matrix is rank one can be verified early in the
script.  Row 2 is a multiple of row 1:
(Pdb) mat[1,1]/mat[1,0]-mat[0,1]/mat[0,0]
Out[2]: NumPy array, format: long
0.0
(Pdb) '%0.30f'%(mat[1,1]/mat[1,0]-mat[0,1]/mat[0,0])
Out[2]: '0.000000000000000000000000000000'

In order to do the row reduction, I append a column of zeros:
(Pdb) vect
Out[2]: NumPy array, format: long
[[ 0.,]
[ 0.,]]
15  ->     mat=c_[mat,vect]
(Pdb) mat
Out[2]: NumPy array, format: long
[[ 1.50155914,-1.24770975,]
[-2.98977017, 2.48432803,]]

But now there is some small error:
(Pdb) '%0.30f'%(mat[1,1]/mat[1,0]-mat[0,1]/mat[0,0])
Out[2]: '-0.000000013035565737951060327759'
(Pdb) mat[1,1]/mat[1,0]-mat[0,1]/mat[0,0]
Out[2]: -1.303556573795106e-08

and the output is now a scalar instead of NumPy array, format: long

Any ideas why this is happening?

Thanks,

Ryan

```