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.Mon, 31 Dec 2018 00:06:22 +0100On function quo_remhttps://ask.sagemath.org/question/44804/on-function-quo_rem/ Hi, I write the following code:
R.<x,y,z> = PolynomialRing(GF(29), order='degrevlex');
f = x*y + z;
g = x + y;
f.quo_rem(g)
and the result is
(x, -x^2 + z).
Is it a really correct result of the function quo_rem?
Because of the 'degrevlex' (`x > y > z` and `y^2 < x*y < x^2`), I expect something like this
(y, -y^2 + z).
Thank you very much in advance for your help.
Sat, 29 Dec 2018 15:53:54 +0100https://ask.sagemath.org/question/44804/on-function-quo_rem/Answer by rburing for <p>Hi, I write the following code:</p>
<pre><code>R.<x,y,z> = PolynomialRing(GF(29), order='degrevlex');
f = x*y + z;
g = x + y;
f.quo_rem(g)
</code></pre>
<p>and the result is</p>
<pre><code>(x, -x^2 + z).
</code></pre>
<p>Is it a really correct result of the function quo_rem?
Because of the 'degrevlex' (<code>x > y > z</code> and <code>y^2 < x*y < x^2</code>), I expect something like this</p>
<pre><code>(y, -y^2 + z).
</code></pre>
<p>Thank you very much in advance for your help.</p>
https://ask.sagemath.org/question/44804/on-function-quo_rem/?answer=44809#post-id-44809For multivariate division with remainder that takes the monomial ordering into account, you want to do
sage: f.reduce([g])
-y^2 + z
and you can obtain the quotient by
sage: (f - f.reduce([g])) // g
y
See the [documentation of reduce()](http://doc.sagemath.org/html/en/reference/polynomial_rings/sage/rings/polynomial/multi_polynomial_libsingular.html#sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular.reduce).
Edit: Actually this is inefficient because both can be computed simultaneously. The algorithm is simple. I don't know if it is included in Sage.
Also, the documentation of `quo_rem()` should refer to `reduce()`.Sun, 30 Dec 2018 12:48:55 +0100https://ask.sagemath.org/question/44804/on-function-quo_rem/?answer=44809#post-id-44809Comment by GK for <p>For multivariate division with remainder that takes the monomial ordering into account, you want to do</p>
<pre><code>sage: f.reduce([g])
-y^2 + z
</code></pre>
<p>and you can obtain the quotient by</p>
<pre><code>sage: (f - f.reduce([g])) // g
y
</code></pre>
<p>See the <a href="http://doc.sagemath.org/html/en/reference/polynomial_rings/sage/rings/polynomial/multi_polynomial_libsingular.html#sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular.reduce">documentation of reduce()</a>.</p>
<p>Edit: Actually this is inefficient because both can be computed simultaneously. The algorithm is simple. I don't know if it is included in Sage.</p>
<p>Also, the documentation of <code>quo_rem()</code> should refer to <code>reduce()</code>.</p>
https://ask.sagemath.org/question/44804/on-function-quo_rem/?comment=44819#post-id-44819Thank you a lot!!!Mon, 31 Dec 2018 00:06:22 +0100https://ask.sagemath.org/question/44804/on-function-quo_rem/?comment=44819#post-id-44819