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.Sat, 17 Jun 2017 04:30:01 +0200Hermite form, entries reduced over pivotshttps://ask.sagemath.org/question/37964/hermite-form-entries-reduced-over-pivots/ Hello!
I have a question concerning the function hermite_form. This function unfortunately does not reduce the entries above the pivots of the hermite normal form if I use the function on a matrix with polynomial entries. Is there another function or option which enables me to do that?
Following short example hopefully illustrates what I mean:
R.<x> = QQ[];
M = matrix(2,2, [x,x, 0,x]);
M.hermite_form()
This will give the exact same matrix M and not the matrix [x,0, 0,x] which I would expect or hope to get.
Especially if somebody wants to apply another algorithm to such a matrix in hermite form it can be difficult to work with non-reduced matrices.
Kind regards
PhilippFri, 16 Jun 2017 17:24:41 +0200https://ask.sagemath.org/question/37964/hermite-form-entries-reduced-over-pivots/Answer by kcrisman for <p>Hello!</p>
<p>I have a question concerning the function hermite_form. This function unfortunately does not reduce the entries above the pivots of the hermite normal form if I use the function on a matrix with polynomial entries. Is there another function or option which enables me to do that?
Following short example hopefully illustrates what I mean:</p>
<pre><code>R.<x> = QQ[];
M = matrix(2,2, [x,x, 0,x]);
M.hermite_form()
</code></pre>
<p>This will give the exact same matrix M and not the matrix [x,0, 0,x] which I would expect or hope to get. </p>
<p>Especially if somebody wants to apply another algorithm to such a matrix in hermite form it can be difficult to work with non-reduced matrices.</p>
<p>Kind regards</p>
<p>Philipp</p>
https://ask.sagemath.org/question/37964/hermite-form-entries-reduced-over-pivots/?answer=37966#post-id-37966One problem might be that you aren't working over the fraction field. Are you *sure* you want Hermite form and not a different echelon? Note that this is even partly documented - if you add the line `M = M.change_ring(R.fraction_field())` as suggested in http://doc.sagemath.org/html/en/reference/matrices/sage/matrix/matrix2.html (search for "hermite_form") it still does the same thing.
On the other hand, `M.echelon_form()` does what [you (apparently) want](http://sagecell.sagemath.org/?z=eJxljrEKgzAYhPdA3iFbEgihONZauhS6OOgqEkT_mIAmEAPN41dra4feet_xXS0v6UoKUlVNm2OE0c26CKHrI0YDaKKY9mEuGvqAMNsIVNB7b2Dyjrb8jBFZU677uYvBJpaJTJAmiSTISaSW5z-ilL3p3AgqWDeyWupNYr1T2sI0MM531GryNhaH8WPZshj_ZKU0e6M28BjCtMA_CvvZL_oCjaJDeA==&lang=sage).
R.<x> = QQ[];
@interact
def _(form=['Hermite','Echelon']):
M = matrix(2,2, [x,x, 0,x]);
M = M.change_ring(R.fraction_field())
if form=='Hermite':
show(M.hermite_form())
else:
show(M.echelon_form())
I don't know enough about the Hermite form to say more, but this is often what the issue is for other users in a similar situation. If this is wrong, then this is probably a bug, as opposed to inadequate documentation.Fri, 16 Jun 2017 18:50:55 +0200https://ask.sagemath.org/question/37964/hermite-form-entries-reduced-over-pivots/?answer=37966#post-id-37966Comment by philipp7 for <p>One problem might be that you aren't working over the fraction field. Are you <em>sure</em> you want Hermite form and not a different echelon? Note that this is even partly documented - if you add the line <code>M = M.change_ring(R.fraction_field())</code>as suggested in <a href="http://doc.sagemath.org/html/en/reference/matrices/sage/matrix/matrix2.html">http://doc.sagemath.org/html/en/refer...</a> (search for "hermite_form") it still does the same thing. </p>
<p>On the other hand, <code>M.echelon_form()</code> does what <a href="http://sagecell.sagemath.org/?z=eJxljrEKgzAYhPdA3iFbEgihONZauhS6OOgqEkT_mIAmEAPN41dra4feet_xXS0v6UoKUlVNm2OE0c26CKHrI0YDaKKY9mEuGvqAMNsIVNB7b2Dyjrb8jBFZU677uYvBJpaJTJAmiSTISaSW5z-ilL3p3AgqWDeyWupNYr1T2sI0MM531GryNhaH8WPZshj_ZKU0e6M28BjCtMA_CvvZL_oCjaJDeA==&lang=sage">you (apparently) want</a>.</p>
<pre><code>R.<x> = QQ[];
@interact
def _(form=['Hermite','Echelon']):
M = matrix(2,2, [x,x, 0,x]);
M = M.change_ring(R.fraction_field())
if form=='Hermite':
show(M.hermite_form())
else:
show(M.echelon_form())
</code></pre>
<p>I don't know enough about the Hermite form to say more, but this is often what the issue is for other users in a similar situation. If this is wrong, then this is probably a bug, as opposed to inadequate documentation.</p>
https://ask.sagemath.org/question/37964/hermite-form-entries-reduced-over-pivots/?comment=37968#post-id-37968Thank you very much for your answer. Unfortunately it is not what I hoped to get. Changing to the fraction field does not give the result that I want. I want to stay in the polynomials over the rationals and I only want to reduce the entries above the pivots. I know that the hermite normal form is defined quite differently amongst different authors but a lot of times the definition include that entries above the pivots are 0 or have a degree which is strictly smaller than the degree of the pivot. Furthermore often a unique representative (for instance monic polynomials here) is chosen.Fri, 16 Jun 2017 19:13:18 +0200https://ask.sagemath.org/question/37964/hermite-form-entries-reduced-over-pivots/?comment=37968#post-id-37968Comment by kcrisman for <p>One problem might be that you aren't working over the fraction field. Are you <em>sure</em> you want Hermite form and not a different echelon? Note that this is even partly documented - if you add the line <code>M = M.change_ring(R.fraction_field())</code>as suggested in <a href="http://doc.sagemath.org/html/en/reference/matrices/sage/matrix/matrix2.html">http://doc.sagemath.org/html/en/refer...</a> (search for "hermite_form") it still does the same thing. </p>
<p>On the other hand, <code>M.echelon_form()</code> does what <a href="http://sagecell.sagemath.org/?z=eJxljrEKgzAYhPdA3iFbEgihONZauhS6OOgqEkT_mIAmEAPN41dra4feet_xXS0v6UoKUlVNm2OE0c26CKHrI0YDaKKY9mEuGvqAMNsIVNB7b2Dyjrb8jBFZU677uYvBJpaJTJAmiSTISaSW5z-ilL3p3AgqWDeyWupNYr1T2sI0MM531GryNhaH8WPZshj_ZKU0e6M28BjCtMA_CvvZL_oCjaJDeA==&lang=sage">you (apparently) want</a>.</p>
<pre><code>R.<x> = QQ[];
@interact
def _(form=['Hermite','Echelon']):
M = matrix(2,2, [x,x, 0,x]);
M = M.change_ring(R.fraction_field())
if form=='Hermite':
show(M.hermite_form())
else:
show(M.echelon_form())
</code></pre>
<p>I don't know enough about the Hermite form to say more, but this is often what the issue is for other users in a similar situation. If this is wrong, then this is probably a bug, as opposed to inadequate documentation.</p>
https://ask.sagemath.org/question/37964/hermite-form-entries-reduced-over-pivots/?comment=37971#post-id-37971My guess is that it is some disagreement about definitions, then. Hopefully someone else may have a better answer.Fri, 16 Jun 2017 19:48:18 +0200https://ask.sagemath.org/question/37964/hermite-form-entries-reduced-over-pivots/?comment=37971#post-id-37971Comment by philipp7 for <p>One problem might be that you aren't working over the fraction field. Are you <em>sure</em> you want Hermite form and not a different echelon? Note that this is even partly documented - if you add the line <code>M = M.change_ring(R.fraction_field())</code>as suggested in <a href="http://doc.sagemath.org/html/en/reference/matrices/sage/matrix/matrix2.html">http://doc.sagemath.org/html/en/refer...</a> (search for "hermite_form") it still does the same thing. </p>
<p>On the other hand, <code>M.echelon_form()</code> does what <a href="http://sagecell.sagemath.org/?z=eJxljrEKgzAYhPdA3iFbEgihONZauhS6OOgqEkT_mIAmEAPN41dra4feet_xXS0v6UoKUlVNm2OE0c26CKHrI0YDaKKY9mEuGvqAMNsIVNB7b2Dyjrb8jBFZU677uYvBJpaJTJAmiSTISaSW5z-ilL3p3AgqWDeyWupNYr1T2sI0MM531GryNhaH8WPZshj_ZKU0e6M28BjCtMA_CvvZL_oCjaJDeA==&lang=sage">you (apparently) want</a>.</p>
<pre><code>R.<x> = QQ[];
@interact
def _(form=['Hermite','Echelon']):
M = matrix(2,2, [x,x, 0,x]);
M = M.change_ring(R.fraction_field())
if form=='Hermite':
show(M.hermite_form())
else:
show(M.echelon_form())
</code></pre>
<p>I don't know enough about the Hermite form to say more, but this is often what the issue is for other users in a similar situation. If this is wrong, then this is probably a bug, as opposed to inadequate documentation.</p>
https://ask.sagemath.org/question/37964/hermite-form-entries-reduced-over-pivots/?comment=37974#post-id-37974Probably. However, hermite form on integer matrices does reduce entries above the pivots. So even in Sage different definitions are used. Thanks anyway!Fri, 16 Jun 2017 20:16:20 +0200https://ask.sagemath.org/question/37964/hermite-form-entries-reduced-over-pivots/?comment=37974#post-id-37974Answer by nbruin for <p>Hello!</p>
<p>I have a question concerning the function hermite_form. This function unfortunately does not reduce the entries above the pivots of the hermite normal form if I use the function on a matrix with polynomial entries. Is there another function or option which enables me to do that?
Following short example hopefully illustrates what I mean:</p>
<pre><code>R.<x> = QQ[];
M = matrix(2,2, [x,x, 0,x]);
M.hermite_form()
</code></pre>
<p>This will give the exact same matrix M and not the matrix [x,0, 0,x] which I would expect or hope to get. </p>
<p>Especially if somebody wants to apply another algorithm to such a matrix in hermite form it can be difficult to work with non-reduced matrices.</p>
<p>Kind regards</p>
<p>Philipp</p>
https://ask.sagemath.org/question/37964/hermite-form-entries-reduced-over-pivots/?answer=37977#post-id-37977A little digging in the code shows that M.hermite_form calls M._echelon_form_PID which is a very generic routine. It also documents that further reduction of non-pivot entries in pivot colums is done when ideals of the base ring have a small_residue method.
See https://trac.sagemath.org/ticket/23260
It should be a nice beginner ticket.Fri, 16 Jun 2017 22:01:07 +0200https://ask.sagemath.org/question/37964/hermite-form-entries-reduced-over-pivots/?answer=37977#post-id-37977Comment by kcrisman for <p>A little digging in the code shows that M.hermite_form calls M._echelon_form_PID which is a very generic routine. It also documents that further reduction of non-pivot entries in pivot colums is done when ideals of the base ring have a small_residue method.</p>
<p>See <a href="https://trac.sagemath.org/ticket/23260">https://trac.sagemath.org/ticket/23260</a></p>
<p>It should be a nice beginner ticket.</p>
https://ask.sagemath.org/question/37964/hermite-form-entries-reduced-over-pivots/?comment=37981#post-id-37981Thanks for doing that digging - I saw the pid call but didn't have time to look further!Sat, 17 Jun 2017 04:30:01 +0200https://ask.sagemath.org/question/37964/hermite-form-entries-reduced-over-pivots/?comment=37981#post-id-37981