A Complete Guide for performing Tensors computations using Physics


This is an old request, a complete guide for using Physics  to perform tensor computations. This guide, shown below with Sections closed, is linked at the end of this post as a pdf file with all the sections open, and also as a Maple worksheet that allows for reproducing its contents. Most of the computations shown are reproducible in Maple 2018.2.1, and a significant part also in previous releases, but to reproduce everything you need to have the Maplesoft Physics Updates version 283 or higher installed. Feedback one how to improve this presentation is welcome.


Physics  is a package developed by Maplesoft, an integral part of the Maple system. In addition to its commands for Quantum Mechanics, Classical Field Theory and General Relativity, Physics  includes 5 other subpackages, three of them also related to General Relativity: Tetrads , ThreePlusOne  and NumericalRelativity (work in progress), plus one to compute with Vectors  and another related to the Standard Model (this one too work in progress).


The presentation is organized as follows. Section I is complete regarding the functionality provided with the Physics package for computing with tensors  in Classical and Quantum Mechanics (so including Euclidean spaces), Electrodynamics and Special Relativity. The material of section I is also relevant in General Relativity, for which section II is all devoted to curved spacetimes. (The sub-section on the Newman-Penrose formalism needs to be filled with more material and a new section devoted to the EnergyMomentum tensor is appropriate. I will complete these two things as time permits.) Section III is about transformations of coordinates, relevant in general.


For an alphabetical list of the Physics commands with a brief one-line description and a link to the corresponding help page see Physics: Brief description of each command .


I. Spacetime and tensors in Physics



This section contains all what is necessary for working with tensors in Classical and Quantum Mechanics, Electrodynamics and Special Relativity. 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


Tensors, their definition, symmetries and operations



Physics comes with a set of predefined tensors, mainly the spacetime metric  g[mu, nu], the space metric  gamma[j, k], and all the standard tensors of  General Relativity. 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 indicating any generic tensorial expression involving other tensors.


In Maple, tensor indices are letters, as when computing with paper and pencil, lowercase or upper case, latin or greek, entered using indexation, as in A[mu], and are displayed as subscripts as in A[mu]. Contravariant indices are entered preceding the letter with ~, as in A[`~μ`], and are displayed as superscripts as in A[`~mu`]. 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 mu, or simpler: use the shortcuts for entering Greek characters . Right-click your input and choose Convert To → 2-D Math input to give to your input spelled tensorial expression a textbook high quality typesetting.


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



Passing the tensor being defined, say F[mu, nu], 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 1. and the right-hand side is a tensorial expression - or an Array or Matrix - such that the components of the tensor being defined are equal to the components of the tensorial expression.


After defining a tensor - say A[mu] or F[mu, nu]- you can perform the following operations on algebraic expressions involving them



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, in addition to the items above you can:



Get each tensor component by indexing, say as in A[1] or A[`~1`]


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 in the case of tensors of 2 indices also trace, and determinant.


No need to specify 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 several indices and different symmetries - using Library:-NumberOfTensorComponents .


The first two sections illustrate these two ways of defining a tensor and the features described. The next sections present the existing functionality of the Physics package to compute with tensors.


Defining a tensor passing the tensor itself


Defining a tensor 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




Visualizing tensor components - Library:-TensorComponents and TensorArray


Modifying tensor components - Library:-RedefineTensorComponent


Enhancing the display of tensorial expressions involving tensor functions and derivatives using CompactDisplay


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



Physics comes with a set of predefined tensors, mainly the spacetime metric  g[mu, nu], the space metric  gamma[j, k], and all the standard tensors of general relativity, respectively entered and displayed as: Einstein[mu,nu] = G[mu, nu],    Ricci[mu,nu]  = R[mu, nu], Riemann[alpha, beta, mu, nu]  = R[alpha, beta, mu, nu], Weyl[alpha, beta, mu, nu],  = C[alpha, beta, mu, nu], and the Christoffel symbols   Christoffel[alpha, mu, nu]  = GAMMA[alpha, mu, nu] and Christoffel[~alpha, mu, nu]  = "GAMMA[mu,nu]^(alpha)" respectively of first and second kinds. The Tetrads  and ThreePlusOne  subpackages have other predefined related tensors. This section is thus all about computing with tensors in General Relativity.


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


Setting the spacetime metric indicating the line element or a Matrix


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


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


A conversion network for the tensors of General Relativity


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


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


III. Transformations of coordinates


See Also


Physics , Conventions used in the Physics package , Physics examples , Physics Updates



Download Tensors_-_A_Complete_Guide.mw, or the pdf version with sections open: Tensors_-_A_Complete_Guide.pdf

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

Please Wait...