Re: Contraction of Tensors in Mathematica

*To*: mathgroup at smc.vnet.net*Subject*: [mg112546] Re: Contraction of Tensors in Mathematica*From*: Simon <simonjtyler at gmail.com>*Date*: Sun, 19 Sep 2010 05:39:34 -0400 (EDT)*References*: <i727in$etb$1@smc.vnet.net>

Hi Sam, Hopefully the following example will be clear enough to generalise: In[1]:= A=Array[a,{2,2,2}] Out[1]= {{{a[1,1,1],a[1,1,2]},{a[1,2,1],a[1,2,2]}}, {{a[2,1,1],a[2,1,2]},{a[2,2,1],a[2,2,2]}}} In[2]:= Tr[A,Plus,2] Out[2]= {a[1,1,1]+a[2,2,1],a[1,1,2]+a[2,2,2]} In[3]:= Tr[Transpose[A,{1,3,2}],Plus,2] Out[3]= {a[1,1,1]+a[2,1,2],a[1,2,1]+a[2,2,2]} A trace to depth 2, traces over the first two indices. Take the appropriate Transpose[] to move the indices you want to trace to the front (leaving the rest in the same order). Simon On Sep 18, 9:25 pm, Sam Takoy <sam.ta... at yahoo.com> wrote: > Hi, > > I this message I will suppress the covariant/contravariant nature of > tensors. > > Suppose I have two tensors A_ijkl and B_rstu (denoted by a and b in > Mathematica). Each tensor is presented for a 4-deep list. Now, I want to > form a new tensor: > > C_ijklrstu = A_ijkl*B_rstu > > and I want C to be represented by an 8-deep list. I've gathered is that > what I need to do is > > c = Outer[Times, a, b]; > > Great! > > Now supposed I want to do some contraction to define a new tensor > > D_jklrsu = C_ijklrsiu? > > How do I do that? > > Many thanks in advance! > > Sam