ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 09 Jun 2015 12:57:59 -0500Quotient of Polynomial rings reduction not workinghttps://ask.sagemath.org/question/27068/quotient-of-polynomial-rings-reduction-not-working/<code>
<br>R.<x>=PolynomialRing(QQ)
<br>R.ideal(x^4).reduce(x^8+1)
<br>R.<x>=PolynomialRing(ZZ)
<br>R.ideal(x^4).reduce(x^8+1)
1
x^8 + 1
</code>
Why am I not getting the result 1 in both cases?Tue, 09 Jun 2015 08:44:26 -0500https://ask.sagemath.org/question/27068/quotient-of-polynomial-rings-reduction-not-working/Answer by tmonteil for <p><code>
<br/>R.<x>=PolynomialRing(QQ)
<br/>R.ideal(x^4).reduce(x^8+1)
<br/>R.<x>=PolynomialRing(ZZ)
<br/>R.ideal(x^4).reduce(x^8+1)</code></p><code>
</code><p><code>1
x^8 + 1
</code></p>
<p>Why am I not getting the result 1 in both cases?</p>
https://ask.sagemath.org/question/27068/quotient-of-polynomial-rings-reduction-not-working/?answer=27070#post-id-27070It seems that in the second case, the `.reduce()` method is the generic one which is just:
def reduce(self, f):
r"""
Return the reduction of the element of `f` modulo ``self``.
This is an element of `R` that is equivalent modulo `I` to `f` where
`I` is ``self``.
EXAMPLES::
sage: ZZ.ideal(5).reduce(17)
2
sage: parent(ZZ.ideal(5).reduce(17))
Integer Ring
"""
return f # default
If you want a better reduction in this particular case, you can put the polynomial in the quotient and lift it:
sage: R.<x>=PolynomialRing(ZZ)
sage: I = R.ideal(x^4)
sage: R.quotient(I)(x^8+1).lift()
1
Tue, 09 Jun 2015 09:58:59 -0500https://ask.sagemath.org/question/27068/quotient-of-polynomial-rings-reduction-not-working/?answer=27070#post-id-27070Comment by Wizq for <p>It seems that in the second case, the <code>.reduce()</code> method is the generic one which is just:</p>
<pre><code>def reduce(self, f):
r"""
Return the reduction of the element of `f` modulo ``self``.
This is an element of `R` that is equivalent modulo `I` to `f` where
`I` is ``self``.
EXAMPLES::
sage: ZZ.ideal(5).reduce(17)
2
sage: parent(ZZ.ideal(5).reduce(17))
Integer Ring
"""
return f # default
</code></pre>
<p>If you want a better reduction in this particular case, you can put the polynomial in the quotient and lift it:</p>
<pre><code>sage: R.<x>=PolynomialRing(ZZ)
sage: I = R.ideal(x^4)
sage: R.quotient(I)(x^8+1).lift()
1
</code></pre>
https://ask.sagemath.org/question/27068/quotient-of-polynomial-rings-reduction-not-working/?comment=27076#post-id-27076I didn't know that, and it's going to help me tremendously. Thank you!Tue, 09 Jun 2015 12:57:59 -0500https://ask.sagemath.org/question/27068/quotient-of-polynomial-rings-reduction-not-working/?comment=27076#post-id-27076Comment by tmonteil for <p>It seems that in the second case, the <code>.reduce()</code> method is the generic one which is just:</p>
<pre><code>def reduce(self, f):
r"""
Return the reduction of the element of `f` modulo ``self``.
This is an element of `R` that is equivalent modulo `I` to `f` where
`I` is ``self``.
EXAMPLES::
sage: ZZ.ideal(5).reduce(17)
2
sage: parent(ZZ.ideal(5).reduce(17))
Integer Ring
"""
return f # default
</code></pre>
<p>If you want a better reduction in this particular case, you can put the polynomial in the quotient and lift it:</p>
<pre><code>sage: R.<x>=PolynomialRing(ZZ)
sage: I = R.ideal(x^4)
sage: R.quotient(I)(x^8+1).lift()
1
</code></pre>
https://ask.sagemath.org/question/27068/quotient-of-polynomial-rings-reduction-not-working/?comment=27072#post-id-27072Note that, you can access directly to the source code of a method with two question marks:
sage: I.reduce??Tue, 09 Jun 2015 12:13:40 -0500https://ask.sagemath.org/question/27068/quotient-of-polynomial-rings-reduction-not-working/?comment=27072#post-id-27072Comment by Wizq for <p>It seems that in the second case, the <code>.reduce()</code> method is the generic one which is just:</p>
<pre><code>def reduce(self, f):
r"""
Return the reduction of the element of `f` modulo ``self``.
This is an element of `R` that is equivalent modulo `I` to `f` where
`I` is ``self``.
EXAMPLES::
sage: ZZ.ideal(5).reduce(17)
2
sage: parent(ZZ.ideal(5).reduce(17))
Integer Ring
"""
return f # default
</code></pre>
<p>If you want a better reduction in this particular case, you can put the polynomial in the quotient and lift it:</p>
<pre><code>sage: R.<x>=PolynomialRing(ZZ)
sage: I = R.ideal(x^4)
sage: R.quotient(I)(x^8+1).lift()
1
</code></pre>
https://ask.sagemath.org/question/27068/quotient-of-polynomial-rings-reduction-not-working/?comment=27071#post-id-27071Thank you very much for your answer. I googled the commented code and found the source code, and I now understand why it wasn't working as expected. Since I'm working with a slightly more complicated ring than this (Z[x]/poly1/poly2), I am now trying to use overriding and inheritance (of PolynomialQuotientRing and QuotientRing, I hope that "_domain_with_category" isn't significant for this) to obtain the behaviour that I want (reduce, quo_rem...). Thank you.Tue, 09 Jun 2015 11:37:33 -0500https://ask.sagemath.org/question/27068/quotient-of-polynomial-rings-reduction-not-working/?comment=27071#post-id-27071