Message Boards Message Boards

Contract a rank 2 tensor with a rank 1 tensor?

Posted 5 years ago

I have a rank 2 tensor obtained by acting with the grad operator twice successively on a function [Psi], so let's call this tensor [Psi]2. I then simply want to contract it over its two indices with a vector f such that I obtain a new vector, but cannot get it to work for some reason, so not sure if I am doing the wrong syntax.

What I am trying is

Sum[f[[i]]*\[Psi]2[[i, j]], {i, 1, 3}, {j, 1, 3}] 

to do the contraction, but for some reason I get a scalar instead of a vecto

POSTED BY: Hollis Williams
2 Replies
Posted 5 years ago

Are you maybe looking for something like this?

In[1]:= matrix = Partition[Range@9, 3]
Out[1]= {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}

In[2]:= vector = {10, 12, 13}
Out[2]= {10, 12, 13}

In[3]:= matrix.vector
Out[3]= {73, 178, 283}
POSTED BY: Hans Milton

By summing over both $i$ and $j$ you’re adding up the entries in the contraction. What you presumably want is something like

Table[Sum[?2[[i, j]]*f[[j]], {j, 1, 3}], {i, 1, 3}]

Of course, as @Hans Milton points out, this is the same as ?2.f.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract