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.Thu, 16 Apr 2015 22:39:25 +0200Is Einstein notation available in sage?https://ask.sagemath.org/question/26548/is-einstein-notation-available-in-sage/ Dear all
I searched here. But I can not find a contented answer. There is [a very usable notation in summations](http://en.wikipedia.org/wiki/Einstein_notation) simplifying computations inclusive very $\Sigma$.
Is there a way in Sage that I can use this kind of notation? For more information, this notation is worked out in Cadabra.
Thu, 16 Apr 2015 00:26:15 +0200https://ask.sagemath.org/question/26548/is-einstein-notation-available-in-sage/Answer by eric_g for <p>Dear all</p>
<p>I searched here. But I can not find a contented answer. There is <a href="http://en.wikipedia.org/wiki/Einstein_notation">a very usable notation in summations</a> simplifying computations inclusive very $\Sigma$. </p>
<p>Is there a way in Sage that I can use this kind of notation? For more information, this notation is worked out in Cadabra. </p>
https://ask.sagemath.org/question/26548/is-einstein-notation-available-in-sage/?answer=26563#post-id-26563Hi,
Since Sage 6.6 (released 2 days ago !), there is some Einstein notation in Sage, but only for some specific purpose: operations on tensors defined on free modules:
sage: M = FiniteRankFreeModule(ZZ, 3, name='M')
sage: e = M.basis('e')
sage: a = M.tensor((1,1))
sage: a[:] = [[2,0,-1], [3,-6,1], [2,1,-4]]
sage: b = M([3,-5,1])
sage: c = a['^i_j'] * b['^j'] # contraction on the repeated index j
sage: c
Element of the Rank-3 free module M over the Integer Ring
sage: c[:]
[5, 40, -3]
sage: c.display()
5 e_0 + 40 e_1 - 3 e_2
sage: a['^k_k'] # trace of a
-8
See [here](http://sagemanifolds.obspm.fr/doc/reference/tensor_free_modules/sage/tensor/modules/tensor_with_indices.html) for more details.
Maybe there is Einstein notation in other parts of Sage, but I am not aware of them.
Eric.Thu, 16 Apr 2015 13:47:17 +0200https://ask.sagemath.org/question/26548/is-einstein-notation-available-in-sage/?answer=26563#post-id-26563Comment by eric_g for <p>Hi,</p>
<p>Since Sage 6.6 (released 2 days ago !), there is some Einstein notation in Sage, but only for some specific purpose: operations on tensors defined on free modules:</p>
<pre><code>sage: M = FiniteRankFreeModule(ZZ, 3, name='M')
sage: e = M.basis('e')
sage: a = M.tensor((1,1))
sage: a[:] = [[2,0,-1], [3,-6,1], [2,1,-4]]
sage: b = M([3,-5,1])
sage: c = a['^i_j'] * b['^j'] # contraction on the repeated index j
sage: c
Element of the Rank-3 free module M over the Integer Ring
sage: c[:]
[5, 40, -3]
sage: c.display()
5 e_0 + 40 e_1 - 3 e_2
sage: a['^k_k'] # trace of a
-8
</code></pre>
<p>See <a href="http://sagemanifolds.obspm.fr/doc/reference/tensor_free_modules/sage/tensor/modules/tensor_with_indices.html">here</a> for more details.</p>
<p>Maybe there is Einstein notation in other parts of Sage, but I am not aware of them. </p>
<p>Eric.</p>
https://ask.sagemath.org/question/26548/is-einstein-notation-available-in-sage/?comment=26574#post-id-26574Alas in the current setting, the dimension has to be a well defined integer.Thu, 16 Apr 2015 22:39:25 +0200https://ask.sagemath.org/question/26548/is-einstein-notation-available-in-sage/?comment=26574#post-id-26574Comment by Haron for <p>Hi,</p>
<p>Since Sage 6.6 (released 2 days ago !), there is some Einstein notation in Sage, but only for some specific purpose: operations on tensors defined on free modules:</p>
<pre><code>sage: M = FiniteRankFreeModule(ZZ, 3, name='M')
sage: e = M.basis('e')
sage: a = M.tensor((1,1))
sage: a[:] = [[2,0,-1], [3,-6,1], [2,1,-4]]
sage: b = M([3,-5,1])
sage: c = a['^i_j'] * b['^j'] # contraction on the repeated index j
sage: c
Element of the Rank-3 free module M over the Integer Ring
sage: c[:]
[5, 40, -3]
sage: c.display()
5 e_0 + 40 e_1 - 3 e_2
sage: a['^k_k'] # trace of a
-8
</code></pre>
<p>See <a href="http://sagemanifolds.obspm.fr/doc/reference/tensor_free_modules/sage/tensor/modules/tensor_with_indices.html">here</a> for more details.</p>
<p>Maybe there is Einstein notation in other parts of Sage, but I am not aware of them. </p>
<p>Eric.</p>
https://ask.sagemath.org/question/26548/is-einstein-notation-available-in-sage/?comment=26572#post-id-26572Dear Eric,
1) I must to thanks for your attention.
2) I saw the details link you mentioned. Your theory is very good. because I deal with vector spaces as very special modules. It works and seems flexible in computations. But, here is a problem for me. Since I am working with tensors symbolically, I need to recognizing no fixed dimension. Cadabra serves this very good for me. But, I like to do all of my computation with sage and python only.Thu, 16 Apr 2015 20:42:53 +0200https://ask.sagemath.org/question/26548/is-einstein-notation-available-in-sage/?comment=26572#post-id-26572