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, 03 Oct 2023 01:52:56 +0200Working with finitely presented algebrashttps://ask.sagemath.org/question/73668/working-with-finitely-presented-algebras/I am trying to work with finitely presented algebras in SageMath. But apparently, I am doing something wrong.
For a simple example, I want to construct `A = Q[x]/<x^2>`. The image `a` of `x` in that algebra should satisfy `a^2 = 0`. But SageMath tells me that this is not the case. (EDIT: the code has been updated below.)
sage: F.<x> = FreeAlgebra(QQ,1)
sage: F
Free Algebra on 1 generators (x,) over Rational Field
sage: x in F
True
sage: I = F.ideal([x^2])
sage: A = F.quotient(I)
sage: A
Quotient of Free Algebra on 1 generators (x,) over Rational Field by the ideal (x^2)
sage: a = A.gen()
sage: a^2 == 0
False
sage: a^2 == A.zero()
False
What am I doing wrong here?
When the ideal is `<1>`, the quotient should be trivial. But again, SageMath does not believe this.
It seems that this bug has been reported here before:
- https://ask.sagemath.org/question/41219/calculations-in-quotient-of-a-free-algebra/
- https://ask.sagemath.org/question/32178/confused-about-freealgebra-quotients/Sat, 30 Sep 2023 11:04:54 +0200https://ask.sagemath.org/question/73668/working-with-finitely-presented-algebras/Comment by Martin-Br for <p>I am trying to work with finitely presented algebras in SageMath. But apparently, I am doing something wrong.</p>
<p>For a simple example, I want to construct <code>A = Q[x]/<x^2></code>. The image <code>a</code> of <code>x</code> in that algebra should satisfy <code>a^2 = 0</code>. But SageMath tells me that this is not the case. (EDIT: the code has been updated below.)</p>
<pre><code>sage: F.<x> = FreeAlgebra(QQ,1)
sage: F
Free Algebra on 1 generators (x,) over Rational Field
sage: x in F
True
sage: I = F.ideal([x^2])
sage: A = F.quotient(I)
sage: A
Quotient of Free Algebra on 1 generators (x,) over Rational Field by the ideal (x^2)
sage: a = A.gen()
sage: a^2 == 0
False
sage: a^2 == A.zero()
False
</code></pre>
<p>What am I doing wrong here?</p>
<p>When the ideal is <code><1></code>, the quotient should be trivial. But again, SageMath does not believe this.</p>
<p>It seems that this bug has been reported here before:</p>
<ul>
<li><a href="https://ask.sagemath.org/question/41219/calculations-in-quotient-of-a-free-algebra/">https://ask.sagemath.org/question/412...</a></li>
<li><a href="https://ask.sagemath.org/question/32178/confused-about-freealgebra-quotients/">https://ask.sagemath.org/question/321...</a></li>
</ul>
https://ask.sagemath.org/question/73668/working-with-finitely-presented-algebras/?comment=73692#post-id-73692Apparently, it works when F is defined as a polynomial ring. The free algebra on one generator should equal the polynomial ring. But SageMath thinks differently.Mon, 02 Oct 2023 14:00:55 +0200https://ask.sagemath.org/question/73668/working-with-finitely-presented-algebras/?comment=73692#post-id-73692Answer by John Palmieri for <p>I am trying to work with finitely presented algebras in SageMath. But apparently, I am doing something wrong.</p>
<p>For a simple example, I want to construct <code>A = Q[x]/<x^2></code>. The image <code>a</code> of <code>x</code> in that algebra should satisfy <code>a^2 = 0</code>. But SageMath tells me that this is not the case. (EDIT: the code has been updated below.)</p>
<pre><code>sage: F.<x> = FreeAlgebra(QQ,1)
sage: F
Free Algebra on 1 generators (x,) over Rational Field
sage: x in F
True
sage: I = F.ideal([x^2])
sage: A = F.quotient(I)
sage: A
Quotient of Free Algebra on 1 generators (x,) over Rational Field by the ideal (x^2)
sage: a = A.gen()
sage: a^2 == 0
False
sage: a^2 == A.zero()
False
</code></pre>
<p>What am I doing wrong here?</p>
<p>When the ideal is <code><1></code>, the quotient should be trivial. But again, SageMath does not believe this.</p>
<p>It seems that this bug has been reported here before:</p>
<ul>
<li><a href="https://ask.sagemath.org/question/41219/calculations-in-quotient-of-a-free-algebra/">https://ask.sagemath.org/question/412...</a></li>
<li><a href="https://ask.sagemath.org/question/32178/confused-about-freealgebra-quotients/">https://ask.sagemath.org/question/321...</a></li>
</ul>
https://ask.sagemath.org/question/73668/working-with-finitely-presented-algebras/?answer=73669#post-id-73669First you're doing something mysterious, because the code you wrote doesn't work.
sage: F = FreeAlgebra(QQ,1,'x')
sage: x in F
True ???
The first line does not define `x` as an element of `F`, so the second line will return `False`. Furthermore, if I do `x = F.gen(0)` to define `x` appropriately, then `F.quotient(I)` raises an error, saying that "a twosided ideal is required". Maybe for this second issue you're using an old version of Sage and the behavior has changed since then.
Your actual question is sound, though, so let's address that. Here is what I would do:
sage: F.<x> = FreeAlgebra(QQ, implementation='letterplace')
sage: x in F
True
sage: I = F.ideal([x^2], side='twosided')
sage: A = F.quotient(I)
sage: a = A.gen()
sage: a^2
0
sage: a^2 == 0
True
The key is to use the "letterplace" implementation for free algebras (https://doc.sagemath.org/html/en/reference/algebras/sage/algebras/letterplace/free_algebra_letterplace.html). Those seem to work better when handling ideals and quotients, at least in my experience.Sat, 30 Sep 2023 19:14:00 +0200https://ask.sagemath.org/question/73668/working-with-finitely-presented-algebras/?answer=73669#post-id-73669Comment by Martin-Br for <p>First you're doing something mysterious, because the code you wrote doesn't work.</p>
<pre><code>sage: F = FreeAlgebra(QQ,1,'x')
sage: x in F
True ???
</code></pre>
<p>The first line does not define <code>x</code> as an element of <code>F</code>, so the second line will return <code>False</code>. Furthermore, if I do <code>x = F.gen(0)</code> to define <code>x</code> appropriately, then <code>F.quotient(I)</code> raises an error, saying that "a twosided ideal is required". Maybe for this second issue you're using an old version of Sage and the behavior has changed since then.</p>
<p>Your actual question is sound, though, so let's address that. Here is what I would do:</p>
<pre><code>sage: F.<x> = FreeAlgebra(QQ, implementation='letterplace')
sage: x in F
True
sage: I = F.ideal([x^2], side='twosided')
sage: A = F.quotient(I)
sage: a = A.gen()
sage: a^2
0
sage: a^2 == 0
True
</code></pre>
<p>The key is to use the "letterplace" implementation for free algebras (<a href="https://doc.sagemath.org/html/en/reference/algebras/sage/algebras/letterplace/free_algebra_letterplace.html">https://doc.sagemath.org/html/en/refe...</a>). Those seem to work better when handling ideals and quotients, at least in my experience.</p>
https://ask.sagemath.org/question/73668/working-with-finitely-presented-algebras/?comment=73710#post-id-73710Thanks! I will try to work with the homogenization then.Tue, 03 Oct 2023 01:52:56 +0200https://ask.sagemath.org/question/73668/working-with-finitely-presented-algebras/?comment=73710#post-id-73710Comment by John Palmieri for <p>First you're doing something mysterious, because the code you wrote doesn't work.</p>
<pre><code>sage: F = FreeAlgebra(QQ,1,'x')
sage: x in F
True ???
</code></pre>
<p>The first line does not define <code>x</code> as an element of <code>F</code>, so the second line will return <code>False</code>. Furthermore, if I do <code>x = F.gen(0)</code> to define <code>x</code> appropriately, then <code>F.quotient(I)</code> raises an error, saying that "a twosided ideal is required". Maybe for this second issue you're using an old version of Sage and the behavior has changed since then.</p>
<p>Your actual question is sound, though, so let's address that. Here is what I would do:</p>
<pre><code>sage: F.<x> = FreeAlgebra(QQ, implementation='letterplace')
sage: x in F
True
sage: I = F.ideal([x^2], side='twosided')
sage: A = F.quotient(I)
sage: a = A.gen()
sage: a^2
0
sage: a^2 == 0
True
</code></pre>
<p>The key is to use the "letterplace" implementation for free algebras (<a href="https://doc.sagemath.org/html/en/reference/algebras/sage/algebras/letterplace/free_algebra_letterplace.html">https://doc.sagemath.org/html/en/refe...</a>). Those seem to work better when handling ideals and quotients, at least in my experience.</p>
https://ask.sagemath.org/question/73668/working-with-finitely-presented-algebras/?comment=73700#post-id-73700Regarding `side='twosided'`: I get an error if I do `F.<x> = FreeAlgebra(QQ); I = F.quotient([x^2+1]); F.quotient(I)`. I don't get the error if `F` has more than one generator, so singly generated algebras are handled differently apparently, than with multiple generators.Mon, 02 Oct 2023 19:47:59 +0200https://ask.sagemath.org/question/73668/working-with-finitely-presented-algebras/?comment=73700#post-id-73700Comment by John Palmieri for <p>First you're doing something mysterious, because the code you wrote doesn't work.</p>
<pre><code>sage: F = FreeAlgebra(QQ,1,'x')
sage: x in F
True ???
</code></pre>
<p>The first line does not define <code>x</code> as an element of <code>F</code>, so the second line will return <code>False</code>. Furthermore, if I do <code>x = F.gen(0)</code> to define <code>x</code> appropriately, then <code>F.quotient(I)</code> raises an error, saying that "a twosided ideal is required". Maybe for this second issue you're using an old version of Sage and the behavior has changed since then.</p>
<p>Your actual question is sound, though, so let's address that. Here is what I would do:</p>
<pre><code>sage: F.<x> = FreeAlgebra(QQ, implementation='letterplace')
sage: x in F
True
sage: I = F.ideal([x^2], side='twosided')
sage: A = F.quotient(I)
sage: a = A.gen()
sage: a^2
0
sage: a^2 == 0
True
</code></pre>
<p>The key is to use the "letterplace" implementation for free algebras (<a href="https://doc.sagemath.org/html/en/reference/algebras/sage/algebras/letterplace/free_algebra_letterplace.html">https://doc.sagemath.org/html/en/refe...</a>). Those seem to work better when handling ideals and quotients, at least in my experience.</p>
https://ask.sagemath.org/question/73668/working-with-finitely-presented-algebras/?comment=73699#post-id-73699As you note in the edited question, this has been reported, and the ticket with the bug (https://github.com/sagemath/sage/issues/24808) is still open. You may be able to work around the nonhomogeneous elements by homogenizing (?) everything: introduce a new variable `t` and just multiply each summand by the appropriate power of `t` to make everything the same degree: replace `x^2+1` by `x^2+t^2`. Not perfect, but that may be the best workaround.Mon, 02 Oct 2023 19:44:57 +0200https://ask.sagemath.org/question/73668/working-with-finitely-presented-algebras/?comment=73699#post-id-73699Comment by Martin-Br for <p>First you're doing something mysterious, because the code you wrote doesn't work.</p>
<pre><code>sage: F = FreeAlgebra(QQ,1,'x')
sage: x in F
True ???
</code></pre>
<p>The first line does not define <code>x</code> as an element of <code>F</code>, so the second line will return <code>False</code>. Furthermore, if I do <code>x = F.gen(0)</code> to define <code>x</code> appropriately, then <code>F.quotient(I)</code> raises an error, saying that "a twosided ideal is required". Maybe for this second issue you're using an old version of Sage and the behavior has changed since then.</p>
<p>Your actual question is sound, though, so let's address that. Here is what I would do:</p>
<pre><code>sage: F.<x> = FreeAlgebra(QQ, implementation='letterplace')
sage: x in F
True
sage: I = F.ideal([x^2], side='twosided')
sage: A = F.quotient(I)
sage: a = A.gen()
sage: a^2
0
sage: a^2 == 0
True
</code></pre>
<p>The key is to use the "letterplace" implementation for free algebras (<a href="https://doc.sagemath.org/html/en/reference/algebras/sage/algebras/letterplace/free_algebra_letterplace.html">https://doc.sagemath.org/html/en/refe...</a>). Those seem to work better when handling ideals and quotients, at least in my experience.</p>
https://ask.sagemath.org/question/73668/working-with-finitely-presented-algebras/?comment=73690#post-id-73690`sage: F.<x> = FreeAlgebra(QQ,implementation="letterplace")`
`sage: F.quotient(Ideal(F,[x+1]))`
throws this error:
`ArithmeticError: Can only add elements of the same weighted degree`Mon, 02 Oct 2023 10:13:58 +0200https://ask.sagemath.org/question/73668/working-with-finitely-presented-algebras/?comment=73690#post-id-73690Comment by Martin-Br for <p>First you're doing something mysterious, because the code you wrote doesn't work.</p>
<pre><code>sage: F = FreeAlgebra(QQ,1,'x')
sage: x in F
True ???
</code></pre>
<p>The first line does not define <code>x</code> as an element of <code>F</code>, so the second line will return <code>False</code>. Furthermore, if I do <code>x = F.gen(0)</code> to define <code>x</code> appropriately, then <code>F.quotient(I)</code> raises an error, saying that "a twosided ideal is required". Maybe for this second issue you're using an old version of Sage and the behavior has changed since then.</p>
<p>Your actual question is sound, though, so let's address that. Here is what I would do:</p>
<pre><code>sage: F.<x> = FreeAlgebra(QQ, implementation='letterplace')
sage: x in F
True
sage: I = F.ideal([x^2], side='twosided')
sage: A = F.quotient(I)
sage: a = A.gen()
sage: a^2
0
sage: a^2 == 0
True
</code></pre>
<p>The key is to use the "letterplace" implementation for free algebras (<a href="https://doc.sagemath.org/html/en/reference/algebras/sage/algebras/letterplace/free_algebra_letterplace.html">https://doc.sagemath.org/html/en/refe...</a>). Those seem to work better when handling ideals and quotients, at least in my experience.</p>
https://ask.sagemath.org/question/73668/working-with-finitely-presented-algebras/?comment=73689#post-id-73689Thanks a lot for your answer.
Actually, I encountered the same problem with `F.<x>`, but apparently I wrote it wrong above.
Is side="twosided" required? I assumed that SageMath has ideals twosided by default. But I am not sure.
I tried with `implementation="letterplace"`, and it indeed works. But the problem is that the ideal that I need for my actual problem (this here was just a toy example) is not homogeneous. And when I want to quotient out non-homogeneous ideals with implementation="letterplace", I get an error. This seems to be confirmed by the SageMath documentation.
Having said this, I have a really hard time to read and understand the documentation.
Have you any idea how to work with quotients of non-homogenous ideals?
PS: On my Ubuntu server I have installed SageMath version 9.5.Mon, 02 Oct 2023 10:11:26 +0200https://ask.sagemath.org/question/73668/working-with-finitely-presented-algebras/?comment=73689#post-id-73689