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.Fri, 10 Dec 2021 18:23:48 +0100How to define tensor product of algebras (and make it an algebra)https://ask.sagemath.org/question/60133/how-to-define-tensor-product-of-algebras-and-make-it-an-algebra/I'm in my first week of Sage (also new to Python). Aiming at symbolic calculations, suppose I have an associative algebra $A$ (think of the Clifford algebra, or the free algebra, for concreteness).
In particular $A$ is a vector space, and I'd like to define a tensor product $A\otimes A$. I've seen that tensor algebra is implemented in SageMath, but I only need two factors, and anyway, I'd like to make $A\otimes A$ an algebra in a way that is *not* endowed with the obvious product $(a\otimes b) \cdot (c\otimes d) = ac\otimes bd$.
(Ideally, the final algebra will depend on a state on $A$, but for simplicity think of my product being, say, $(a\otimes b) \cdot (c\otimes d) = ac\otimes db$.)
An example of how to do what I wish (although not precisely the same object), is along the lines of
[Mathematica Stack Exchange answer 165511](https://mathematica.stackexchange.com/a/165511):
CenterDot[X___, Y_Plus, Z___] := CenterDot[X, #, Z] & /@ Y (* additivity *)
CenterDot[] = 1;
CenterDot[X_] := X
CenterDot[X___, 1, Y___] := CenterDot[X, Y] (* unital*)
SetAttributes[CenterDot, Flat] (* associativity *)
This allows to create a product `CenterDot` that behaves as it should. But in SageMath I need to define the analogue of this on $A\otimes A$ and this is not even clear to me how to define this product. (I.e. if it's not implemented, I probably should do something analogous to the code above, first for $\otimes$, tell it that it has to be bilinear, etc.)Tue, 07 Dec 2021 11:42:27 +0100https://ask.sagemath.org/question/60133/how-to-define-tensor-product-of-algebras-and-make-it-an-algebra/Comment by slelievre for <p>I'm in my first week of Sage (also new to Python). Aiming at symbolic calculations, suppose I have an associative algebra $A$ (think of the Clifford algebra, or the free algebra, for concreteness). </p>
<p>In particular $A$ is a vector space, and I'd like to define a tensor product $A\otimes A$. I've seen that tensor algebra is implemented in SageMath, but I only need two factors, and anyway, I'd like to make $A\otimes A$ an algebra in a way that is <em>not</em> endowed with the obvious product $(a\otimes b) \cdot (c\otimes d) = ac\otimes bd$.
(Ideally, the final algebra will depend on a state on $A$, but for simplicity think of my product being, say, $(a\otimes b) \cdot (c\otimes d) = ac\otimes db$.)</p>
<p>An example of how to do what I wish (although not precisely the same object), is along the lines of
<a href="https://mathematica.stackexchange.com/a/165511">Mathematica Stack Exchange answer 165511</a>: </p>
<pre><code>CenterDot[X___, Y_Plus, Z___] := CenterDot[X, #, Z] & /@ Y (* additivity *)
CenterDot[] = 1;
CenterDot[X_] := X
CenterDot[X___, 1, Y___] := CenterDot[X, Y] (* unital*)
SetAttributes[CenterDot, Flat] (* associativity *)
</code></pre>
<p>This allows to create a product <code>CenterDot</code> that behaves as it should. But in SageMath I need to define the analogue of this on $A\otimes A$ and this is not even clear to me how to define this product. (I.e. if it's not implemented, I probably should do something analogous to the code above, first for $\otimes$, tell it that it has to be bilinear, etc.)</p>
https://ask.sagemath.org/question/60133/how-to-define-tensor-product-of-algebras-and-make-it-an-algebra/?comment=60136#post-id-60136Welcome to Ask Sage! Thank you for your question.Tue, 07 Dec 2021 15:42:58 +0100https://ask.sagemath.org/question/60133/how-to-define-tensor-product-of-algebras-and-make-it-an-algebra/?comment=60136#post-id-60136Answer by FrédéricC for <p>I'm in my first week of Sage (also new to Python). Aiming at symbolic calculations, suppose I have an associative algebra $A$ (think of the Clifford algebra, or the free algebra, for concreteness). </p>
<p>In particular $A$ is a vector space, and I'd like to define a tensor product $A\otimes A$. I've seen that tensor algebra is implemented in SageMath, but I only need two factors, and anyway, I'd like to make $A\otimes A$ an algebra in a way that is <em>not</em> endowed with the obvious product $(a\otimes b) \cdot (c\otimes d) = ac\otimes bd$.
(Ideally, the final algebra will depend on a state on $A$, but for simplicity think of my product being, say, $(a\otimes b) \cdot (c\otimes d) = ac\otimes db$.)</p>
<p>An example of how to do what I wish (although not precisely the same object), is along the lines of
<a href="https://mathematica.stackexchange.com/a/165511">Mathematica Stack Exchange answer 165511</a>: </p>
<pre><code>CenterDot[X___, Y_Plus, Z___] := CenterDot[X, #, Z] & /@ Y (* additivity *)
CenterDot[] = 1;
CenterDot[X_] := X
CenterDot[X___, 1, Y___] := CenterDot[X, Y] (* unital*)
SetAttributes[CenterDot, Flat] (* associativity *)
</code></pre>
<p>This allows to create a product <code>CenterDot</code> that behaves as it should. But in SageMath I need to define the analogue of this on $A\otimes A$ and this is not even clear to me how to define this product. (I.e. if it's not implemented, I probably should do something analogous to the code above, first for $\otimes$, tell it that it has to be bilinear, etc.)</p>
https://ask.sagemath.org/question/60133/how-to-define-tensor-product-of-algebras-and-make-it-an-algebra/?answer=60143#post-id-60143Like this maybe ?
sage: Q = QuadraticForm(ZZ, 3, [1,2,3,4,5,6])
sage: Cl = CliffordAlgebra(Q)
sage: D = Cl.tensor_square()
sage: D in Algebras(ZZ)
True
sage: D.one()**2
1 # 1
EDIT: I missed the point that you wanted some other product. You may look at the doc of tensor_square.Tue, 07 Dec 2021 18:39:35 +0100https://ask.sagemath.org/question/60133/how-to-define-tensor-product-of-algebras-and-make-it-an-algebra/?answer=60143#post-id-60143Comment by slelievre for <p>Like this maybe ?</p>
<pre><code>sage: Q = QuadraticForm(ZZ, 3, [1,2,3,4,5,6])
sage: Cl = CliffordAlgebra(Q)
sage: D = Cl.tensor_square()
sage: D in Algebras(ZZ)
True
sage: D.one()**2
1 # 1
</code></pre>
<p>EDIT: I missed the point that you wanted some other product. You may look at the doc of tensor_square.</p>
https://ask.sagemath.org/question/60133/how-to-define-tensor-product-of-algebras-and-make-it-an-algebra/?comment=60199#post-id-60199That is right. Either of the following works:
sage: tensor((a, b))
a # b
sage: a.tensor(b)
a # bFri, 10 Dec 2021 18:23:48 +0100https://ask.sagemath.org/question/60133/how-to-define-tensor-product-of-algebras-and-make-it-an-algebra/?comment=60199#post-id-60199Comment by c.p. for <p>Like this maybe ?</p>
<pre><code>sage: Q = QuadraticForm(ZZ, 3, [1,2,3,4,5,6])
sage: Cl = CliffordAlgebra(Q)
sage: D = Cl.tensor_square()
sage: D in Algebras(ZZ)
True
sage: D.one()**2
1 # 1
</code></pre>
<p>EDIT: I missed the point that you wanted some other product. You may look at the doc of tensor_square.</p>
https://ask.sagemath.org/question/60133/how-to-define-tensor-product-of-algebras-and-make-it-an-algebra/?comment=60180#post-id-60180I see, thanks. so if `Cl.<a,b,c> = CliffordAlgebra(Q) ` then `tensor((a,b))` is $a \otimes b$...Thu, 09 Dec 2021 18:21:07 +0100https://ask.sagemath.org/question/60133/how-to-define-tensor-product-of-algebras-and-make-it-an-algebra/?comment=60180#post-id-60180Comment by slelievre for <p>Like this maybe ?</p>
<pre><code>sage: Q = QuadraticForm(ZZ, 3, [1,2,3,4,5,6])
sage: Cl = CliffordAlgebra(Q)
sage: D = Cl.tensor_square()
sage: D in Algebras(ZZ)
True
sage: D.one()**2
1 # 1
</code></pre>
<p>EDIT: I missed the point that you wanted some other product. You may look at the doc of tensor_square.</p>
https://ask.sagemath.org/question/60133/how-to-define-tensor-product-of-algebras-and-make-it-an-algebra/?comment=60179#post-id-60179To type tensor products:
sage: D.one()
1 # 1
sage: D.one().tensor(D.one())
1 # 1 # 1 # 1Thu, 09 Dec 2021 18:02:27 +0100https://ask.sagemath.org/question/60133/how-to-define-tensor-product-of-algebras-and-make-it-an-algebra/?comment=60179#post-id-60179Comment by c.p. for <p>Like this maybe ?</p>
<pre><code>sage: Q = QuadraticForm(ZZ, 3, [1,2,3,4,5,6])
sage: Cl = CliffordAlgebra(Q)
sage: D = Cl.tensor_square()
sage: D in Algebras(ZZ)
True
sage: D.one()**2
1 # 1
</code></pre>
<p>EDIT: I missed the point that you wanted some other product. You may look at the doc of tensor_square.</p>
https://ask.sagemath.org/question/60133/how-to-define-tensor-product-of-algebras-and-make-it-an-algebra/?comment=60165#post-id-60165Merci. I'll try it that way. What confuses me is that it seems that the tensor product $(a\otimes b)$ is represented by `a#b` which is recognized as a ... comment after that sign. So not sure how to type stuff.Wed, 08 Dec 2021 15:47:09 +0100https://ask.sagemath.org/question/60133/how-to-define-tensor-product-of-algebras-and-make-it-an-algebra/?comment=60165#post-id-60165