Convert an expression involving Dot, Tr and MatrixPower into an equivalent expression using TensorContract
Contributed by:
Carl Woll
Examples
Basic Examples (4)
Specify the properties of symbolic arrays:
A tensor built using Tr and Dot:
Convert to an equivalent form using TensorContract:
Check:
Scope (2)
Check equivalence of forms, assuming the two matrices A and B are square:
A tensor consisting of Dot, Tr and MatrixPower:
Evaluate, assuming the two matrices are square:
Applications (2)
TensorReduce is unable to reduce some mixed expressions consisting of both TensorContract and Dot:
Using ToTensor trivially simplifies the expression:
Possible Issues (2)
Rank information for symbolic tensors must be specified using the Assumptions option or using $Assumptions:
Here the assumptions are added correctly:
Only Tr expression representing traces of the first two levels of an array have equivalent TensorContract representations:
Publisher
Carl Woll
Version History
-
1.2.0
– 17 April 2025
-
1.1.0
– 14 December 2021
-
1.0.0
– 16 October 2019
Related Resources