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, 27 Apr 2020 20:23:14 +0200How to get the graded part of a graded ring?https://ask.sagemath.org/question/47623/how-to-get-the-graded-part-of-a-graded-ring/I have a graded quotient of a graded polynomial ring, say something like
P = PolynomialRing(QQ, , 'x,y,z', order=TermOrder('wdegrevlex',(1,2,3)))
I = P.ideal(x*y^2 + x^5, z*y + x^3*y)
Q = P.quotient(I)
I would like to get the vector space over QQ consisting on vectors of degree, say 9, in Q.
Tue, 27 Aug 2019 15:34:06 +0200https://ask.sagemath.org/question/47623/how-to-get-the-graded-part-of-a-graded-ring/Answer by John Palmieri for <p>I have a graded quotient of a graded polynomial ring, say something like</p>
<pre><code>P = PolynomialRing(QQ, , 'x,y,z', order=TermOrder('wdegrevlex',(1,2,3)))
I = P.ideal(x*y^2 + x^5, z*y + x^3*y)
Q = P.quotient(I)
</code></pre>
<p>I would like to get the vector space over QQ consisting on vectors of degree, say 9, in Q. </p>
https://ask.sagemath.org/question/47623/how-to-get-the-graded-part-of-a-graded-ring/?answer=47626#post-id-47626This is not perfect, but it works: use `GradedCommutativeAlgebra`. This isn't perfect because such objects are graded commutative, not commutative, so if `x` and `z` are in odd degrees, then `xz = -zx`. You can deal with this by doubling all degrees to make sure nothing is in an odd degree.
P = GradedCommutativeAlgebra(QQ, names=('x', 'y', 'z'), degrees=(2, 4, 6))
P.inject_variables()
or
P.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=(2, 4, 6))
Then
I = P.ideal(x*y^2 + x^5, z*y + x^3*y)
Q = P.quotient(I)
Q.basis(18)
will return
[z^3, x*y*z^2, x^3*z^2, x^2*y^2*z]Tue, 27 Aug 2019 19:25:33 +0200https://ask.sagemath.org/question/47623/how-to-get-the-graded-part-of-a-graded-ring/?answer=47626#post-id-47626Comment by heluani for <p>This is not perfect, but it works: use <code>GradedCommutativeAlgebra</code>. This isn't perfect because such objects are graded commutative, not commutative, so if <code>x</code> and <code>z</code> are in odd degrees, then <code>xz = -zx</code>. You can deal with this by doubling all degrees to make sure nothing is in an odd degree.</p>
<pre><code>P = GradedCommutativeAlgebra(QQ, names=('x', 'y', 'z'), degrees=(2, 4, 6))
P.inject_variables()
</code></pre>
<p>or</p>
<pre><code>P.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=(2, 4, 6))
</code></pre>
<p>Then</p>
<pre><code>I = P.ideal(x*y^2 + x^5, z*y + x^3*y)
Q = P.quotient(I)
Q.basis(18)
</code></pre>
<p>will return</p>
<pre><code>[z^3, x*y*z^2, x^3*z^2, x^2*y^2*z]
</code></pre>
https://ask.sagemath.org/question/47623/how-to-get-the-graded-part-of-a-graded-ring/?comment=47650#post-id-47650Thanks for the reply, I had seen another question with this answer. What I ended up doing is implementing the same basis(n) method from the source code of GradedCommutativeAlgebra in my quotient ring because I couldn't change the degrees.Wed, 28 Aug 2019 18:07:56 +0200https://ask.sagemath.org/question/47623/how-to-get-the-graded-part-of-a-graded-ring/?comment=47650#post-id-47650Answer by mwageringel for <p>I have a graded quotient of a graded polynomial ring, say something like</p>
<pre><code>P = PolynomialRing(QQ, , 'x,y,z', order=TermOrder('wdegrevlex',(1,2,3)))
I = P.ideal(x*y^2 + x^5, z*y + x^3*y)
Q = P.quotient(I)
</code></pre>
<p>I would like to get the vector space over QQ consisting on vectors of degree, say 9, in Q. </p>
https://ask.sagemath.org/question/47623/how-to-get-the-graded-part-of-a-graded-ring/?answer=51077#post-id-51077Here is a more direct way to compute this.
sage: P.<x,y,z> = PolynomialRing(QQ, order=TermOrder('wdegrevlex', (1, 2, 3)))
sage: I = P.ideal(x*y^2 + x^5, z*y + x^3*y)
sage: M9 = [P.monomial(*e) for e in WeightedIntegerVectors(9, (1, 2, 3))]
sage: [m for m in M9 if m.reduce(I) == m]
[z^3, x*y*z^2, x^3*z^2, x^2*y^2*z]
**Edit:** As of Sage 9.1, it is best to use:
sage: I.normal_basis(9)
[x^2*y^2*z, x^3*z^2, x*y*z^2, z^3]Mon, 27 Apr 2020 20:23:14 +0200https://ask.sagemath.org/question/47623/how-to-get-the-graded-part-of-a-graded-ring/?answer=51077#post-id-51077