[SciPy-user] small error problem

Travis Oliphant oliphant at ee.byu.edu
Sat Oct 29 13:12:23 CDT 2005

Ryan Krauss wrote:

>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
which version of scipy are you using?

>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
>(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
I'm not sure what NumPy array, format: long means

It does seem strange that the expression is different things in 
different places. 

Could you post more information.  What is the result of type(mat), for 



More information about the SciPy-user mailing list