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.Tue, 20 Apr 2021 10:48:53 +0200Quotient of polynomial ring over integers not workinghttps://ask.sagemath.org/question/56734/quotient-of-polynomial-ring-over-integers-not-working/I have a problem. I want Sage to calculate in $\mathbb Z[x]/\langle4,2x,x^2\rangle$ but none of the relations are being calculated/recognized properly:
sage: R.<x> = ZZ[]
sage: I = R.ideal(4,2*x,x^2)
sage: S.<a> = R.quotient(I)
sage: a^2 # the output should be 0
a^2
sage: 2*a # the output should be 0
2*a
sage: S(2)+S(2) # the output should be 0
4
When I introduce a superfluous variable $y$ and consider $\mathbb Z[x,y]/\langle4,2x,x^2,y\rangle$ instead, which is practically the same ring (i.e. isomorphic), then it seems to work:
sage: R.<x,y> = ZZ[]
sage: I = R.ideal(4,2*x,x^2,y)
sage: S.<a,b> = R.quotient(I)
sage: a^2
0
sage: 2*a
0
sage: S(2)+S(2)
0
But now look at this:
sage: S(2)+S(3) # the output should be 1
5
How can I solve this problem?Mon, 19 Apr 2021 22:33:39 +0200https://ask.sagemath.org/question/56734/quotient-of-polynomial-ring-over-integers-not-working/Answer by tmonteil for <p>I have a problem. I want Sage to calculate in $\mathbb Z[x]/\langle4,2x,x^2\rangle$ but none of the relations are being calculated/recognized properly:</p>
<pre><code>sage: R.<x> = ZZ[]
sage: I = R.ideal(4,2*x,x^2)
sage: S.<a> = R.quotient(I)
sage: a^2 # the output should be 0
a^2
sage: 2*a # the output should be 0
2*a
sage: S(2)+S(2) # the output should be 0
4
</code></pre>
<p>When I introduce a superfluous variable $y$ and consider $\mathbb Z[x,y]/\langle4,2x,x^2,y\rangle$ instead, which is practically the same ring (i.e. isomorphic), then it seems to work:</p>
<pre><code>sage: R.<x,y> = ZZ[]
sage: I = R.ideal(4,2*x,x^2,y)
sage: S.<a,b> = R.quotient(I)
sage: a^2
0
sage: 2*a
0
sage: S(2)+S(2)
0
</code></pre>
<p>But now look at this:</p>
<pre><code>sage: S(2)+S(3) # the output should be 1
5
</code></pre>
<p>How can I solve this problem?</p>
https://ask.sagemath.org/question/56734/quotient-of-polynomial-ring-over-integers-not-working/?answer=56735#post-id-56735For the first issue, you can replace
sage: R.<x> = ZZ[]
with
sage: R.<x> = PolynomialRing(ZZ,1)
It looks stupid, but the univariate polynomial ring is not the same as the multivariate polynomial ring in one variable, the first one is implemented in Sage and the second relies on `Singular`, also they do not have the same methods available.
Reegarding the creation of ideals, in the first case, it seems that the method is inherited from a generic parent class, while the second has its own ideal method:
sage: R.<x> = ZZ[]
sage: R.ideal
<built-in method ideal of PolynomialRing_integral_domain_with_category object at 0x7f40f95402c8>
sage: R.<x> = PolynomialRing(ZZ,1)
sage: R.ideal
<built-in method ideal of sage.rings.polynomial.multi_polynomial_libsingular.MPolynomialRing_libsingular object at 0x7f40f4ecc4f8>
With this second implementation, you can check:
sage: R.<x> = PolynomialRing(ZZ,1)
sage: I = R.ideal(4,2*x,x^2)
sage: S.<a> = R.quotient(I)
sage: a^2
0
sage: 2*a
0
sage: S(2) + S(2)
0
So far, so good. Now, regarding your second issue, there is no problem that
sage: S(2) + S(3)
5
as this is correct. However, there seems to be a problem with the following:
sage: S(2) + S(3) == S(1)
False
Note that, however :
sage: S(2) + S(3) - S(1)
0
Perhaps should we investigate a bit further on where the problem is exactly and then report this as a bug. Meanwhile, i will add a `confirmed_bug` tag.
In any case, thanks for reporting !Mon, 19 Apr 2021 23:01:02 +0200https://ask.sagemath.org/question/56734/quotient-of-polynomial-ring-over-integers-not-working/?answer=56735#post-id-56735Comment by Thrash for <p>For the first issue, you can replace</p>
<pre><code>sage: R.<x> = ZZ[]
</code></pre>
<p>with</p>
<pre><code>sage: R.<x> = PolynomialRing(ZZ,1)
</code></pre>
<p>It looks stupid, but the univariate polynomial ring is not the same as the multivariate polynomial ring in one variable, the first one is implemented in Sage and the second relies on <code>Singular</code>, also they do not have the same methods available.</p>
<p>Reegarding the creation of ideals, in the first case, it seems that the method is inherited from a generic parent class, while the second has its own ideal method:</p>
<pre><code>sage: R.<x> = ZZ[]
sage: R.ideal
<built-in method ideal of PolynomialRing_integral_domain_with_category object at 0x7f40f95402c8>
sage: R.<x> = PolynomialRing(ZZ,1)
sage: R.ideal
<built-in method ideal of sage.rings.polynomial.multi_polynomial_libsingular.MPolynomialRing_libsingular object at 0x7f40f4ecc4f8>
</code></pre>
<p>With this second implementation, you can check:</p>
<pre><code>sage: R.<x> = PolynomialRing(ZZ,1)
sage: I = R.ideal(4,2*x,x^2)
sage: S.<a> = R.quotient(I)
sage: a^2
0
sage: 2*a
0
sage: S(2) + S(2)
0
</code></pre>
<p>So far, so good. Now, regarding your second issue, there is no problem that</p>
<pre><code>sage: S(2) + S(3)
5
</code></pre>
<p>as this is correct. However, there seems to be a problem with the following:</p>
<pre><code>sage: S(2) + S(3) == S(1)
False
</code></pre>
<p>Note that, however :</p>
<pre><code>sage: S(2) + S(3) - S(1)
0
</code></pre>
<p>Perhaps should we investigate a bit further on where the problem is exactly and then report this as a bug. Meanwhile, i will add a <code>confirmed_bug</code> tag.</p>
<p>In any case, thanks for reporting !</p>
https://ask.sagemath.org/question/56734/quotient-of-polynomial-ring-over-integers-not-working/?comment=56741#post-id-56741Thank you very much! This means that the first method implemented in Sage should be improved. Of course, `S(2)+S(3)` resulting in `5` is correct like `a^2` resulting in `a^2` (with the first method), but it's not elegant, or more precisely. impractical for further calculations. I would like to do something like `(1+a).is_unit()` for example, but I get the error "Lifting of multivariate polynomials over non-fields is not implemented."Tue, 20 Apr 2021 10:48:53 +0200https://ask.sagemath.org/question/56734/quotient-of-polynomial-ring-over-integers-not-working/?comment=56741#post-id-56741