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, 13 Apr 2022 17:31:09 +0200.rref() over the reals?https://ask.sagemath.org/question/61953/rref-over-the-reals/Hi everyone,
I just discovered sage and was trying to obtain the reduced echelon form of a real augmented matrix with the following code:
A = matrix(RR,[[27.6, 30.2], [3100, 6400], [250, 360]]);
B = column_matrix(RR, [162 , 23610, 1623]);
C = A.augment(B, subdivide = True);
C.rref();
The output is the identity matrix:
[1.0 0.0|0.0]
[0.0 1.0|0.0]
[0.0 0.0|1.0]
This is not right over the reals, as A\B yields
[3.90000000000000]
[1.80000000000000]
Is there any way I obtain the correct output with rref(), that is
[ 1.00000000000000 0.000000000000000| 3.90000000000000]
[0.000000000000000 1.00000000000000| 1.80000000000000]
[0.000000000000000 0.000000000000000|0.000000000000000]Wed, 13 Apr 2022 16:59:51 +0200https://ask.sagemath.org/question/61953/rref-over-the-reals/Answer by mouss5ss for <p>Hi everyone,</p>
<p>I just discovered sage and was trying to obtain the reduced echelon form of a real augmented matrix with the following code:</p>
<pre><code>A = matrix(RR,[[27.6, 30.2], [3100, 6400], [250, 360]]);
B = column_matrix(RR, [162 , 23610, 1623]);
C = A.augment(B, subdivide = True);
C.rref();
</code></pre>
<p>The output is the identity matrix:</p>
<pre><code>[1.0 0.0|0.0]
[0.0 1.0|0.0]
[0.0 0.0|1.0]
</code></pre>
<p>This is not right over the reals, as A\B yields</p>
<pre><code>[3.90000000000000]
[1.80000000000000]
</code></pre>
<p>Is there any way I obtain the correct output with rref(), that is </p>
<pre><code>[ 1.00000000000000 0.000000000000000| 3.90000000000000]
[0.000000000000000 1.00000000000000| 1.80000000000000]
[0.000000000000000 0.000000000000000|0.000000000000000]
</code></pre>
https://ask.sagemath.org/question/61953/rref-over-the-reals/?answer=61954#post-id-61954I found the answer, simply using QQ and getting back to RR does the trick:
A = matrix([[27.6, 30.2], [3100, 6400], [250, 360]]);
B = vector([162 , 23610, 1623]);
C = A.augment(B, subdivide = True);
C.change_ring(QQ).rref().change_ring(RR);Wed, 13 Apr 2022 17:31:09 +0200https://ask.sagemath.org/question/61953/rref-over-the-reals/?answer=61954#post-id-61954