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.Sun, 10 Sep 2023 18:17:50 +0200Problem with matrix echelon formhttps://ask.sagemath.org/question/73196/problem-with-matrix-echelon-form/Dear all,
if we define A to be
A = matrix([[1,-3,0,2],[-2,4,0,h],[0,-2,1,k],[3,-1,7,1]])
A.echelon_form()
gives diag(1,1,1,1).
But this is wrong for some values of h and k.In some cases the last 1 could be 0.
How can I fix this?
Thanks, NThu, 07 Sep 2023 07:03:34 +0200https://ask.sagemath.org/question/73196/problem-with-matrix-echelon-form/Comment by Sotto for <p>Dear all,</p>
<p>if we define A to be</p>
<pre><code>A = matrix([[1,-3,0,2],[-2,4,0,h],[0,-2,1,k],[3,-1,7,1]])
A.echelon_form()
</code></pre>
<p>gives diag(1,1,1,1).
But this is wrong for some values of h and k.In some cases the last 1 could be 0.</p>
<p>How can I fix this?
Thanks, N</p>
https://ask.sagemath.org/question/73196/problem-with-matrix-echelon-form/?comment=73334#post-id-73334diag not drag :-)Sun, 10 Sep 2023 10:15:11 +0200https://ask.sagemath.org/question/73196/problem-with-matrix-echelon-form/?comment=73334#post-id-73334Comment by Sotto for <p>Dear all,</p>
<p>if we define A to be</p>
<pre><code>A = matrix([[1,-3,0,2],[-2,4,0,h],[0,-2,1,k],[3,-1,7,1]])
A.echelon_form()
</code></pre>
<p>gives diag(1,1,1,1).
But this is wrong for some values of h and k.In some cases the last 1 could be 0.</p>
<p>How can I fix this?
Thanks, N</p>
https://ask.sagemath.org/question/73196/problem-with-matrix-echelon-form/?comment=73333#post-id-73333I see. Thanks.
But in this case I have to enter the values for h and k. That's not what I want...
I'd like Sage to tell me what condition on h and k gives an echelon form like drag(1,1,1,1) and which one gives drag(1,1,1,0).Sun, 10 Sep 2023 10:13:37 +0200https://ask.sagemath.org/question/73196/problem-with-matrix-echelon-form/?comment=73333#post-id-73333Comment by Max Alekseyev for <p>Dear all,</p>
<p>if we define A to be</p>
<pre><code>A = matrix([[1,-3,0,2],[-2,4,0,h],[0,-2,1,k],[3,-1,7,1]])
A.echelon_form()
</code></pre>
<p>gives diag(1,1,1,1).
But this is wrong for some values of h and k.In some cases the last 1 could be 0.</p>
<p>How can I fix this?
Thanks, N</p>
https://ask.sagemath.org/question/73196/problem-with-matrix-echelon-form/?comment=73304#post-id-73304Like this:
def myform(h,k):
A = matrix([[1,-3,0,2],[-2,4,0,h],[0,-2,1,k],[3,-1,7,1]])
return A.echelon_form()Sat, 09 Sep 2023 14:46:49 +0200https://ask.sagemath.org/question/73196/problem-with-matrix-echelon-form/?comment=73304#post-id-73304Comment by Sotto for <p>Dear all,</p>
<p>if we define A to be</p>
<pre><code>A = matrix([[1,-3,0,2],[-2,4,0,h],[0,-2,1,k],[3,-1,7,1]])
A.echelon_form()
</code></pre>
<p>gives diag(1,1,1,1).
But this is wrong for some values of h and k.In some cases the last 1 could be 0.</p>
<p>How can I fix this?
Thanks, N</p>
https://ask.sagemath.org/question/73196/problem-with-matrix-echelon-form/?comment=73303#post-id-73303Sorry not clear enough for me …
What do you mean?Sat, 09 Sep 2023 12:27:11 +0200https://ask.sagemath.org/question/73196/problem-with-matrix-echelon-form/?comment=73303#post-id-73303Comment by Max Alekseyev for <p>Dear all,</p>
<p>if we define A to be</p>
<pre><code>A = matrix([[1,-3,0,2],[-2,4,0,h],[0,-2,1,k],[3,-1,7,1]])
A.echelon_form()
</code></pre>
<p>gives diag(1,1,1,1).
But this is wrong for some values of h and k.In some cases the last 1 could be 0.</p>
<p>How can I fix this?
Thanks, N</p>
https://ask.sagemath.org/question/73196/problem-with-matrix-echelon-form/?comment=73203#post-id-73203A possible approach would be defining a function of `h` and `k`.Thu, 07 Sep 2023 17:29:37 +0200https://ask.sagemath.org/question/73196/problem-with-matrix-echelon-form/?comment=73203#post-id-73203Answer by Max Alekseyev for <p>Dear all,</p>
<p>if we define A to be</p>
<pre><code>A = matrix([[1,-3,0,2],[-2,4,0,h],[0,-2,1,k],[3,-1,7,1]])
A.echelon_form()
</code></pre>
<p>gives diag(1,1,1,1).
But this is wrong for some values of h and k.In some cases the last 1 could be 0.</p>
<p>How can I fix this?
Thanks, N</p>
https://ask.sagemath.org/question/73196/problem-with-matrix-echelon-form/?answer=73338#post-id-73338I'm not sure why this does not work over the symbolic ring, but it does so over the rational field of polynomials in `h` and `k`:
R.<h,k> = PolynomialRing(QQ,2)
A = matrix([[1,-3,0,2],[-2,4,0,h],[0,-2,1,k],[3,-1,7,1]])
A.echelon_form()
gives
[ 1 0 0 -3/2*h - 4]
[ 0 1 0 -1/2*h - 2]
[ 0 0 1 -h + k - 4]
[ 0 0 0 11*h - 7*k + 39]
---
**ADDED.** Explanation for why this does not work over `SR` is given in [this answer](https://ask.sagemath.org/question/8386/row-echelon-form-of-a-matrix-containing-symbolic-expresssions/?answer=12778#post-id-12778).Sun, 10 Sep 2023 18:17:50 +0200https://ask.sagemath.org/question/73196/problem-with-matrix-echelon-form/?answer=73338#post-id-73338