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.Wed, 13 Jan 2021 19:31:58 +0100How to compute in the Tensor Algebra $T(V)$ ?https://ask.sagemath.org/question/55256/how-to-compute-in-the-tensor-algebra-tv/I need to make some computations in low degree in the Tensor algebra $T(V)$ of a rational vector space $V$, but i cannot find a good way of doing this. I could use FreeAlgebras, but then i cannot get access to the summands in my element : for example i want to be able to retrieve $a$ $b$ and $c$ from the element $a*b*c $ (whenever the element is homogeneous).
The reason for this is I need to define a 'cycle' function that associates $Wa$ to a tensor $aW$ when $W$ is a tensor and $a \in V$.Wed, 13 Jan 2021 16:21:54 +0100https://ask.sagemath.org/question/55256/how-to-compute-in-the-tensor-algebra-tv/Answer by FrédéricC for <p>I need to make some computations in low degree in the Tensor algebra $T(V)$ of a rational vector space $V$, but i cannot find a good way of doing this. I could use FreeAlgebras, but then i cannot get access to the summands in my element : for example i want to be able to retrieve $a$ $b$ and $c$ from the element $a<em>b</em>c $ (whenever the element is homogeneous). </p>
<p>The reason for this is I need to define a 'cycle' function that associates $Wa$ to a tensor $aW$ when $W$ is a tensor and $a \in V$.</p>
https://ask.sagemath.org/question/55256/how-to-compute-in-the-tensor-algebra-tv/?answer=55258#post-id-55258Like this maybe
sage: A = algebras.Free(QQ, 'abc')
sage: elt = 4 * A.monomial(Word('abc')) + 6*A.monomial(Word('a'))
sage: data = [(w.to_word(), cf) for w, cf in elt]
sage: A.sum_of_terms((w[1:] + w[:1], cf) for w, cf in data)
6*a + 4*b*c*aWed, 13 Jan 2021 17:24:55 +0100https://ask.sagemath.org/question/55256/how-to-compute-in-the-tensor-algebra-tv/?answer=55258#post-id-55258Comment by qfaes for <p>Like this maybe</p>
<pre><code>sage: A = algebras.Free(QQ, 'abc')
sage: elt = 4 * A.monomial(Word('abc')) + 6*A.monomial(Word('a'))
sage: data = [(w.to_word(), cf) for w, cf in elt]
sage: A.sum_of_terms((w[1:] + w[:1], cf) for w, cf in data)
6*a + 4*b*c*a
</code></pre>
https://ask.sagemath.org/question/55256/how-to-compute-in-the-tensor-algebra-tv/?comment=55262#post-id-55262Thank you so much, that is exactly what I need ! So the algebra element is secretly a list of tuples ?Wed, 13 Jan 2021 19:31:58 +0100https://ask.sagemath.org/question/55256/how-to-compute-in-the-tensor-algebra-tv/?comment=55262#post-id-55262