Sie sind auf Seite 1von 6

Printed from the Complete Wolfram Language Documentation 1

TUTORIAL Related Tutorials Related Guides

Functions URL

Symbolic Tensors
Symbolic Array Domains Tensor Canonicalization

The Wolfram System offers a large number of functions to efficiently manipulate lists, matrices, and arrays of any depth and dimension. Among
them there are functions to perform algebraic operations, like sums, products, inner or outer products, transpositions, etc. The Wolfram System
also has powerful algorithms to manipulate algebraic combinations of expressions representing those arrays. These expressions are called
symbolic arrays or symbolic tensors. By assuming given properties about those symbolic arrays (mainly rank, dimension, and symmetry), you can
construct and prove results which are valid for arbitrary members of large domains of arrays obeying those properties.

Matrices are rank 2 arrays and can be symmetric, antisymmetric, or not have any symmetry at all. Higher-rank tensors can be fully symmetric or
fully antisymmetric, but they can also have many other types of symmetries under transposition of their levels or slots. Relevant tensors in
physics and mathematics usually have symmetry: the symmetric inertia tensors, the antisymmetric electromagnetic field, the rank 4 stiffness
tensor in elasticity, the rank 4 Riemann curvature tensor of a manifold, the fully antisymmetric volume forms, etc. Even when you work with
elementary objects without symmetry, like vectors, the repeated use of them leads to the appearance of symmetry. The Wolfram System
introduces a general language to describe arbitrary transposition symmetries of arrays of any depth and dimension, both for ordinary arrays and
for symbolic arrays. See "Tensor Symmetries" for a description of the language of symmetries.

Symbolic Array Domains


A given symbolic expression expr will be taken to belong to a given domain adom of arrays by using an assumption of the form
Element expr, adom , where adom specifies the properties shared by all arrays of that domain.

Arrays d1 , ,dr ,dom,sym arrays of given dimensions, component type, and


symmetry
Matrices d1 ,d2 ,dom,sym matrices of given dimensions, component type, and
symmetry
Vectors d1 ,dom vectors of given dimension and component type

Domains of symbolic arrays.

Extract properties of a real symmetric matrix:

In[1]:= $Assumptions m Matrices 4, 4 , Reals, Symmetric 1, 2


asunciones matrices núme simétrico

Out[1]= m Matrices 4, 4 , Reals, Symmetric 1, 2

In[2]:= TensorRank m
rango de tensor

Out[2]= 2

1988–2019 Wolfram Research, Inc. All rights reserved. http://reference.wolfram.com/language


Printed from the Complete Wolfram Language Documentation 2

In[3]:= TensorDimensions m
dimensiones de tensor

Out[3]= 4, 4

In[4]:= TensorSymmetry m
symmetría de tensor

Out[4]= Symmetric 1, 2

You can compute properties of combinations of tensors, like tensor products:

In[5]:= $Assumptions m Matrices 4, 4 , Complexes, Symmetric 1, 2 ,


asunciones matrices números co simétrico
v Vectors 4, Complexes ;
vectores números complejos

In[6]:= TensorRank m v
rango de tensor

Out[6]= 3

In[7]:= TensorDimensions v m v
dimensiones de tensor

Out[7]= 4, 4, 4, 4

In[8]:= TensorSymmetry v v v
symmetría de tensor

Out[8]= Symmetric 1, 2, 3

The symmetry must be compatible with the dimensions of the array:

In[9]:= m Matrices 3, 4 , Reals, Antisymmetric 1, 2


matrices núme antisimétrico

Matrices : Symmetry specification Antisymmetric 1, 2 is incompatible with expression 3, 4 .


Out[9]= m Matrices 3, 4 , Reals, Antisymmetric 1, 2

In[10]:= m Matrices 3, 3 , Reals, Antisymmetric 1, 2, 3


matrices núme antisimétrico

Matrices : Symmetry specification moves index 3 beyond tensor rank 2.


Out[10]= m Matrices 3, 3 , Reals, Antisymmetric 1, 2, 3

A general symbolic tensor expression can be understood as a linear combination of terms formed by combining the symbolic tensors using three
basic operations: tensor products, transpositions, and contractions. Other basic algebra operations can be decomposed in terms of these.

TensorProduct t1 ,t2 , tensor product of tensors ti


TensorTranspose t, perm transposition of tensor t by permutation perm
TensorContract t, pairs contraction of the pairs of slots in the tensor t

Basic tensor operations.

Declare new symbolic tensor objects:

In[11]:= $Assumptions a Arrays 4, 4, 4 , Reals, Antisymmetric 1, 2, 3 ,


asunciones arreglos núme antisimétrico
b Arrays 2, 3, 4 , Reals , v Vectors 4, Reals ;
arreglos números rea vectores números reales

1988–2019 Wolfram Research, Inc. All rights reserved. http://reference.wolfram.com/language


Printed from the Complete Wolfram Language Documentation 3

This is a transposition of the array b:

In[12]:= TensorTranspose b, 2, 3, 1
traspón tensor

Out[12]= TensorTranspose b, 2, 3, 1

In[13]:= TensorDimensions
dimensiones de tensor

Out[13]= 4, 2, 3

Compare with:

In[14]:= Transpose Array x, 2, 3, 4 , 2, 3, 1 Dimensions


transposición arreglo dimensiones

Out[14]= 4, 2, 3

This is a contraction of levels 1 and 3 of the array a:

In[15]:= TensorContract a, 1, 3
contrae tensor

Out[15]= TensorContract a, 1, 3

In[16]:= TensorDimensions
dimensiones de tensor

Out[16]= 4

Contractions must be dimensionally consistent:

In[17]:= TensorContract b, 1, 3
contrae tensor

TensorContract: Cannot contract array levels of different dimensions 2 and 4.


Out[17]= TensorContract b, 1, 3

All terms in a sum must have the same rank and dimensions, but not necessarily the same symmetry:

In[18]:= 3a 2v v v TensorDimensions
dimensiones de tensor

Out[18]= 4, 4, 4

In[19]:= 3a 2b TensorDimensions
dimensiones de tensor

TensorDimensions: Inhomogeneous dimensions in sum 3 a 2 b.


Out[19]= TensorDimensions 3 a 2b

Tensor Canonicalization
As usual in computer algebra, one of the most important computational steps is converting general expressions into a canonical form, if
possible. When only transposition symmetries are involved, it is always possible to bring symbolic tensor polynomials to such canonical form,
using specialized group theory algorithms. However, for complicated cases involving large ranks, it could consume considerable time and
memory.

1988–2019 Wolfram Research, Inc. All rights reserved. http://reference.wolfram.com/language


Printed from the Complete Wolfram Language Documentation 4

TensorExpand texpr expand tensor sums and products


TensorReduce texpr canonicalize terms with respect to symmetry

Tensor canonicalization.

Declare the properties of various real tensors:

In[20]:= $Assumptions T Arrays 3, 3, 4, 4 , Reals, Symmetric 1, 2 ,


asunciones arreglos núme simétrico
A Matrices 3, 3 , Reals, Antisymmetric 1, 2 ,M Matrices 4, 4 , Reals, Antisymmetric 1, 2 ,
matrices núme antisimétrico matrices núme antisimétrico
P Matrices 4, 4 , Reals ;
matrices números reales

Now you can have a symbolic tensor expression like the following:

In[21]:= texpr 2M P P M P P TensorContract T A, 1, 5 , 2, 6


contrae tensor

Out[21]= 2M P P M P P TensorContract T A, 1, 5 , 2, 6

TensorExpand expands sums in products and applies basic identities:


In[22]:= TensorExpand texpr
expande tensor

Out[22]= TensorContract P T A, 3, 7 , 4, 8 2M P P M P P

TensorReduce applies the same operations, sorts the tensors lexicographically, and uses the symmetry information. In this example, the
contraction term disappears because it involves the contraction of a symmetric and an antisymmetric tensor:
In[23]:= TensorReduce texpr
reduce tensor

Out[23]= 2M P P P TensorTranspose M P, 3, 4, 1, 2

TensorReduce always moves TensorProduct inside TensorContract or TensorTranspose :


In[24]:= TensorContract T, 1, 2 TensorContract P M, 1, 3 TensorReduce
contrae tensor contrae tensor reduce tensor

Out[24]= TensorTranspose TensorContract M P T, 2, 3 , 5, 6 , 4, 3, 1, 2

In[25]:= TensorTranspose A M, 2, 3, 1 T TensorReduce


traspón tensor reduce tensor

Out[25]= TensorTranspose A M T, 2, 3, 1, 4, 5, 6, 7, 8

TensorReduce always moves TensorContract inside TensorTranspose :


In[26]:= TensorContract TensorTranspose P P, 2, 3, 4, 1 , 3, 4 TensorReduce
contrae tensor traspón tensor reduce tensor

Out[26]= TensorTranspose TensorContract P P, 2, 3 , 2, 1

Scalar factors (in this case a contraction of P) are separated if possible:

In[27]:= TensorContract M P P, 3, 4 TensorReduce


contrae tensor reduce tensor

Out[27]= TensorContract P, 1, 2 M P

The next example explores the trace of powers of an antisymmetric matrix. For such a matrix A in any dimension, Tr MatrixPower A, n vanishes

for odd n but not for even n. This is illustrated by constructing the power and trace in terms of TensorProduct and TensorContract and then

canonicalizing the expression using TensorReduce .

1988–2019 Wolfram Research, Inc. All rights reserved. http://reference.wolfram.com/language


Printed from the Complete Wolfram Language Documentation 5

Declare A to be an antisymmetric matrix in arbitrary dimension:

In[28]:= $Assumptions A Matrices d, d , Reals, Antisymmetric 1, 2 ;


asunciones matrices núme antisimétrico

Construct a representation using TensorContract and TensorProduct :


In[29]:= contract mat , n : TensorContract TensorProduct ConstantArray mat, n , Partition RotateLeft Range 2 n ,2
contrae tensor producto tensorial arreglo constante particiona rota a la izqui rango

In[30]:= contract A, 1

Out[30]= TensorContract A, 1, 2

In[31]:= TensorReduce
reduce tensor

Out[31]= 0

In[32]:= contract A, 2

Out[32]= TensorContract A A, 1, 4 , 2, 3

In[33]:= TensorReduce
reduce tensor

Out[33]= TensorContract A A, 1, 3 , 2, 4

In[34]:= contract A, 3

Out[34]= TensorContract A A A, 1, 6 , 2, 3 , 4, 5

In[35]:= TensorReduce
reduce tensor

Out[35]= 0

These are the results for low values of n:

In[36]:= Table n TensorReduce contract A, n 0, n, 20


tabla reduce tensor

Out[36]= 1 True, 2 False, 3 True, 4 False, 5 True, 6 False, 7 True, 8 False, 9 True, 10 False, 11 True,
12 False, 13 True, 14 False, 15 True, 16 False, 17 True, 18 False, 19 True, 20 False

A more complicated example is given by the canonicalization of scalar polynomials in the Riemann tensor. Here, only its transposition symme-
tries are used (also known as permutation symmetries or monoterm symmetries), and not the Riemann cyclic symmetries.

This is a specification of the Riemann transposition symmetry:

In[37]:= Rsym 2, 1, 3, 4 , 1 , 3, 4, 1, 2 , 1 ;

In[38]:= $Assumptions R Arrays d, d, d, d , Reals, Rsym


asunciones arreglos números reales

Out[38]= R Arrays d, d, d, d , Reals, Cycles 1, 2 , 1 , Cycles 1, 3 , 2, 4 , 1 , Cycles 3, 4 , 1

There are 24 possible transpositions:

In[39]:= TensorTranspose R, & Permutations 1, 2, 3, 4


traspón tensor permutaciones

Out[39]= R, TensorTranspose R, 1, 2, 4, 3 , TensorTranspose R, 1, 3, 2, 4 ,


TensorTranspose R, 1, 3, 4, 2 , TensorTranspose R, 1, 4, 2, 3 , TensorTranspose R, 1, 4, 3, 2 ,
TensorTranspose R, 2, 1, 3, 4 , TensorTranspose R, 2, 1, 4, 3 , TensorTranspose R, 2, 3, 1, 4 ,
TensorTranspose R, 2, 3, 4, 1 , TensorTranspose R, 2, 4, 1, 3 , TensorTranspose R, 2, 4, 3, 1 ,
TensorTranspose R, 3, 1, 2, 4 , TensorTranspose R, 3, 1, 4, 2 , TensorTranspose R, 3, 2, 1, 4 ,
TensorTranspose R, 3, 2, 4, 1 , TensorTranspose R, 3, 4, 1, 2 , TensorTranspose R, 3, 4, 2, 1 ,
TensorTranspose R, 4, 1, 2, 3 , TensorTranspose R, 4, 1, 3, 2 , TensorTranspose R, 4, 2, 1, 3 ,
TensorTranspose R, 4, 2, 3, 1 , TensorTranspose R, 4, 3, 1, 2 , TensorTranspose R, 4, 3, 2, 1

1988–2019 Wolfram Research, Inc. All rights reserved. http://reference.wolfram.com/language


Printed from the Complete Wolfram Language Documentation 6

But only three (up to sign) are canonical:

In[40]:= TensorReduce Union


reduce tensor unión

Out[40]= R, R, TensorTranspose R, 1, 3, 2, 4 , TensorTranspose R, 1, 3, 2, 4 ,


TensorTranspose R, 1, 4, 2, 3 , TensorTranspose R, 1, 4, 2, 3

This gives random contraction of m pairs of slots in the tensor product of n Riemann tensors:

In[41]:= randomRprod n , m : TensorContract TensorProduct ConstantArray R, n ,


contrae tensor producto tensorial arreglo constante
Partition RandomSample Range 4 n Range 2 m ,2 ;m 2n
particiona muestra aleatoria rango rango

These are three contractions with two Riemann tensors:

In[42]:= SeedRandom 17 ;
semilla aleatoria
randomRprod 2, 3
Out[43]= TensorContract R R, 1, 6 , 2, 3 , 5, 8

In[44]:= TensorReduce Timing


reduce tensor cronometra

Out[44]= 0., TensorContract R R, 2, 3 , 4, 7 , 6, 8

A bigger case, involving 25 tensors (100 slots) and 40 contraction pairs:

In[45]:= randomRprod 25, 40

Out[45]= TensorContract R R R R R R R R R R R R R R R R R R R R R R R R R,
1, 83 , 2, 17 , 3, 42 , 4, 63 , 6, 31 , 7, 36 , 8, 29 , 10, 85 , 11, 64 , 12, 66 ,
13, 91 , 14, 79 , 16, 53 , 18, 52 , 19, 28 , 20, 88 , 21, 98 , 24, 68 , 26, 33 , 30, 93 ,
34, 96 , 35, 54 , 37, 59 , 39, 74 , 41, 48 , 44, 67 , 45, 78 , 46, 82 , 47, 76 , 49, 65 ,
50, 60 , 51, 58 , 57, 81 , 61, 100 , 62, 77 , 69, 72 , 73, 84 , 75, 87 , 80, 95 , 86, 90

In[46]:= TensorReduce Timing


reduce tensor cronometra

Out[46]= 0.031200, TensorContract R R R R R R R R R R R R R R R R R R R R R R R R R,


2, 22 , 3, 23 , 4, 53 , 6, 57 , 7, 61 , 8, 65 , 10, 35 , 11, 44 , 12, 69 , 14, 50 ,
16, 63 , 18, 55 , 20, 73 , 24, 46 , 26, 77 , 28, 81 , 30, 64 , 31, 85 , 32, 89 , 36, 54 ,
38, 40 , 42, 58 , 47, 56 , 48, 70 , 52, 67 , 59, 74 , 60, 83 , 62, 93 , 66, 86 , 68, 71 ,
72, 91 , 75, 87 , 76, 95 , 78, 94 , 79, 96 , 80, 97 , 82, 99 , 84, 90 , 88, 100 , 92, 98

Related Guides
Symbolic Tensors

Related Tutorials
Tensor Symmetries
Symmetrized Arrays

1988–2019 Wolfram Research, Inc. All rights reserved. http://reference.wolfram.com/language

Das könnte Ihnen auch gefallen