0
$\begingroup$

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?

$\endgroup$
  • 1
    $\begingroup$ This is a bug in FromTensor (I forgot that Dot[a] autoevaluates to a). I will push a fix tonight. $\endgroup$ – Carl Woll Oct 3 '19 at 21:49
1
$\begingroup$

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.