ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 30 Nov 2016 17:05:15 +0100echelon_form not giving reduced echelon formhttps://ask.sagemath.org/question/35819/echelon_form-not-giving-reduced-echelon-form/According to the document(emphasis mine):
> echelon_form(algorithm='default', cutoff=0, **kwds)
>
> Return the echelon form of self.
>
> **OUTPUT**:
>
> The *reduced row echelon form* of self, as an immutable matrix.
Here is what I was doing:
sage: A = Matrix([[1,0,3,1,2],[-1,3,0,-1,1],[2,1,7,2,5],[4,2,14,0,6]])
sage: A.echelon_form()
[1 0 3 1 2]
[0 1 1 0 1]
[0 0 0 4 4]
[0 0 0 0 0]
While the result is in row echelon form, it's not in **reduced** row echelon form. What I expect is something like this:
[1 0 3 0 1]
[0 1 1 0 1]
[0 0 0 1 1]
[0 0 0 0 0]
Also, if this is merely a documentation bug, how can I get the reduced row echelon form of a matrix?Wed, 30 Nov 2016 15:24:42 +0100https://ask.sagemath.org/question/35819/echelon_form-not-giving-reduced-echelon-form/Comment by kcrisman for <p>According to the document(emphasis mine):</p>
<blockquote>
<pre><code>echelon_form(algorithm='default', cutoff=0, **kwds)
</code></pre>
<p>Return the echelon form of self.</p>
<p><strong>OUTPUT</strong>:</p>
<p>The <em>reduced row echelon form</em> of self, as an immutable matrix.</p>
</blockquote>
<p>Here is what I was doing:</p>
<pre><code>sage: A = Matrix([[1,0,3,1,2],[-1,3,0,-1,1],[2,1,7,2,5],[4,2,14,0,6]])
sage: A.echelon_form()
[1 0 3 1 2]
[0 1 1 0 1]
[0 0 0 4 4]
[0 0 0 0 0]
</code></pre>
<p>While the result is in row echelon form, it's not in <strong>reduced</strong> row echelon form. What I expect is something like this:</p>
<pre><code>[1 0 3 0 1]
[0 1 1 0 1]
[0 0 0 1 1]
[0 0 0 0 0]
</code></pre>
<p>Also, if this is merely a documentation bug, how can I get the reduced row echelon form of a matrix?</p>
https://ask.sagemath.org/question/35819/echelon_form-not-giving-reduced-echelon-form/?comment=35821#post-id-35821Cross posted at http://stackoverflow.com/questions/40888112/sagemath-echelon-form-not-giving-echelon-formWed, 30 Nov 2016 17:01:57 +0100https://ask.sagemath.org/question/35819/echelon_form-not-giving-reduced-echelon-form/?comment=35821#post-id-35821Answer by nbruin for <p>According to the document(emphasis mine):</p>
<blockquote>
<pre><code>echelon_form(algorithm='default', cutoff=0, **kwds)
</code></pre>
<p>Return the echelon form of self.</p>
<p><strong>OUTPUT</strong>:</p>
<p>The <em>reduced row echelon form</em> of self, as an immutable matrix.</p>
</blockquote>
<p>Here is what I was doing:</p>
<pre><code>sage: A = Matrix([[1,0,3,1,2],[-1,3,0,-1,1],[2,1,7,2,5],[4,2,14,0,6]])
sage: A.echelon_form()
[1 0 3 1 2]
[0 1 1 0 1]
[0 0 0 4 4]
[0 0 0 0 0]
</code></pre>
<p>While the result is in row echelon form, it's not in <strong>reduced</strong> row echelon form. What I expect is something like this:</p>
<pre><code>[1 0 3 0 1]
[0 1 1 0 1]
[0 0 0 1 1]
[0 0 0 0 0]
</code></pre>
<p>Also, if this is merely a documentation bug, how can I get the reduced row echelon form of a matrix?</p>
https://ask.sagemath.org/question/35819/echelon_form-not-giving-reduced-echelon-form/?answer=35820#post-id-35820For your matrix you have:
sage: A.parent()
Full MatrixSpace of 4 by 5 dense matrices over Integer Ring
so it's a matrix over the integers. There "echelon form" means "Hermite normal form", which is what you got (the transition matrix is an integer matrix with an inverse that is also an integer matrix in that case. That's why the row [0 0 0 4 4] doesn't get scaled)
If you're interested in reduced row echelon form over the rationals, you can get that:
sage: B=A.change_ring(QQ)
sage: B.echelon_form()
[1 0 3 0 1]
[0 1 1 0 1]
[0 0 0 1 1]
[0 0 0 0 0]
Wed, 30 Nov 2016 16:34:17 +0100https://ask.sagemath.org/question/35819/echelon_form-not-giving-reduced-echelon-form/?answer=35820#post-id-35820Comment by kcrisman for <p>For your matrix you have:</p>
<pre><code>sage: A.parent()
Full MatrixSpace of 4 by 5 dense matrices over Integer Ring
</code></pre>
<p>so it's a matrix over the integers. There "echelon form" means "Hermite normal form", which is what you got (the transition matrix is an integer matrix with an inverse that is also an integer matrix in that case. That's why the row [0 0 0 4 4] doesn't get scaled)</p>
<p>If you're interested in reduced row echelon form over the rationals, you can get that:</p>
<pre><code>sage: B=A.change_ring(QQ)
sage: B.echelon_form()
[1 0 3 0 1]
[0 1 1 0 1]
[0 0 0 1 1]
[0 0 0 0 0]
</code></pre>
https://ask.sagemath.org/question/35819/echelon_form-not-giving-reduced-echelon-form/?comment=35822#post-id-35822On the Stackoverflow one though the question is whether the "Hermite normal form" or whatever actually should be called a *reduced* form or not. Perhaps that is a subtle doc bug, even given our usual answer where the base ring matters? I just don't know whether there is a standard terminology in the non-field case for "reduced".Wed, 30 Nov 2016 17:05:15 +0100https://ask.sagemath.org/question/35819/echelon_form-not-giving-reduced-echelon-form/?comment=35822#post-id-35822