Tensors - a complete guide - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Physics : Tensors - a complete guide

A Complete Guide for performing Tensors computations using Physics

 

The Physics package, developed by Maplesoft, is an integral part of the Maple system. The package includes commands for Classical and Quantum Mechanics, Classical Field Theory and General Relativity. It also includes 5 subpackages: Vectors, StandardModel, FeynmanIntegral, and Tetrads and ThreePlusOne which are related to General Relativity.

 

Section I of this guide includes the information needed to compute with tensors in Classical and Quantum Mechanics, Electrodynamics and Special Relativity, using the Physics package. This section is also relevant for computations in General Relativity. Section II is completely devoted to working with tensors in curved spacetimes. Section III is about transformations of coordinates.

 

To transform this page into an active computational worksheet that enables you to reproduce its contents, click the corresponding icon on the toolbar.

 

For an alphabetical list of the Physics commands with one-line descriptions and links to the corresponding help pages see Physics: Brief description of each command.

 

I. Spacetime and tensors in Physics

 

Default metric, signature and coordinates

Systems of coordinates

Tensors, their definition, symmetries and operations

Defining a tensor by passing the tensor itself

Defining a tensor by passing a tensorial equation

Automatic formatting of repeated tensor indices and handling of their collisions in products

Tensor symmetries

Substituting tensors and tensor indices

Simplifying tensorial expressions

Sum over repeated indices

Visualizing tensor components - Library:-TensorComponents and TensorArray

Modifying tensor components - Library:-RedefineTensorComponent

Using CompactDisplay to enhance the display of tensorial expressions involving tensor functions and derivatives

The LeviCivita tensor and KroneckerDelta

The 3D space metric and decomposing 4D tensors into their 3D space part and the rest

Total differentials, the d_[mu] and dAlembertian operators

Tensorial differential operators in algebraic expressions

Inert tensors

Functional differentiation of tensorial expressions with respect to tensor functions

The Pauli matrices and the spacetime Psigma[mu] 4-vector

The Dirac matrices and the spacetime Dgamma[mu] 4-vector

Quantum not-commutative operators using tensor notation

 

II. Curved spacetimes

 

10 

Loading metrics from the database of solutions to Einstein's equations

11 

Setting the spacetime metric indicating the line element or a Matrix

12 

Covariant differentiation: the D_[mu] operator and the Christoffel symbols

13 

The LeviCivita tensor in curved spacetimes and the determinant of the metric

14 

The Einstein, Ricci, Riemann and Weyl tensors of General Relativity

15 

The EnergyMomentum tensor

16 

Killing vectors

17 

Geodesics

18 

A conversion network for the tensors of General Relativity

19 

Tetrads and the local system of reference - the Newman-Penrose formalism

20 

Differentiating the spacetime metric, the tetrad, and their determinants, with respect to each other

21 

The ThreePlusOne package and the 3 + 1 splitting of Einstein's equations

 

III. Transformations of coordinates

I. Spacetime and tensors in Physics

 

This section contains the information needed to compute with tensors in Classical and Quantum Mechanics, Electrodynamics and Special Relativity, using the Physics package. This material is also relevant for computing with tensors in General Relativity, for which there is a dedicated Section II: Curved spacetimes.

 

Default metric and signature, coordinate systems

 

To load Physics enter

withPhysics

`*`,`.`,Annihilation,AntiCommutator,Antisymmetrize,Assume,Bra,Bracket,Check,Christoffel,Coefficients,Commutator,CompactDisplay,Coordinates,Creation,D_,Dagger,Decompose,Define,Dγ,Einstein,EnergyMomentum,Expand,ExteriorDerivative,Factor,FeynmanDiagrams,FeynmanIntegral,Fundiff,Geodesics,GrassmannParity,Gtaylor,Intc,Inverse,Ket,KillingVectors,KroneckerDelta,LagrangeEquations,LeviCivita,Library,LieBracket,LieDerivative,Normal,NumericalRelativity,Parameters,PerformOnAnticommutativeSystem,Projector,Psigma,Redefine,Ricci,Riemann,Setup,Simplify,SortProducts,SpaceTimeVector,StandardModel,Substitute,SubstituteTensor,SubstituteTensorIndices,SumOverRepeatedIndices,Symmetrize,TensorArray,Tetrads,ThreePlusOne,ToContravariant,ToCovariant,ToFieldComponents,ToSuperfields,Trace,TransformCoordinates,Vectors,Weyl,`^`,dAlembertian,d_,diff,g_,gamma_

(1)

By default, the spacetime metric is 4-dimensional, of Minkowski type, with the signature (- - - +). You can verify the metric, signature and dimension at any time in different ways, the simplest being:

g_

g_μ,ν=1000010000100001

(2)

 

In Physics, everything is set up using the Setup command. Likewise, you can query one or several settings simultaneously using the same command, for example:

Setupcoordinates, dimension, signature,metric

g_μ,ν=1000010000100001

_______________________________________________________

coordinatesystems=none,dimension=4,metric=1,1=−1,2,2=−1,3,3=−1,4,4=1,signature=- - - +

(3)

The dimension, signature and metric, as well as all other Physics settings, can also be changed using Setup and Redefine. For example, to change the default signature you can enter Setupsignature = `+++ -`. To change the signature, reorder the coordinates and the lines and columns in the metric all in one go enter Redefinesetall,tosignature=`+ + + -`. The five signatures understood by Physics are:

 

(- - - +), default.

(+ - - - ), same line element as a.

(+ + + -), used in the ThreePlusOne package and ADM formalism, and in the database of exact solutions to Einstein equations.

(- + + +), same line element as c.

(+ + + +), used to set a Euclidean spacetime.

 

These signatures generalize naturally when you change the spacetime dimension.

 

In a flat spacetime, the value of the signature defines the signs in the line element

g_lineelement;

Systems of spacetime coordinates are:X=x1,x2,x3,x4

ⅆx12ⅆx22ⅆx32+ⅆx42

(4)

In a curved spacetime you can always define, at any point, a local system of reference of Minkowski type, also referred to in Maple as the tetrad system. The value of the signature defines the line element in that local system of reference.

 

The signature also indicates the position of the time-like component

Library:-PositionOfTimelikeComponent;

4

(5)

 and therefore the ordering of lines and columns in the matrix representation of the metric (2).

 

To redefine a metric, the coordinates, or both according to a change you make in the signature you can use Setup or, more simply, use the Redefine command.

 

You can also visualize and change all the Physics settings at once using the Setup applet, launched entering Setup. The following image shows the left half of that applet.

Setup

 


Systems of coordinates

 

A coordinate system is not set by default when you load the package. You can set it by indicating an uppercase letter that will work as a label representing the sequence of the four coordinates (this is internally implemented using alias).

Setupcoordinates = X

Systems of spacetime coordinates are:X=x1,x2,x3,x4

_______________________________________________________

coordinatesystems=X

(6)

For historical reasons, to set coordinate systems there is also the Coordinates command, which can be used for the same purpose as Setup.

 

Setting a coordinate system is necessary when computing with curved spacetimes in order to compute the derivatives of the metric that enter the Christoffel symbols, which are then used to compute the components of all the general relativity tensors - an operation performed in the background, automatically, when you define the metric.

 

In a flat spacetime setting a coordinates system is optional, although it can be useful for different purposes as explained below.

The coordinates of the first system of coordinates you set are used by the d_, D_ and dAlembertian commands as the default differentiation variables.

 

You can define several coordinates systems at the same time

Setupcoordinates = Y

Systems of spacetime coordinates are:X=x1,x2,x3,x4,Y=y1,y2,y3,y4

_______________________________________________________

coordinatesystems=X,Y

(7)

To change the coordinates used by the differential operators d_, D_ and dAlembertian, for example from X to Y, enter Setupdifferentiationvariables=Y.

 

All the coordinates of coordinates systems that are defined using Setup or Coordinates are automatically assumed to be real, so coulditbe, is and getassumptions, and through them all the Maple library, know about the coordinates' properties

getassumptionsx2

x2::real

(8)

Often one works with Cartesian, spherical or cylindrical coordinates. These three keywords are understood by Setup and, when using any of them, you can, but do not need to, specify the label representing the coordinates. In that case, the label of the differentiation coordinates system is reused. If no coordinates system is defined then X is used. You can thus also set the coordinates via

Setupcoordinates = spherical

Default differentiation variables for d_, D_ and dAlembertian are:X=r,θ,φ,t

Systems of spacetime coordinates are:X=r,θ,φ,t,Y=y1,y2,y3,y4

_______________________________________________________

coordinatesystems=X,Y

(9)

Note that the coordinate t, complementing the three spherical coordinates, is positioned according to the signature (- - - +). To change the signature, see Setup. In the case of spherical and cylindrical coordinates, the assumptions automatically placed on them are the expected ones:

mapgetassumptions,X

r::0,,θ::0,π,φ::0,2π,t::0,

(10)

 

Finally, you can also specify any coordinates to constitute a coordinates system and, in doing so, you can also redefine a previously used label. For example:

Setupcoordinates = X=u,v,w,t,Z=z__1,z__2,z__3,z__4

Systems of spacetime coordinates are:X=u,v,w,t,Y=y1,y2,y3,y4,Z=z__1,z__2,z__3,z__4

_______________________________________________________

coordinatesystems=X,Y,Z

(11)

When the coordinates you define have specific geometrical meaning, e.g. (10), you can indicate that using the Assume command so that any restriction in their range is automatically taken into account, for example, when simplifying expressions.

• 

Different uses of a coordinates system label

 

Due to the use of alias, the label of a coordinate system - say X - actually represents the sequence of the four coordinates, and so you can use this label to refer to all the coordinates at once, for example, when specifying the functionality of functions

FX

FX

(12)

where FXis a function of four variables. You can check the number of its operands, or get any one of its variables via

nops

4

(13)

op4,FX

t

(14)

It is often useful to avoid a redundant display of the coordinate's dependencyXin functions. For that purpose use CompactDisplay.

CompactDisplayFX

Fu,v,w,twill now be displayed asF

(15)

The dependency of FXis now omitted from the display

FX

(16)

FX

FX

(17)

In Maple, the indices of tensors are represented through normal indexing []. Thus you can use the label of a coordinates system to represent the SpaceTimeVector

Xmu

Xμ

(18)

In the context of Physics, contravariant indices are entered preceded by ~

X~mu

Xμμ

(19)

The distinction between covariant and contravariant indices is relevant in non-Euclidean spacetimes (you can set the spacetime to be Euclidean by entering Setupmetric=Euclidean). For example, in a flat Minkowski spacetime, when summing over the repeated indices of tensorial expressions (see SumOverRepeatedIndices)

Xmu2

XμXμμ

(20)

SumOverRepeatedIndices

t2u2v2w2

(21)

Defining more than one coordinates system is also convenient when transforming coordinates using the TransformCoordinates command, as explained in the next sections.

Tensors: their definition, symmetries and operations

 

Physics comes with a set of predefined tensors, mainly the spacetime metric gμ,ν, the space metric γj,k, and all the standard tensors of General Relativity. To check their definition, index the tensor with the keyword definition, for example: γdefinition. In addition, one of the strengths of Physics is that you can define tensors, in natural ways, by indicating a matrix or array with its components, or by indicating any generic tensorial expression involving other tensors.

 

In Maple tensor indices are letters, lowercase or uppercase, Latin or Greek, just like when computing with paper and pencil. The indices are entered using indexation, as in Amu, and are displayed as subscripts as in Aμ. To change or set the kind of letter (greek, lowercaselatin, etc.) used to represent a kind of index (spacetime, space, etc.) see Setup.

 

Contravariant indices are entered with ~ preceding the letter, as in A~mu, and are displayed as superscripts, as in Aμμ. You can work with two or more kinds of indices at the same time, e.g., spacetime and space indices.

 

To input Greek letters you can spell them, as in mu for μ, or simpler: use the shortcuts for entering Greek characters. Right-click your input and choose Convert To → 2-D Math input to give your spelled tensorial expression a textbook high-quality typesetting.

 

However, not every indexed object or function is automatically a tensor. You need to define it as such first with the Define command. You can do that in two ways:

 

Passing the tensor being defined, say Fμ,ν, to the Define command, possibly indicating symmetries and/or antisymmetries for its indices.

Passing a tensorial equation where the left-hand side is the tensor being defined, as in item 1., and the right-hand side is a tensorial expression - or an Array or Matrix - such that the components of the tensor being defined become equal to the components of the tensorial expression.

 

After defining a tensor, say Fμ,ν, you can perform the following operations on algebraic expressions involving it:

• 

Automatic formatting of repeated indices, one covariant the other contravariant

• 

Automatic handling of collisions of repeated indices in products of tensors

• 

Simplify products using Einstein's sum rule for repeated indices

• 

SumOverRepeatedIndices of the tensorial expression

• 

Use TensorArray to compute the expression's components

• 

TransformCoordinates

 

If you define a tensor using a tensorial equation you can additionally:

 

• 

Get each tensor component by indexing, as in A1 or A11

• 

Get all the covariant and contravariant components by respectively using the shortcut notation A and A~

• 

Use any of the special indexing keywords valid for the pre-defined tensors of Physics. They are definition, nonzero, and for tensors with 2 indices also trace and determinant

• 

Forgo specifying the tensor dependency for differentiation purposes - it is inferred automatically from its definition

• 

Redefine any particular tensor component using Library:-RedefineTensorComponent

• 

Minimizing the number of independent tensor components using Library:-MinimizeTensorComponent

• 

Compute the number of independent tensor components - relevant for tensors with many indices and different symmetries - using Library:-NumberOfTensorComponents

 

The following sections showcase these two ways of defining a tensor, the features described above, and the basic functionality in the Physics package for computing with tensors.

 

Defining a tensor by passing the tensor itself

 

The simplest way to define a spacetime or any other type of tensor is passing the tensor itself as a name indexed by one or several indices of the corresponding type.

 

By default, spacetime indices are represented by Greek letters

restart;withPhysics:Setupspacetimeindices

spacetimeindices=greek

(22)

To change the type of letter used for a kind of index see Setup. Therefore, the simplest way to define a spacetime tensor is, for instance

DefineAmu

Defined objects with tensor properties

Aμ,γμ,σμ,μ,gμ,ν,εα,β,μ,ν

(23)

The output of Define is always a set with all the tensors defined so far (it includes the predefined tensors, and all the coordinates systems as SpaceTimeVectors). To avoid the verbosity of Define's output use the quiet option.

 

To clear a tensor definition, like the one above, enter Defineclear, A.


Once Aμ is defined as a tensor you can refer to any of its components by indexing with the corresponding covariant or contravariant number

A1

A1

(24)

A~1

A11

(25)

To retrieve all the components at once you can use TensorArray or Library:-TensorComponents, the respective output will be an Array or a list

TensorArrayAmu

A1A2A3A4

(26)

Library:-TensorComponentsA~mu

A11,A22,A33,A44

(27)

 

When the spacetime is not Euclidean the repeated indices are automatically reformatted: one covariant the other contravariant

Amu g_mu,nu

gμ,νAμμ

(28)

When the automatic choice of which one is contravariant is not the one you prefer, you can indicate your preference by using ~ for the contravariant one

Amu g_~mu,nu

Aμg_ν,~mu

(29)

Tensorial expressions, i.e. expressions that have any of the predefined tensors of Physics or tensors defined by you using Define, can be simplified using Simplify. That simplification takes into account the symmetry properties of tensorial subexpressions and makes use of the sum rule for repeated indices

Simplify

Aν

(30)

Repeated indices - some or all - can be summed over using SumOverRepeatedIndices

SumOverRepeatedIndices

g1,νA11+g2,νA22+g3,νA33+g4,νA44

(31)

Recalling the current value of the metric

g_

g_μ,ν=1000010000100001

(32)

a tensor array with the components of, for example, the relationship Aν=gμ,νAμμ, can be computed using TensorArray

TensorArrayAν=gμ,νAμμ

A1=A~1A2=A~2A3=A~3A4=A~4

(33)

Note the textbook typesetting of the input above. That input line includes subscripts and superscripts for the tensor indices. You can achieve this input with typesetting by entering the expression using standard Maple notation, as in: TensorArrayAnu = g_mu, nu A~mu, then right-clicking the expression and following the pop-up menu 2-D Math → Convert To → 2-D Math input. This is particularly useful:

when the input and output are the same so you can terminate the input with : to avoid displaying the output,

when the input without typesetting is not easy to read/understand

for presentation purposes.

 

When you perform a coordinate transformation, tensors change according to specific rules. For that purpose, start by setting two coordinate systems, as shown in the previous section

CoordinatesX=u,v,w,t,Z=z__1,z__2,z__3,z__4

Systems of spacetime coordinates are:X=u,v,w,t,Z=z__1,z__2,z__3,z__4

X,Z

(34)

You can now transform coordinates using TransformCoordinates, for example from X to Z usingu=z__1+z__2,v=z__1z__2, as follows:

tr  u=z__1+z__2,v=z__1z__2:

TransformCoordinatestr, Amu

A1+A2A1A2A3A4

(35)

Note the different transformation rule for the covariant components (above) and the contravariant ones:

TransformCoordinatestr, A~mu

12A~1+12A~212A~112A~2A~3A~4

(36)

Defining a tensor by passing a tensorial equation

 

Tensors defined by passing a tensorial equation have all the features mentioned in the previous section, which enable you to Simplify, SumOverRepeatedIndices, TensorArray, and TransformCoordinates, as well as several additional ones.

 

A simple example is that of a 4-vector. This time, we also want to specify its components. You can indicate them in a list on the right-hand side of the definition

Definepμ = p__x,p__y,p__z,Ec

Defined objects with tensor properties

Aμ,γμ,σμ,μ,gμ,ν,pμ,εα,β,μ,ν,Xμ,Zμ

(37)

On the right-hand side of the definition you can also use a Vector construction, as in p__x,p__y,p__z,Ec, or a Matrix. See Define for all the possible ways you can use to indicate the components.

 

Having defined p passing a tensorial equation, you can now get each of its components via indexing

p1

p__x

(38)

p0

Ec

(39)

Note that the value 0 of the index points to the position of the timelike component, that is, the position of the different sign in the signature. You can query that using Setup

Setupsignature

signature=- - - +

(40)

or Library:-PositionOfTimelikeComponent

Library:-PositionOfTimelikeComponent

4

(41)

When the tensor is defined using a tensorial equation and a coordinates system is set you can also use the coordinates as tensor indices to select tensor components. For example,

Setupcoordinates = cartesian, usecoordinates = true

* Partial match of 'usecoordinates' against keyword 'usecoordinatesastensorindices'

Default differentiation variables for d_, D_ and dAlembertian are:X=x,y,z,t

Systems of spacetime coordinates are:X=x,y,z,t,Z=z__1,z__2,z__3,z__4

_______________________________________________________

coordinatesystems=X,Z,usecoordinatesastensorindices=true

(42)

p1 = px

p__x=p__x

(43)

p4 = pt

Ec=Ec

(44)

You can get all the covariant and contravariant components by respectively using the following shortcut notation

p

pμ=p__xp__yp__zEc

(45)

p~

p~mu=p__xp__yp__zEc

(46)

The indexing keywords valid for all the pre-defined tensors of Physics, definition, determinant, nonzero, and trace, can also be used for tensors you define using tensorial equations

pdefinition

pμ=p__x,p__y,p__z,Ec

(47)

pnonzero

pμ=1=p__x,2=p__y,3=p__z,4=Ec

(48)

The trace and determinant keywords are only for tensors with two indices. To illustrate this, first define a tensor by indicating a 2x2 generic matrix

Fmu,nu = Matrix4,symbol=F

Fμ,ν=F1,1F1,2F1,3F1,4F2,1F2,2F2,3F2,4F3,1F3,2F3,3F3,4F4,1F4,2F4,3F4,4

(49)

Define

Defined objects with tensor properties

Aμ,γμ,Fμ,ν,σμ,μ,gμ,ν,pμ,εα,β,μ,ν,Xμ,Zμ

(50)

F~

F~mu,~nu=F1,1F1,2F1,3F1,4F2,1F2,2F2,3F2,4F3,1F3,2F3,3F3,4F4,1F4,2F4,3F4,4

(51)

Fmu,mu = Ftrace

Fμμμμ=F1,1F2,2F3,3+F4,4

(52)

Fdeterminant

F1,1F2,2F3,3F4,4F1,1F2,2F3,4F4,3F1,1F2,3F3,2F4,4+F1,1F2,3F3,4F4,2+F1,1F2,4F3,2F4,3F1,1F2,4F3,3F4,2F1,2F2,1F3,3F4,4+F1,2F2,1F3,4F4,3+F1,2F2,3F3,1F4,4F1,2F2,3F3,4F4,1F1,2F2,4F3,1F4,3+F1,2F2,4F3,3F4,1+F1,3F2,1F3,2F4,4F1,3F2,1F3,4F4,2F1,3F2,2F3,1F4,4+F1,3F2,2F3,4F4,1+F1,3F2,4F3,1F4,2F1,3F2,4F3,2F4,1F1,4F2,1F3,2F4,3+F1,4F2,1F3,3F4,2+F1,4F2,2F3,1F4,3F1,4F2,2F3,3F4,1F1,4F2,3F3,1F4,2+F1,4F2,3F3,2F4,1

(53)


To work with the determinant without having it computed you can use the inert version of the tensor and activate the computation only when that is desired using value

%Fdeterminant

%Fdeterminant

(54)

value

F1,1F2,2F3,3F4,4F1,1F2,2F3,4F4,3F1,1F2,3F3,2F4,4+F1,1F2,3F3,4F4,2+F1,1F2,4F3,2F4,3F1,1F2,4F3,3F4,2F1,2F2,1F3,3F4,4+F1,2F2,1F3,4F4,3+F1,2F2,3F3,1F4,4F1,2F2,3F3,4F4,1F1,2F2,4F3,1F4,3+F1,2F2,4F3,3F4,1+F1,3F2,1F3,2F4,4F1,3F2,1F3,4F4,2F1,3F2,2F3,1F4,4+F1,3F2,2F3,4F4,1+F1,3F2,4F3,1F4,2F1,3F2,4F3,2F4,1F1,4F2,1F3,2F4,3+F1,4F2,1F3,3F4,2+F1,4F2,2F3,1F4,3F1,4F2,2F3,3F4,1F1,4F2,3F3,1F4,2+F1,4F2,3F3,2F4,1

(55)

The matrix keyword shows the matrix form that corresponds to the indicated indices, which is particularly useful when the indices are a mixture of covariant and contravariant

F~mu,nu,matrix

F~mu,ν=F1,1F1,2F1,3F1,4F2,1F2,2F2,3F2,4F3,1F3,2F3,3F3,4F4,1F4,2F4,3F4,4

(56)

 

All these keywords work the same way in the case of a curved spacetime.

 

You can redefine any tensor component using Library:-RedefineTensorComponent, for example redefine F2,1=F1,2

Library:-RedefineTensorComponentF2,1 = F1,2

Fμ,ν=F1,1F1,2F1,3F1,4F1,2F2,2F2,3F2,4F3,1F3,2F3,3F3,4F4,1F4,2F4,3F4,4

(57)

When you define a tensor you can also minimize the number of its independent components all in one go. Consider for instance redoing the definition of Fμ,ν, this time indicating that it is antisymmetric and minimizing the amount of independent components by taking that fact into account

Define, antisymmetric, minimizetensorcomponents

Defined objects with tensor properties

Aμ,γμ,Fμ,ν,σμ,μ,gμ,ν,pμ,εα,β,μ,ν,Xμ,Zμ

(58)

F

Fμ,ν=0F1,2F1,3F1,4F1,20F2,3F2,4F1,3F2,30F3,4F1,4F2,4F3,40

(59)

Library:-NumberOfIndependentTensorComponentsF

6

(60)
• 

Defining tensors that represent tensorial expressions

 

One of the most useful features of defining tensors using tensorial equations is that the right-hand side of the equation can be any desired tensorial expression, not just a list or table of components. For example, at this point we have defined the tensor Aμ

Library:-TensorComponentsAμ

A1,A2,A3,A4

(61)

Taking Aμ to represent the 4D potential in electrodynamics, the corresponding electromagnetic field is

Fmu,nu = 2 Antisymmetrized_muAnuX

Fμ,ν=μAνXνAμX

(62)

To have a compact display that avoids redundancy use CompactDisplay

CompactDisplayAX

Ax,y,z,twill now be displayed asA

(63)

Now redo the definition of Fμ,ν using (62)

Defineredo,,minimizetensorcomponents

Defined objects with tensor properties

Aμ,γμ,Fμ,ν,σμ,μ,gμ,ν,pμ,εα,β,μ,ν,Xμ,Zμ

(64)

 

F

Fμ,ν=0xA2x,y,z,tyA1x,y,z,txA3x,y,z,tzA1x,y,z,txA4x,y,z,ttA1x,y,z,tyA1x,y,z,txA2x,y,z,t0yA3x,y,z,tzA2x,y,z,tyA4x,y,z,ttA2x,y,z,tzA1x,y,z,txA3x,y,z,tzA2x,y,z,tyA3x,y,z,t0zA4x,y,z,ttA3x,y,z,ttA1x,y,z,txA4x,y,z,ttA2x,y,z,tyA4x,y,z,ttA3x,y,z,tzA4x,y,z,t0

(65)

Note that the derivatives - constructed using the diff command - are compactly displayed in index notation.

Another common situation where defining a tensor by using a tensorial expression is useful is constructing a traceless tensor from a given one. For example, in the case of a tensor with 2 indices Cα,β,

Cα,β=Matrix4,symbol=C

Cα,β=C1,1C1,2C1,3C1,4C2,1C2,2C2,3C2,4C3,1C3,2C3,3C3,4C4,1C4,2C4,3C4,4

(66)

Define

Defined objects with tensor properties

Aμ,Cα,β,γμ,Fμ,ν,σμ,μ,gμ,ν,pμ,εα,β,μ,ν,Xμ,Zμ

(67)

Tα, β = Cα, β  Cμ,μg_α, β4

Tα,β=Cα,βgα,βCμμμμ4

(68)

Define

Defined objects with tensor properties

Aμ,Cα,β,γμ,Fμ,ν,σμ,Tα,β,μ,gμ,ν,pμ,εα,β,μ,ν,Xμ,Zμ

(69)

T

Tμ,ν=34C1,114C2,214C3,3+14C4,4C1,2C1,3C1,4C2,134C2,214C1,114C3,3+14C4,4C2,3C2,4C3,1C3,234C3,314C1,114C2,2+14C4,4C3,4C4,1C4,2C4,334C4,4+14C1,1+14C2,2+14C3,3

(70)

Talpha, alpha = Ttrace

Tαααα=0

(71)

 

Automatic formatting of repeated tensor indices and handling of their collisions in products

 

The distinction between covariant and contravariant indices in the input of tensors is made by prefixing contravariant indices with ~, as in ~mu. In the output, contravariant indices are displayed as superscripts. However, for contracted tensor indices it is not relevant which one is covariant and which one contravariant. Taking advantage of that, contracted indices can both be entered (input) as covariant, in which case they will be automatically rewritten as one covariant and one contravariant. You can override this behavior by indicating which index you want to be contravariant in the output

 

restart;withPhysics:

 

Define two tensors

DefineAmu, Bmu

Defined objects with tensor properties

Aμ,Bμ,γμ,σμ,μ,gμ,ν,εα,β,μ,ν

(72)

The contraction of A with itself and with B can be entered with all repeated indices as covariant - the output shows these indices reformatted appropriately

Amu2

AμAμμ

(73)

Amu Bmu

AμBμμ

(74)

Entering all the repeated indices as covariant not only removes the burden of having to type one index as contravariant each time there is a contraction, it also automatically results in a normal form for a contraction that the system remembers, so the indices are always reformatted in the same way.

 

In cases where the choice, made by the system, of which index is contravariant is not the one you prefer, you can override the system's choice by indicating your preference using ~ to prefix the contravariant index. For example

A~mu Bmu

AμμBμ

(75)
• 

Automatic handling of collisions of contracted indices in products 

Consider two tensorial expressions, say E__1 and E__2, that have the same contracted indices, for example (74) and (75) 

E__1  

E__1AμBμμ

(76)

E__2  

E__2AμμBμ

(77)

If you multiply E__1E__2 there shouldn't be any problem. However, from the point of view of the summation rule for repeated indices the index μ would be repeated four times, which is incorrect; we say this is a case of collision of indices in products. These cases are handled automatically by replacing the (dummy) repeated indices in one of the factors such that every contracted index is repeated only once.  For example, we see in the following input/output that the repeated index μ in E__2 is replaced by ν

E__1  E__2

AμBμμAννBν

(78)

This expression now has two pairs of repeated indices and checks out

Check

The repeated and free indices in the given expression check ok.

(79)

Therefore, multiplying it by itself should not be a problem

 

2

AμBμμAννBνAαBααAββBβ

(80)

Check

The repeated and free indices in the given expression check ok.

(81)

Note that a collision of indices in products can also happen between a free index in one factor and a repeated index in another factor. Those cases are also handled automatically, for example

E__1

AμBμμ

(82)

Amu  E__1

AμAνBνν

(83)

When introducing replacements to resolve the collision of repeated indices in products, special care is taken such that the introduced indices:

are of the same kind as the ones being replaced;

were not already present in the expression where they are being introduced;


To prevent the system from introducing a certain index, say ν, before multiplying E__1E__2 you can assign it to _Env_Physics_indices_in_use

_Env_Physics_indices_in_use  nu

_Env_Physics_indices_in_useν

(84)

Now you have

E__1  E__2

AμBμμAααBα

(85)

_Env_Physics_indices_in_use  nu, alpha

_Env_Physics_indices_in_useν,α

(86)

E__1  E__2

AμBμμAββBβ

(87)

Tensor symmetries

 

Your definition of a tensor can include symmetries and antisymmetries for its indices. For a totally symmetric or antisymmetric tensor it suffices to add the corresponding keyword symmetric or antisymmetric.

restart;withPhysics:

DefineBmu,nu, symmetric

Defined objects with tensor properties

Bμ,ν,γμ,σμ,μ,gμ,ν,εα,β,μ,ν

(88)

When defining a tensor this way, without passing a tensorial equation or the keyword minimizetensorcomponents, the symmetry indicated is not automatically taken into account. That allows for further abstract manipulations, and when you want the symmetry to be taken into account you can use Simplify

Bmu,nu  Bnu,mu

Bμ,νBν,μ

(89)

Simplify

0

(90)

Alternatively, by passing the keyword minimizetensorcomponents the symmetry indicated is automatically taken into account

DefineBmu,nu, symmetric,minimizetensorcomponents

Defined objects with tensor properties

Bμ,ν,γμ,σμ,μ,gμ,ν,εα,β,μ,ν

(91)

Bmu,nu  Bnu,mu

0

(92)

Consider now a tensor with four indices Rα,β,μ,ν which has the symmetries of the Riemann tensor. This tensor is antisymmetric with respect to interchanging the positions ofαβ or μν, and symmetric with respect to interchanging the positions of the 1st and 2nd pairs of indicesα,β ↔ μ,ν. You can indicate these symmetries by specifying the indices themselves or their numerical position

DefineRα,β,μ,ν, symmetric = α,β, μ,ν, antisymmetric = α,β,μ,ν

Defined objects with tensor properties

Bμ,ν,γμ,σμ,Rα,β,μ,ν,μ,gμ,ν,εα,β,μ,ν

(93)

To retrieve the symmetries of a tensor, use Library:-GetTensorSymmetryProperties

Library:-GetTensorSymmetryPropertiesR

1,2,3,4,1,2,3,4

(94)

 

Redoing the definition of Rα,β,μ,ν, this time using minimizetensorcomponents, allows, among other things, for counting of the number of independent components of R

DefineRα,β,μ,ν, symmetric = α,β, μ,ν, antisymmetric = α,β,μ,ν,minimizetensorcomponents

Defined objects with tensor properties

Bμ,ν,γμ,σμ,Rμ,ν,α,β,μ,gμ,ν,εα,β,μ,ν

(95)

Out of the 44=256 components only 21 are independent, due to the symmetries indicated

Library:-NumberOfIndependentTensorComponentsR

21

(96)

In the case of the Riemann tensor, taking into account the first Bianchi identity, this number is further reduced to 20.

 

• 

Traceless tensors

 

As previously mentioned, you can use tensorial equations to define tensors representing arbitrary tensorial expressions that involve other tensors. A more advanced example of that is the construction of a traceless version of Rα,β,μ,ν, the tensor with the symmetries of the Riemann tensor defined in the previous section. For this tensor, the sum over any possible pair of repeated indices (contraction of two indices) returns 0. The formula used is the same as the one used to define the Weyl tensor in terms of the Riemann and Ricci tensors

Weyldefinition

Cα,β,μ,ν=Rα,β,μ,νRα,μgβ,ν2+Rα,νgβ,μ2+Rβ,μgα,ν2Rβ,νgα,μ2+gα,μgβ,ν6gα,νgβ,μ6Rκκκκ

(97)

Converting it to Riemann, without evaluating tensors, and substituting Riemann with R and Weyl with W, you get

subsRiemann=R, Weyl=W,convertWeyldefinition,Riemann,only=Ricci,evaluatetensor=false

Wα,β,μ,ν=Rα,β,μ,νRκα,κ,μκα,κ,μgβ,ν2+Rκα,κ,νκα,κ,νgβ,μ2+Rκβ,κ,μκβ,κ,μgα,ν2Rκβ,κ,νκβ,κ,νgα,μ2+gα,μgβ,ν6gα,νgβ,μ6Rλκ,λκλκ,λκ

(98)

Now define Wα,β,μ,ν using this tensorial equation

Define, minimizetensorcomponents

Defined objects with tensor properties

Bμ,ν,γμ,σμ,Rμ,ν,α,β,Wα,β,μ,ν,μ,gμ,ν,εα,β,μ,ν

(99)

While the number of independent components of R is 21, W only has the expected 10 and is traceless

Library:-NumberOfIndependentTensorComponentsW

10

(100)

Wαα,μ,ναα,μ,ν

0

(101)
• 

Symmetrization and Antisymmetrization of tensors

 

You can create new tensorial expressions by symmetrizing or antisymmetrizing existing tensors or tensorial expressions, with respect to all or part of their free indices. The resulting tensorial expressions can be used to define new tensors with the corresponding symmetries. For example, construct a tensorial expression by symmetrizing Wα,β,μ,ν with respect to αμ and antisymmetrizing the result with respect to βμ, then define a new tensor Uα,β,μ,ν using the resulting tensorial expression. Note that Uα,β,μ,ν  will also have the symmetries and tracelessness of Wα,β,μ,ν.

SymmetrizeWα,β,μ,ν,α,μ

Wα,β,μ,ν2Wβ,μ,α,ν2

(102)

Uα,β,μ,ν=Antisymmetrize,β,μ

Uα,β,μ,ν=Wα,β,μ,ν4Wβ,μ,α,ν2Wα,μ,β,ν4

(103)

Define,minimizetensorcomponents

Defined objects with tensor properties

Bμ,ν,γμ,σμ,Rμ,ν,α,β,Uα,β,μ,ν,Wα,β,μ,ν,μ,gμ,ν,εα,β,μ,ν

(104)

The number of independent tensor components of Uα,β,μ,ν is

Library:-NumberOfIndependentTensorComponentsU

8

(105)

Substituting tensors and tensor indices

 

Two common operations with tensorial expressions are substituting tensors and substituting tensor indices. The Physics commands for these purposes are SubstituteTensor and SubstituteTensorIndices.

 

restart; withPhysics:

DefineA,B,C,F,G

Defined objects with tensor properties

A,B,C,F,G,γμ,σμ,μ,gμ,ν,εα,β,μ,ν

(106)

EQAμ=Gν,αAαFμ,ν

EQAμ=Gν,αAααFμνμν

(107)

The repeated and free indices of the left and right-hand sides of this equation are

CheckEQ,all

The repeated indices per term are: ...,...,..., the free indices are: ...

,μ=α,ν,μ

(108)

The easy case: using EQ to substitute Aμin Aμ itself

SubstituteTensorEQ,Aμ

Gν,αAααFμνμν

(109)

The same operation, but now the free index in the target expression is ν instead of μ

SubstituteTensorEQ,Aν

Gβ,αAααFνβνβ

(110)

The same operation, but now the target is Aνν

SubstituteTensorEQ,Aνν

Gβ,αAααFν,βν,β

(111)

An example where the index ν, which is repeated in the right-hand side of EQ, is also repeated in the target expression:

eeAνAν

eeAνAνν

(112)

The collision of indices is resolved automatically

resSubstituteTensorEQ,ee

resGλ,κAκκFνλνλGβ,αAααFν,βν,β

(113)

The repeated and free indices of this result are

Checkres,all

The repeated indices per term are: ...,...,..., the free indices are: ...

α,β,κ,λ,ν,

(114)

The functionality of tensor functions is also considered a parameter when substituting tensors. For example, consider the following substitution equation

EQ__2  AμX=BμX

EQ__2AμX=BμX

(115)

Now substitute in AνY

SubstituteTensorEQ__2, AνY

BνY

(116)

SubstituteTensor also substitutes sub-expressions like algsubs. For example

EQ__3AμXBνY=Gμ,νX

EQ__3AμXBνY=Gμ,νX

(117)

The target expression is

AαXBβYAρXBρY

AαXBβYAρXBρρY

(118)

When substituting EQ__3 into (118), the sub-expression AB appears twice, once with repeated indices and once without, and is not part of the indeterminates of (118)

indets

X,Y,AαX,AρX,BβY,BρρY

(119)

SubstituteTensorEQ__3, 

Gα,βXGρρρρX

(120)
• 

Tensor indices can be substituted in a similar way

 

Consider the following target tensorial expression

ee__1  g_α,μA~mug_~alpha,~nuCν,σ,~rho

ee__1gα,μAμμgα,να,νCν,σρν,σρ

(121)

Checkee__1,all

The repeated indices per term are: ...,...,..., the free indices are: ...

α,μ,ν,σ,~rho

(122)

Substitute the repeated index α that appears in covariant and contravariant forms in ee__1

SubstituteTensorIndicesα=β, ee__1

gβ,μAμμgβ,νβ,νCν,σρν,σρ

(123)

Now substitute the contravariant index ~ρ= ~β : a) you don't need to prefix contravariant indices with ~ in the substitution equations; and b) the index β already exists as a dummy (repeated) index in the target expression; you don't need to be concerned with that, this kind of collision of indices is also handled automatically

SubstituteTensorIndicesρ = β,ee__1

gα,μAμμgα,να,νCν,σβν,σβ

(124)

To substitute several indices at once, enclose the substitution equations in a set or a list

SubstituteTensorIndicesρ=β,α=γ,ee__1

gγ