I am looking to take two rank two tensors and then contract one of the indices with one of the indices of the second tensor to get another rank two tensor, so something like
A_{ij}B_{ik}=C_{jk}
Could someone advise how I would do this in Mathematica?
That is standard matrix multiplication, which you can do with the dot operator in Mathematica. Since the inner indices are summed over in matrix multiplication, you have to transpose A first.
Transpose[A].B
or, if you want to show the summation indices more explicitly, you can do something like
Table[Sum[A[[i, j]]*B[[i, k]], {i, 1, 3}], {j, 1, 3}, {k, 1, 3}]
the latter approach may generalize better for higher rank tensors
An alternative could be to use TensorProduct and TensorContract:
mA = {{a11, a12}, {a21, a22}};
mB = {{b11, b12}, {b21, b22}};
In[3]:= TensorContract[TensorProduct[mA, mB], {1, 3}]
Out[3]= {{a11 b11 + a21 b21, a11 b12 + a21 b22}, {a12 b11 + a22 b21, a12 b12 + a22 b22}}
Same result as with Sam’s method:
In[4]:= Transpose[mA].mB
Out[4]= {{a11 b11 + a21 b21, a11 b12 + a21 b22}, {a12 b11 + a22 b21, a12 b12 + a22 b22}}