Re: Contraction of Tensors in Mathematica

• To: mathgroup at smc.vnet.net
• Subject: [mg112539] Re: Contraction of Tensors in Mathematica
• From: Sam Takoy <sam.takoy at yahoo.com>
• Date: Sun, 19 Sep 2010 05:38:17 -0400 (EDT)

```Thank you! Please see my follow up question below 4).

________________________________
From: David Park <djmpark at comcast.net>
To: Sam Takoy <sam.takoy at yahoo.com>; mathgroup at smc.vnet.net
Sent: Sat, September 18, 2010 7:58:41 AM
Subject: [mg112539] RE:  Contraction of Tensors in Mathematica

These are the Mathematical techniques for handling tensor arrays:

1)The Prime Rule for Products of 'Tensor' Arrays in Mathematica:
S.T dots the lowest level of S with the highest level of T,
or equivalently
S.T dots the last level of S with the first level of T.

2)The Mathematica Transpose[T,{n1,n2,n3,...}] moves levels {1,2,3,...} to
levels {n1,n2,n3,...}. We will always want to move the contracted level to
the first or last level when doing Dot products and to the first two levels
when doing single array contractions.

3)If R, S, T,... are Mathematica tensor arrays, then their direct product is
given by Outer[Times,R,S,T,...]. This will produce a single Mathematica
array. The levels are in the same order as the levels in the successive
arrays.
When expanding tensors to be put in Outer it is best to keep the indicies in
strictly ascending sort order with the slots, or at least within each
tensor.

4) The basic Mathematica command for contraction of the top two levels in a
single array T is Tr[T,Plus,2]. We will have to use Transpose on T to put
the contraction slots in the first two levels. We will have to repeat the
operation if we want to do multiple contractions.

>> Thanks again.  What's a good way to ensure that the rest of the indices remain
>>in the same order. If I need to contract indices 5 and 8, I would swap 1 with 5
>>and 2 with 8 before calling Tr. This will mess up the order of indices. What I
>>need instead is bring 5 forward and shift 1 2 3 4 down one. Then bring 8 to slot
>>two and move the rest down one. I could probably do this in a painfully
>>convoluted way, but is there a more elegant way of doing this?

David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/

From: Sam Takoy [mailto:sam.takoy at yahoo.com]

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?