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, 12 Sep 2018 00:42:22 +0200How to get the left matrix that was used to obtain reduced row echelon form?https://ask.sagemath.org/question/43633/how-to-get-the-left-matrix-that-was-used-to-obtain-reduced-row-echelon-form/ Hi all.
I have a matrix A and would like to determine a matrix E such that E*A = R, where R is the reduced row echelon form of the matrix A. I just know the command R = A.rref(). But I don't know how to get E (my stupid solution is to compute the inverse of the pivot columns of A ...). Is there e.g. an argument such that A.rref() also outputs E?
Thanks a lot,
JulianMon, 10 Sep 2018 17:25:45 +0200https://ask.sagemath.org/question/43633/how-to-get-the-left-matrix-that-was-used-to-obtain-reduced-row-echelon-form/Answer by slelievre for <p>Hi all.</p>
<p>I have a matrix A and would like to determine a matrix E such that E*A = R, where R is the reduced row echelon form of the matrix A. I just know the command R = A.rref(). But I don't know how to get E (my stupid solution is to compute the inverse of the pivot columns of A ...). Is there e.g. an argument such that A.rref() also outputs E?</p>
<p>Thanks a lot,
Julian</p>
https://ask.sagemath.org/question/43633/how-to-get-the-left-matrix-that-was-used-to-obtain-reduced-row-echelon-form/?answer=43635#post-id-43635You can use the `echelon_form` method with `transformation=True`.
Example:
sage: A = Matrix([[1, 2, 3], [3, 2, 1], [1, 1, 1]])
sage: A
[1 2 3]
[3 2 1]
[1 1 1]
sage: A.echelon_form(transformation=True)
(
[ 1 0 -1] [ 0 1 -2]
[ 0 1 2] [ 0 -1 3]
[ 0 0 0], [ 1 1 -4]
)Mon, 10 Sep 2018 18:31:53 +0200https://ask.sagemath.org/question/43633/how-to-get-the-left-matrix-that-was-used-to-obtain-reduced-row-echelon-form/?answer=43635#post-id-43635Comment by Jules for <p>You can use the <code>echelon_form</code> method with <code>transformation=True</code>.</p>
<p>Example:</p>
<pre><code>sage: A = Matrix([[1, 2, 3], [3, 2, 1], [1, 1, 1]])
sage: A
[1 2 3]
[3 2 1]
[1 1 1]
sage: A.echelon_form(transformation=True)
(
[ 1 0 -1] [ 0 1 -2]
[ 0 1 2] [ 0 -1 3]
[ 0 0 0], [ 1 1 -4]
)
</code></pre>
https://ask.sagemath.org/question/43633/how-to-get-the-left-matrix-that-was-used-to-obtain-reduced-row-echelon-form/?comment=43640#post-id-43640Thanks for your quick answer. However, it does not really what I would like to have :-/ Am I doing something wrong or does It not work if A is over GF(q). (gives A.echelon_form(transformation=True) always reduced row echelon form or just echelon form?)
Thanks :)Tue, 11 Sep 2018 16:22:27 +0200https://ask.sagemath.org/question/43633/how-to-get-the-left-matrix-that-was-used-to-obtain-reduced-row-echelon-form/?comment=43640#post-id-43640Comment by slelievre for <p>You can use the <code>echelon_form</code> method with <code>transformation=True</code>.</p>
<p>Example:</p>
<pre><code>sage: A = Matrix([[1, 2, 3], [3, 2, 1], [1, 1, 1]])
sage: A
[1 2 3]
[3 2 1]
[1 1 1]
sage: A.echelon_form(transformation=True)
(
[ 1 0 -1] [ 0 1 -2]
[ 0 1 2] [ 0 -1 3]
[ 0 0 0], [ 1 1 -4]
)
</code></pre>
https://ask.sagemath.org/question/43633/how-to-get-the-left-matrix-that-was-used-to-obtain-reduced-row-echelon-form/?comment=43642#post-id-43642There are two bugs in Sage regarding this:
- The method for reduced row echelon form, `rref`, calls the method `echelon_form`,
and is supposed to pass on the arguments it is given, such as `transformation=True`,
but it does not.
- The method `echelon_form` itself does not always honor the request to return the
transformation (i.e., the argument `transformation=True`).
See
- [Sage Trac ticket 23715: most matrices ignore `transformation=True` in `echelon_form`](https://trac.sagemath.org/ticket/23715).Wed, 12 Sep 2018 00:42:22 +0200https://ask.sagemath.org/question/43633/how-to-get-the-left-matrix-that-was-used-to-obtain-reduced-row-echelon-form/?comment=43642#post-id-43642