[Numpy-discussion] Reduced row echelon form

jason-sage@creativetra... jason-sage@creativetra...
Tue Nov 18 17:17:00 CST 2008

Anne Archibald wrote:
> 2008/11/18 Robert Young <rob@roryoung.co.uk>:
>> Is there a method in NumPy that reduces a matrix to it's reduced row echelon
>> form? I'm brand new to both NumPy and linear algebra, and I'm not quite sure
>> where to look.
> Unfortunately, reduced row-echelon form doesn't really work when using
> approximate values: any construction of the reduced row-echelon form
> forces you many times to ask "is this number exactly zero or just very
> small?"; if it's zero you do one thing, but if it's very small you do
> something totally different - usually divide by it. With
> floating-point numbers, every calculation is approximate, and such a
> method will blow up completely. If you really need reduced row echelon
> form, you have to start with exact numbers and use a package that does
> exact computations (I think SymPy might be a place to start).

I also recommend Sage here (http://www.sagemath.org).  For example, here 
is a session in which we calculate the reduced echelon form of a matrix 
over the rationals (QQ):

sage: a=matrix(QQ,[[1,2,3],[4,5,6],[7,8,9]])
sage: a.echelon_form()
[ 1  0 -1]
[ 0  1  2]
[ 0  0  0]

Sage has quite a bit of advanced functionality for exact linear 
algebra.  (It also uses numpy as a backend to provide some nice 
functionality for approximate linear algebra).  Here is a short tutorial 
on constructions in linear algebra:  


More information about the Numpy-discussion mailing list