# FromTensor + TensorContract gives unexpected result for a tensor product of vectors and a matrix

I have written a larger code that uses the TensorSimplify package written by Carl Woll for tensor manipulations. The code, however, produces unexpected results, which I have been able to narrow down to a few lines using TensorProduct and subsequently TensorContract and FromTensor. Here is a typical example in a standalone form (including installation of the package):

PacletInstall["TensorSimplify",
"Site" -> "http://raw.githubusercontent.com/carlwoll/TensorSimplify/master"];
<< TensorSimplify
$Assumptions = {(u|v) \[Element] Vectors[d],A \[Element] Matrices[{d, d}]}; TensorContract[u\[TensorProduct]A\[TensorProduct]v, {{1, 3}, {2, 4}}] // FromTensor TensorContract[A\[TensorProduct]u\[TensorProduct]v, {{1, 4}, {2, 3}}] // FromTensor  Both evaluation lines produce v.Transpose[A].u while I would in both cases expect v.A.u. Is there something trivial about the way that TensorContract or FromTensor works that I am misunderstanding? • This is a bug in FromTensor (I forgot that Dot[a] autoevaluates to a). I will push a fix tonight. – Carl Woll Oct 3 '19 at 21:49 ## 1 Answer This was a bug in my code, fixed with version 0.0.3. Should work now. From a fresh kernel: PacletUninstall["TensorSimplify"] PacletInstall["TensorSimplify","Site"->"http://raw.githubusercontent.com/carlwoll/TensorSimplify/master"]; <<TensorSimplify$Assumptions={(u|v) ∈ Vectors[d],A ∈ Matrices[{d,d}]};
TensorContract[u \[TensorProduct] A \[TensorProduct]v,{{1,3},{2,4}}]//FromTensor
TensorContract[A \[TensorProduct] u \[TensorProduct]v,{{1,4},{2,3}}]//FromTensor


v.A.u

v.A.u

• Fantastic!!! Thank you so much for the quick fix of the bug! – Tomáš Brauner Oct 4 '19 at 8:16