TensorArray - Maple Help

Physics[TensorArray] - construct an Array that can be indexed to return the values of a tensorial expression

 Calling Sequence TensorArray(expression, ...)

Parameters

 expression - any algebraic tensorial expression having spacetime free indices possibly having also repeated indices implying summation explore - optional, when given, an applet with sliders to give values to the free indices allows for exploration of the tensorial expression; useful when there are more than two free indices freeindices = [...] - optional, the right-hand side is a list indicating the ordering of the free indices in the returned output - relevant when expression involves products and sums of tensors with free indices. output = ... - optional, the right-hand side can be setofequations, listofequations or lineelement (synonym: line_element), to return a set or list of equations where each of the components of the Array is equal to 0, instead of the Array itself, or the line_element when expression is the spacetime metric g_. performmatrixoperations - optional, can be true or false (default), to perform the matrix operations involving Pauli, Dirac or Gell-Mann matrices entering expression as tensors performsumoverrepeatedindices - optional, can be true (default) or false, to perform the sum over repeated tensor indices in the returned result rewriteinmatrixform - optional, can be true or false (default), to rewrite in matrix form (without performing matrix operations) the Pauli, Dirac or Gell-Mann matrices entering expression as tensors simplifier = ... - optional, indicates the simplifier to be used instead; default is none

Description

 • The TensorArray receives a tensorial expression having n free indices, typically involving sums and products, and returns a corresponding n dimensional Array, which can be indexed as a single object to return the values of the tensorial expression for given values of its free indices.
 • To check and determine the free and repeated indices of an expression use Check.
 • The returned Array is constructed taking into account the covariant and contravariant character of each free index in expression. To compute the values of expression you index this array giving values between 1 and the spacetime dimension to the indices.
 • Pauli, Dirac and Gell-Mann matrices, respectively represented by the Psigma Dgamma and StandardModel:-Glambda commands, are implemented as spacetime and SU(3) vectors, where each component represents a matrix. Thus, when computing tensor arrays of components, one can optionally visualize the matrices behind these tensor representations and rewrite in matrix form, or additionally perform the matrix operations involved if any. For this purpose, pass the optional arguments rewriteinmatrixform or performmatrixoperations.
 • By default, in the returned result, summation is explicitly performed over all the repeated indices found in expression, taking into account the covariant/contravariant character of each index. To avoid performing this summation and keep repeated indices not summed pass the optional argument performsumoverrepeatedindices = false.
 • By default, the Array is constructed without simplifying its components; to have them simplified indicate the simplifier on the right-hand-side of the optional argument simplifier = .... A frequently convenient simplification is achieved with simplifier = simplify.
 • When expression involves sums and products of tensors having free indices, the ordering of the free indices in the returned Array is arbitrary. To indicated a desired ordering of these free indices, use the option freeindices = [...] where the list [...] indicates the desired ordering.
 • The array of components of a tensorial expression with at most 2 free indices is all visible on the screen as the output TensorArray. Things are not so simple when that number is 3 or larger, when only a slice of the array of components is shown. To visualize the expression's components in these cases you can use the explore option, which launches an applet that allows for giving values to all but two of the free indices, and shows the 2x2 corresponding slice for the other two, with the ordering shown.

Examples

 > $\mathrm{with}\left(\mathrm{Physics}\right):$
 > $\mathrm{Setup}\left(\mathrm{mathematicalnotation}=\mathrm{true}\right)$
 $\left[{\mathrm{mathematicalnotation}}{=}{\mathrm{true}}\right]$ (1)

Set the spacetime metric to be the Schwarzschild metric and construct an Array for the product of the metric tensor g_ contracted and multiplied with an arbitrary tensor $A$  as in ${g}_{\mathrm{\mu },\mathrm{\rho }}{A}_{}^{\mathrm{\rho }}{A}_{\mathrm{\nu }}$ For this purpose, set first the metric and the coordinates -you can use Setup for that, or because the Schwarzschild metric is known to the system you can directly pass the keyword or an abbreviation of it to the metric g_ to do all in one step

 > $\mathrm{g_}\left[\mathrm{sc}\right]$
 ${}\mathrm{_______________________________________________________}$
 ${}\mathrm{Systems of spacetime coordinates are:}{}\left\{X=\left(r{,}\mathrm{\theta }{,}\mathrm{\phi }{,}t\right)\right\}$
 ${}\mathrm{Default differentiation variables for d_, D_ and dAlembertian are:}{}\left\{X=\left(r{,}\mathrm{\theta }{,}\mathrm{\phi }{,}t\right)\right\}$
 $\mathrm{Setting}\mathrm{lowercaselatin_is}\mathrm{letters to represent}\mathrm{space}\mathrm{indices}$
 ${}\mathrm{The Schwarzschild metric in coordinates}{}\left[r{,}\mathrm{\theta }{,}\mathrm{\phi }{,}t\right]$
 $\mathrm{Parameters:}\left[m\right]$
 $\mathrm{Signature:}\left(\mathrm{- - - +}\right)$
 ${}\mathrm{_______________________________________________________}$
 ${{g}}_{{\mathrm{\mu }}{,}{\mathrm{\nu }}}{=}\left[\right]$ (2)

Define now an arbitrary tensor $A$

 > $\mathrm{Define}\left(A\right)$
 $\mathrm{Defined objects with tensor properties}$
 $\left\{{A}{,}{{▿}}_{{\mathrm{\mu }}}{,}{{\mathrm{\gamma }}}_{{\mathrm{\mu }}}{,}{{\mathrm{\sigma }}}_{{\mathrm{\mu }}}{,}{{R}}_{{\mathrm{\mu }}{,}{\mathrm{\nu }}}{,}{{R}}_{{\mathrm{\mu }}{,}{\mathrm{\nu }}{,}{\mathrm{\alpha }}{,}{\mathrm{\beta }}}{,}{{C}}_{{\mathrm{\mu }}{,}{\mathrm{\nu }}{,}{\mathrm{\alpha }}{,}{\mathrm{\beta }}}{,}{{\partial }}_{{\mathrm{\mu }}}{,}{{g}}_{{\mathrm{\mu }}{,}{\mathrm{\nu }}}{,}{{\mathrm{\gamma }}}_{{i}{,}{j}}{,}{{\mathrm{\Gamma }}}_{{\mathrm{\mu }}{,}{\mathrm{\nu }}{,}{\mathrm{\alpha }}}{,}{{G}}_{{\mathrm{\mu }}{,}{\mathrm{\nu }}}{,}{{\mathrm{\epsilon }}}_{{\mathrm{\alpha }}{,}{\mathrm{\beta }}{,}{\mathrm{\mu }}{,}{\mathrm{\nu }}}{,}{{X}}_{{\mathrm{\mu }}}\right\}$ (3)

Construct now the tensorial expression mentioned

 > $\mathrm{g_}\left[\mathrm{\mu },\mathrm{\rho }\right]A\left[\mathrm{~rho}\right]A\left[\mathrm{\nu }\right]$
 ${{g}}_{{\mathrm{\mu }}{,}{\mathrm{\rho }}}{}{{A}}_{\phantom{{}}\phantom{{\mathrm{\rho }}}}^{\phantom{{}}{\mathrm{\rho }}}{}{{A}}_{{\mathrm{\nu }}}$ (4)

Check the indices

 > $\mathrm{Check}\left(,\mathrm{all}\right)$
 $\mathrm{The repeated indices per term are:}\left[\left\{\mathrm{...}\right\}{,}\left\{\mathrm{...}\right\}{,}\mathrm{...}\right]\mathrm{, the free indices are:}\left\{\mathrm{...}\right\}$
 $\left[\left\{{\mathrm{\rho }}\right\}\right]{,}\left\{{\mathrm{\mu }}{,}{\mathrm{\nu }}\right\}$ (5)

Construct now the tensor-array

 > $T≔\mathrm{TensorArray}\left(\right)$
 ${T}{≔}\left[\right]$ (6)

In the above, the sum over $\mathrm{\rho }$ is performed. With performsumoverrepeatedindices = false the sum is not performed:

 > $\mathrm{TensorArray}\left(,\mathrm{performsumoverrepeatedindices}=\mathrm{false}\right)$
 $\left[\right]$ (7)

Also, in (6) the ordering of the free indices $\mathrm{\mu },\mathrm{\nu }$ is not defined. In the computations above, TensorArray choose the ordering $\left[\mathrm{\mu },\mathrm{\nu }\right]$ but one may prefer, for instance, $\left[\mathrm{\nu },\mathrm{\mu }\right]$, resulting in the transpose of the matrix (8). To indicate any desired ordering you can use the optional argument freeindices = [...]

 > $T≔\mathrm{TensorArray}\left(,\mathrm{freeindices}=\left[\mathrm{\nu },\mathrm{\mu }\right]\right)$
 ${T}{≔}\left[\right]$ (8)

Depending on the context, instead of an Array of components, it is more convenient to receive as a set or list of equations with each of components of the Array equal to 0. For that purpose use the output = setofequations (or listofequations on the right-hand side) option

 > $T≔\mathrm{TensorArray}\left(,\mathrm{freeindices}=\left[\mathrm{\nu },\mathrm{\mu }\right],\mathrm{output}=\mathrm{setofequations}\right)$
 ${T}{≔}\left\{\frac{{{A}}_{{1}}{}{{A}}_{\phantom{{}}\phantom{{1}}}^{\phantom{{}}{1}}{}{r}}{{2}{}{m}{-}{r}}{=}{0}{,}\frac{{{A}}_{{1}}{}{{A}}_{\phantom{{}}\phantom{{4}}}^{\phantom{{}}{4}}{}\left({r}{-}{2}{}{m}\right)}{{r}}{=}{0}{,}\frac{{{A}}_{{2}}{}{{A}}_{\phantom{{}}\phantom{{1}}}^{\phantom{{}}{1}}{}{r}}{{2}{}{m}{-}{r}}{=}{0}{,}\frac{{{A}}_{{2}}{}{{A}}_{\phantom{{}}\phantom{{4}}}^{\phantom{{}}{4}}{}\left({r}{-}{2}{}{m}\right)}{{r}}{=}{0}{,}\frac{{{A}}_{{3}}{}{{A}}_{\phantom{{}}\phantom{{1}}}^{\phantom{{}}{1}}{}{r}}{{2}{}{m}{-}{r}}{=}{0}{,}\frac{{{A}}_{{3}}{}{{A}}_{\phantom{{}}\phantom{{4}}}^{\phantom{{}}{4}}{}\left({r}{-}{2}{}{m}\right)}{{r}}{=}{0}{,}\frac{{{A}}_{{4}}{}{{A}}_{\phantom{{}}\phantom{{1}}}^{\phantom{{}}{1}}{}{r}}{{2}{}{m}{-}{r}}{=}{0}{,}\frac{{{A}}_{{4}}{}{{A}}_{\phantom{{}}\phantom{{4}}}^{\phantom{{}}{4}}{}\left({r}{-}{2}{}{m}\right)}{{r}}{=}{0}{,}{-}{{A}}_{{1}}{}{{r}}^{{2}}{}{{A}}_{\phantom{{}}\phantom{{2}}}^{\phantom{{}}{2}}{=}{0}{,}{-}{{A}}_{{2}}{}{{r}}^{{2}}{}{{A}}_{\phantom{{}}\phantom{{2}}}^{\phantom{{}}{2}}{=}{0}{,}{-}{{A}}_{{3}}{}{{r}}^{{2}}{}{{A}}_{\phantom{{}}\phantom{{2}}}^{\phantom{{}}{2}}{=}{0}{,}{-}{{A}}_{{4}}{}{{r}}^{{2}}{}{{A}}_{\phantom{{}}\phantom{{2}}}^{\phantom{{}}{2}}{=}{0}{,}{-}{{A}}_{{1}}{}{{A}}_{\phantom{{}}\phantom{{3}}}^{\phantom{{}}{3}}{}{{r}}^{{2}}{}{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{=}{0}{,}{-}{{A}}_{{2}}{}{{A}}_{\phantom{{}}\phantom{{3}}}^{\phantom{{}}{3}}{}{{r}}^{{2}}{}{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{=}{0}{,}{-}{{A}}_{{3}}{}{{A}}_{\phantom{{}}\phantom{{3}}}^{\phantom{{}}{3}}{}{{r}}^{{2}}{}{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{=}{0}{,}{-}{{A}}_{{4}}{}{{A}}_{\phantom{{}}\phantom{{3}}}^{\phantom{{}}{3}}{}{{r}}^{{2}}{}{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{=}{0}\right\}$ (9)

In the particular case where the tensorial expression is the spacetime metric, the desired output could be the line element (that you can also get entering g_[lineelement])

 > $\mathrm{TensorArray}\left(\mathrm{g_}\left[\mathrm{\mu },\mathrm{\nu }\right],\mathrm{output}=\mathrm{lineelement}\right)$
 $\frac{{r}{}{{\mathbf{ⅆ}}{}\left({r}\right)}^{{2}}}{{2}{}{m}{-}{r}}{-}{{r}}^{{2}}{}{{\mathbf{ⅆ}}{}\left({\mathrm{\theta }}\right)}^{{2}}{-}{{r}}^{{2}}{}{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{}{{\mathbf{ⅆ}}{}\left({\mathrm{\phi }}\right)}^{{2}}{+}\frac{\left({r}{-}{2}{}{m}\right){}{{\mathbf{ⅆ}}{}\left({t}\right)}^{{2}}}{{r}}$ (10)

Rewrite the Riemann tensor with all its indices covariant in terms of Christoffel symbols and their derivatives and construct a tensor-array for the resulting tensorial expression; in view of the presence of trigonometric functions, use the simplifier option

 > $\mathrm{Riemann}\left[\mathrm{\mu },\mathrm{\nu },\mathrm{\alpha },\mathrm{\beta }\right]$
 ${{R}}_{{\mathrm{\alpha }}{,}{\mathrm{\beta }}{,}{\mathrm{\mu }}{,}{\mathrm{\nu }}}$ (11)
 > $\mathrm{convert}\left(,\mathrm{Christoffel}\right)$
 ${{g}}_{{\mathrm{\alpha }}{,}{\mathrm{\lambda }}}{}\left({{\partial }}_{{\mathrm{\mu }}}{}\left({{\mathrm{\Gamma }}}_{\phantom{{}}\phantom{{\mathrm{\lambda }}}{\mathrm{\beta }}{,}{\mathrm{\nu }}}^{\phantom{{}}{\mathrm{\lambda }}\phantom{{\mathrm{\beta }}{,}{\mathrm{\nu }}}}\right){-}{{\partial }}_{{\mathrm{\nu }}}{}\left({{\mathrm{\Gamma }}}_{\phantom{{}}\phantom{{\mathrm{\lambda }}}{\mathrm{\beta }}{,}{\mathrm{\mu }}}^{\phantom{{}}{\mathrm{\lambda }}\phantom{{\mathrm{\beta }}{,}{\mathrm{\mu }}}}\right){+}{{\mathrm{\Gamma }}}_{\phantom{{}}\phantom{{\mathrm{\lambda }}}{\mathrm{\mu }}{,}{\mathrm{\upsilon }}}^{\phantom{{}}{\mathrm{\lambda }}\phantom{{\mathrm{\mu }}{,}{\mathrm{\upsilon }}}}{}{{\mathrm{\Gamma }}}_{\phantom{{}}\phantom{{\mathrm{\upsilon }}}{\mathrm{\beta }}{,}{\mathrm{\nu }}}^{\phantom{{}}{\mathrm{\upsilon }}\phantom{{\mathrm{\beta }}{,}{\mathrm{\nu }}}}{-}{{\mathrm{\Gamma }}}_{\phantom{{}}\phantom{{\mathrm{\lambda }}}{\mathrm{\nu }}{,}{\mathrm{\upsilon }}}^{\phantom{{}}{\mathrm{\lambda }}\phantom{{\mathrm{\nu }}{,}{\mathrm{\upsilon }}}}{}{{\mathrm{\Gamma }}}_{\phantom{{}}\phantom{{\mathrm{\upsilon }}}{\mathrm{\beta }}{,}{\mathrm{\mu }}}^{\phantom{{}}{\mathrm{\upsilon }}\phantom{{\mathrm{\beta }}{,}{\mathrm{\mu }}}}\right)$ (12)
 > $R≔\mathrm{TensorArray}\left(,\mathrm{simplifier}=\mathrm{simplify}@\mathrm{normal}\right)$

Verify the result comparing $R$, constructed with the definition of Riemann in terms of Christoffel symbols, with the Riemann tensor itself

 > $R\left[1,3,1,3\right]$
 ${-}\frac{{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{}{m}}{{2}{}{m}{-}{r}}$ (13)
 > $\mathrm{Riemann}\left[1,3,1,3\right]$
 ${-}\frac{{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{}{m}}{{2}{}{m}{-}{r}}$ (14)

Compare all the nonzero values of the two arrays: for Riemann, pass the option nonzero, for $R$ use ArrayElems; all the nonzero components are same:

 > $\mathrm{Riemann}\left[\mathrm{nonzero}\right]$
 ${{R}}_{{\mathrm{\alpha }}{,}{\mathrm{\beta }}{,}{\mathrm{\mu }}{,}{\mathrm{\nu }}}{=}\left\{\left({1}{,}{2}{,}{1}{,}{2}\right){=}{-}\frac{{m}}{{2}{}{m}{-}{r}}{,}\left({1}{,}{2}{,}{2}{,}{1}\right){=}\frac{{m}}{{2}{}{m}{-}{r}}{,}\left({1}{,}{3}{,}{1}{,}{3}\right){=}{-}\frac{{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{}{m}}{{2}{}{m}{-}{r}}{,}\left({1}{,}{3}{,}{3}{,}{1}\right){=}\frac{{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{}{m}}{{2}{}{m}{-}{r}}{,}\left({1}{,}{4}{,}{1}{,}{4}\right){=}\frac{{2}{}{m}}{{{r}}^{{3}}}{,}\left({1}{,}{4}{,}{4}{,}{1}\right){=}{-}\frac{{2}{}{m}}{{{r}}^{{3}}}{,}\left({2}{,}{1}{,}{1}{,}{2}\right){=}\frac{{m}}{{2}{}{m}{-}{r}}{,}\left({2}{,}{1}{,}{2}{,}{1}\right){=}{-}\frac{{m}}{{2}{}{m}{-}{r}}{,}\left({2}{,}{3}{,}{2}{,}{3}\right){=}{-}{2}{}{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{}{m}{}{r}{,}\left({2}{,}{3}{,}{3}{,}{2}\right){=}{2}{}{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{}{m}{}{r}{,}\left({2}{,}{4}{,}{2}{,}{4}\right){=}\frac{\left({2}{}{m}{-}{r}\right){}{m}}{{{r}}^{{2}}}{,}\left({2}{,}{4}{,}{4}{,}{2}\right){=}\frac{{-}{2}{}{{m}}^{{2}}{+}{r}{}{m}}{{{r}}^{{2}}}{,}\left({3}{,}{1}{,}{1}{,}{3}\right){=}\frac{{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{}{m}}{{2}{}{m}{-}{r}}{,}\left({3}{,}{1}{,}{3}{,}{1}\right){=}{-}\frac{{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{}{m}}{{2}{}{m}{-}{r}}{,}\left({3}{,}{2}{,}{2}{,}{3}\right){=}{2}{}{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{}{m}{}{r}{,}\left({3}{,}{2}{,}{3}{,}{2}\right){=}{-}{2}{}{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{}{m}{}{r}{,}\left({3}{,}{4}{,}{3}{,}{4}\right){=}\frac{{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{}\left({2}{}{m}{-}{r}\right){}{m}}{{{r}}^{{2}}}{,}\left({3}{,}{4}{,}{4}{,}{3}\right){=}{-}\frac{{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{}\left({2}{}{m}{-}{r}\right){}{m}}{{{r}}^{{2}}}{,}\left({4}{,}{1}{,}{1}{,}{4}\right){=}{-}\frac{{2}{}{m}}{{{r}}^{{3}}}{,}\left({4}{,}{1}{,}{4}{,}{1}\right){=}\frac{{2}{}{m}}{{{r}}^{{3}}}{,}\left({4}{,}{2}{,}{2}{,}{4}\right){=}\frac{{-}{2}{}{{m}}^{{2}}{+}{r}{}{m}}{{{r}}^{{2}}}{,}\left({4}{,}{2}{,}{4}{,}{2}\right){=}\frac{\left({2}{}{m}{-}{r}\right){}{m}}{{{r}}^{{2}}}{,}\left({4}{,}{3}{,}{3}{,}{4}\right){=}{-}\frac{{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{}\left({2}{}{m}{-}{r}\right){}{m}}{{{r}}^{{2}}}{,}\left({4}{,}{3}{,}{4}{,}{3}\right){=}\frac{{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{}\left({2}{}{m}{-}{r}\right){}{m}}{{{r}}^{{2}}}\right\}$ (15)
 > $\mathrm{ArrayElems}\left(R\right)$
 $\left\{\left({1}{,}{2}{,}{1}{,}{2}\right){=}{-}\frac{{m}}{{2}{}{m}{-}{r}}{,}\left({1}{,}{2}{,}{2}{,}{1}\right){=}\frac{{m}}{{2}{}{m}{-}{r}}{,}\left({1}{,}{3}{,}{1}{,}{3}\right){=}{-}\frac{{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{}{m}}{{2}{}{m}{-}{r}}{,}\left({1}{,}{3}{,}{3}{,}{1}\right){=}\frac{{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{}{m}}{{2}{}{m}{-}{r}}{,}\left({1}{,}{4}{,}{1}{,}{4}\right){=}\frac{{2}{}{m}}{{{r}}^{{3}}}{,}\left({1}{,}{4}{,}{4}{,}{1}\right){=}{-}\frac{{2}{}{m}}{{{r}}^{{3}}}{,}\left({2}{,}{1}{,}{1}{,}{2}\right){=}\frac{{m}}{{2}{}{m}{-}{r}}{,}\left({2}{,}{1}{,}{2}{,}{1}\right){=}{-}\frac{{m}}{{2}{}{m}{-}{r}}{,}\left({2}{,}{3}{,}{2}{,}{3}\right){=}{-}{2}{}{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{}{m}{}{r}{,}\left({2}{,}{3}{,}{3}{,}{2}\right){=}{2}{}{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{}{m}{}{r}{,}\left({2}{,}{4}{,}{2}{,}{4}\right){=}\frac{\left({2}{}{m}{-}{r}\right){}{m}}{{{r}}^{{2}}}{,}\left({2}{,}{4}{,}{4}{,}{2}\right){=}\frac{{-}{2}{}{{m}}^{{2}}{+}{r}{}{m}}{{{r}}^{{2}}}{,}\left({3}{,}{1}{,}{1}{,}{3}\right){=}\frac{{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{}{m}}{{2}{}{m}{-}{r}}{,}\left({3}{,}{1}{,}{3}{,}{1}\right){=}{-}\frac{{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{}{m}}{{2}{}{m}{-}{r}}{,}\left({3}{,}{2}{,}{2}{,}{3}\right){=}{2}{}{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{}{m}{}{r}{,}\left({3}{,}{2}{,}{3}{,}{2}\right){=}{-}{2}{}{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{}{m}{}{r}{,}\left({3}{,}{4}{,}{3}{,}{4}\right){=}\frac{{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{}\left({2}{}{m}{-}{r}\right){}{m}}{{{r}}^{{2}}}{,}\left({3}{,}{4}{,}{4}{,}{3}\right){=}{-}\frac{{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{}\left({2}{}{m}{-}{r}\right){}{m}}{{{r}}^{{2}}}{,}\left({4}{,}{1}{,}{1}{,}{4}\right){=}{-}\frac{{2}{}{m}}{{{r}}^{{3}}}{,}\left({4}{,}{1}{,}{4}{,}{1}\right){=}\frac{{2}{}{m}}{{{r}}^{{3}}}{,}\left({4}{,}{2}{,}{2}{,}{4}\right){=}\frac{{-}{2}{}{{m}}^{{2}}{+}{r}{}{m}}{{{r}}^{{2}}}{,}\left({4}{,}{2}{,}{4}{,}{2}\right){=}\frac{\left({2}{}{m}{-}{r}\right){}{m}}{{{r}}^{{2}}}{,}\left({4}{,}{3}{,}{3}{,}{4}\right){=}{-}\frac{{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{}\left({2}{}{m}{-}{r}\right){}{m}}{{{r}}^{{2}}}{,}\left({4}{,}{3}{,}{4}{,}{3}\right){=}\frac{{{\mathrm{sin}}{}\left({\mathrm{\theta }}\right)}^{{2}}{}\left({2}{}{m}{-}{r}\right){}{m}}{{{r}}^{{2}}}\right\}$ (16)
 > $\mathrm{evalb}\left(\mathrm{simplify}\left(\mathrm{rhs}\left(\right)=\right)\right)$
 ${\mathrm{true}}$ (17)

A contraction of the Riemann tensor over two of its indices

 > $\mathrm{Riemann}\left[\mathrm{\alpha },\mathrm{\beta },\mathrm{\mu },\mathrm{\nu }\right]\mathrm{Riemann}\left[\mathrm{~alpha},\mathrm{~beta},\mathrm{~nu},\mathrm{~sigma}\right]$
 ${{R}}_{{\mathrm{\alpha }}{,}{\mathrm{\beta }}{,}{\mathrm{\mu }}{,}{\mathrm{\nu }}}{}{{R}}_{\phantom{{}}\phantom{{\mathrm{\alpha }}{,}{\mathrm{\beta }}{,}{\mathrm{\nu }}{,}{\mathrm{\sigma }}}}^{\phantom{{}}{\mathrm{\alpha }}{,}{\mathrm{\beta }}{,}{\mathrm{\nu }}{,}{\mathrm{\sigma }}}$ (18)
 > $\mathrm{Check}\left(,\mathrm{all}\right)$
 $\mathrm{The repeated indices per term are:}\left[\left\{\mathrm{...}\right\}{,}\left\{\mathrm{...}\right\}{,}\mathrm{...}\right]\mathrm{, the free indices are:}\left\{\mathrm{...}\right\}$
 $\left[\left\{{\mathrm{\alpha }}{,}{\mathrm{\beta }}{,}{\mathrm{\nu }}\right\}\right]{,}\left\{{\mathrm{\mu }}{,}{\mathrm{~σ}}\right\}$ (19)
 > $\mathrm{TensorArray}\left(,\mathrm{simplifier}=\mathrm{simplify}\right)$
 $\left[\right]$ (20)

The output of TensorArray is clear when there are at most 2 free indices. When there are 3 or more free indices, however, while the whole array of components is returned, only a slice of it is displayed. For example, for the Riemann tensor, which for the Schwarzschild metric has non-zero components,

 > $\mathrm{TensorArray}\left(\mathrm{Riemann}\left[\mathrm{\alpha },\mathrm{\beta },\mathrm{\mu },\mathrm{\nu }\right]\right)$

It is not evident which slice of the 4 x 4 x 4 x 4 array of components is being displayed, that is: what indices are being shown in the 4 x 4 matrix, in what order, and what are the values of the indices not being shown. To address these issues, the explore option allows for visualizing the different possible slices of components while making clear which indices are shown, in what order, and what are the values of the indices not shown:

 > $\mathrm{TensorArray}\left(\mathrm{Riemann}\left[\mathrm{\alpha },\mathrm{\beta },\mathrm{\mu },\mathrm{\nu }\right],\mathrm{explore}\right)$
 ${}{R}_{\mathrm{\alpha },\mathrm{\beta },\mathrm{\mu },\mathrm{\nu }}\left(\mathrm{ordering of free indices}=\left[\mathrm{\alpha }{,}\mathrm{\beta }{,}\mathrm{\mu }{,}\mathrm{\nu }\right]\right)$ (21)

 $\mathbf{Index 1}$ $\mathbf{Index 2}$ alphabetamunu alphabetamunu

$\mathbf{Value of Index 1}$

$\mathbf{Value of Index 2}$

In this output we see:

 – In the title, the tensorial expression being explored and an indication of its free indices, as well as the ordering used to produce the display. Note that, for a tensorial expression that is not just a tensor, that ordering is not determined by the expression.
 – Which indices are being explored: Index 1 = alpha and Index 2 = beta, so the 4 x 4 matrix displayed is for the remaining indices $\mathrm{\mu }$ and $\mathrm{\nu }$, in that order (as shown in ordering of free indices = [...] within the title).
 – You can move the slider of each Value of Index to set the values of alpha or beta without having to recompute anything, and the 4 x 4 matrix for $\mathrm{\mu }$ and $\mathrm{\nu }$ is automatically updated.
 – You can actually choose which of the 4 indices will be Index 1 or Index 2 by clicking in the corresponding boxes, and in that way also indirectly select the remaining two indices shown in the 4 x 4 matrix of components, always with the ordering you see in ordering of free indices (after removing Index 1 and Index 2).

When the number of free indices is larger, being able to explore is even more significant. For example, consider a metric for which the Ricci tensor has non-zero components and explore the expression formed by the product of three non-contracted Ricci tensors ${R}_{\mathrm{\alpha },\mathrm{\rho }}{R}_{\mathrm{\beta },\mathrm{\nu }}{R}_{\mathrm{\mu },\mathrm{\sigma }}$

 > $\mathrm{Setup}\left(\mathrm{metric}=-{\mathrm{dt}}^{2}+\frac{{a\left(t\right)}^{2}{\mathrm{dr}}^{2}}{-k{r}^{2}+1}+{a\left(t\right)}^{2}{r}^{2}{\mathrm{dtheta}}^{2}+{a\left(t\right)}^{2}{r}^{2}{\mathrm{sin}\left(\mathrm{\theta }\right)}^{2}{\mathrm{dphi}}^{2}\right):$
 ${}\mathrm{_______________________________________________________}$
 $\mathrm{Coordinates:}\left[r{,}\mathrm{\theta }{,}\mathrm{\phi }{,}t\right]\mathrm{. Signature:}\left(\mathrm{- - - +}\right)$
 ${}\mathrm{_______________________________________________________}$
 ${{g}}_{{\mathrm{\mu }}{,}{\mathrm{\nu }}}{=}\left[\right]$
 ${}\mathrm{_______________________________________________________}$ (22)
 > $\mathrm{g_}\left[\right]$
 ${{g}}_{{\mathrm{\mu }}{,}{\mathrm{\nu }}}{=}\left[\right]$ (23)
 > $\mathrm{TensorArray}\left(\mathrm{Ricci}\left[\mathrm{\alpha },\mathrm{\rho }\right]\mathrm{Ricci}\left[\mathrm{\beta },\mathrm{\nu }\right]\mathrm{Ricci}\left[\mathrm{\mu },\mathrm{\sigma }\right],\mathrm{explore}\right)$
 ${}{R}_{\mathrm{\alpha },\mathrm{\rho }}{}{R}_{\mathrm{\beta },\mathrm{\nu }}{}{R}_{\mathrm{\mu },\mathrm{\sigma }}\left(\mathrm{ordering of free indices}=\left[\mathrm{\alpha }{,}\mathrm{\beta }{,}\mathrm{\mu }{,}\mathrm{\nu }{,}\mathrm{\rho }{,}\mathrm{\sigma }\right]\right)$ (24)

 $\mathbf{Index 1}$ $\mathbf{Index 2}$ $\mathbf{Index 3}$ $\mathbf{Index 4}$ alphabetamunurhosigma alphabetamunurhosigma alphabetamunurhosigma alphabetamunurhosigma

$\mathbf{Value of Index 1}$

$\mathbf{Value of Index 2}$

$\mathbf{Value of Index 3}$

$\mathbf{Value of Index 4}$

The Physics package includes representations for the Dirac, Pauli and Gell-Mann matrices. These matrices, respectively represented by Dgamma, Psigma and Glambda, are implemented as tensors in spacetime or the corresponding SU(n) groups. Each tensor component, in turn, also has matrix components, the ones corresponding to the fundamental representation of the group. To visualize the matrix components you can use the option rewriteinmatrixform, or if there are also matrix operations that could be performed, to visualize and perform those operations use the option performmatrixoperations.

As an example, consider the Pauli matrices at this point of the session, with the spacetime set with a curved value. By default the Pauli matrices are implemented as spacetime 4-vectors in a Minkowski flat spacetime. To work with Pauli matrices using tensor notation, and within a curved spacetime, you can set su2indices using Setup and redo the definition of these matrices as a tensor in a SU(2) space (indicating them with su2 indices) using Define and its redo option.

 > $\mathrm{Setup}\left(\mathrm{su2indices}=\mathrm{lowercaselatin_ah}\right)$
 $\left[{\mathrm{su2indices}}{=}{\mathrm{lowercaselatin_ah}}\right]$ (25)
 > $\mathrm{Define}\left(\mathrm{redo},\mathrm{Psigma}\left[a\right]\right)$
 $\mathrm{Defined Pauli sigma matrices \left(Psigma\right):}{\mathrm{\sigma }}_{1},{\mathrm{\sigma }}_{2},{\mathrm{\sigma }}_{3}$
 $\mathrm{__________________________________________________}$
 $\mathrm{Defined objects with tensor properties}$
 $\left\{{{A}}_{\phantom{{}}\phantom{{\mathrm{\rho }}}}^{\phantom{{}}{\mathrm{\rho }}}{,}{{▿}}_{{\mathrm{\mu }}}{,}{{\mathrm{\gamma }}}_{{\mathrm{\mu }}}{,}{{\mathrm{\sigma }}}_{{a}}{,}{{R}}_{{\mathrm{\mu }}{,}{\mathrm{\nu }}}{,}{{R}}_{{\mathrm{\mu }}{,}{\mathrm{\nu }}{,}{\mathrm{\alpha }}{,}{\mathrm{\beta }}}{,}{{C}}_{{\mathrm{\mu }}{,}{\mathrm{\nu }}{,}{\mathrm{\alpha }}{,}{\mathrm{\beta }}}{,}{{\partial }}_{{\mathrm{\mu }}}{,}{{g}}_{{\mathrm{\mu }}{,}{\mathrm{\nu }}}{,}{{\mathrm{\gamma }}}_{{i}{,}{j}}{,}{{\mathrm{\Gamma }}}_{{\mathrm{\mu }}{,}{\mathrm{\nu }}{,}{\mathrm{\alpha }}}{,}{{G}}_{{\mathrm{\mu }}{,}{\mathrm{\nu }}}{,}{{\mathrm{\epsilon }}}_{{\mathrm{\alpha }}{,}{\mathrm{\beta }}{,}{\mathrm{\mu }}{,}{\mathrm{\nu }}}{,}{{X}}_{{\mathrm{\mu }}}\right\}$ (26)

So the spacetime is curved,

 > $\mathrm{g_}\left[\right]$
 ${{g}}_{{\mathrm{\mu }}{,}{\mathrm{\nu }}}{=}\left[\right]$ (27)

and the Pauli matrices now form a SU(2) 3D tensor, with commutator and anticommutator algebras defined in a SU(2) space.

 > $\mathrm{Psigma}\left[\mathrm{definition}\right]$
 ${\left[{{\mathrm{\sigma }}}_{{a}}{,}{{\mathrm{\sigma }}}_{{b}}\right]}_{{-}}{=}{2}{}{I}{}{{\mathrm{\epsilon }}}_{{a}{,}{b}{,}{c}}{}{{\mathrm{\sigma }}}_{{c}}{,}{\left[{{\mathrm{\sigma }}}_{{a}}{,}{{\mathrm{\sigma }}}_{{b}}\right]}_{{+}}{=}{2}{}{{\mathrm{\delta }}}_{{a}{,}{b}}$ (28)

TensorArray can be used to visualize the SU(2) components of these two equations as well as the matrix components of each SU(2) component. For example for the first commutator algebra tensorial equation, the following shows the SU(2) components.

 > $\mathrm{TensorArray}\left(\left[1\right]\right)$
 $\left[\right]$ (29)

Note that in these definitions the commutators are expressed in inert form. To visualize the matrix form of each component you can use rewriteinmatrixform.

 > $\mathrm{TensorArray}\left(\left[1\right],\mathrm{rewriteinmatrixform}\right)$
 $\left[\right]$ (30)

To activate the inert commutators in these equations you can use value.

 > $\mathrm{value}\left(\right)$
 $\left[\right]$ (31)

or indicate value as the simplifier

 > $\mathrm{TensorArray}\left(\left[1\right],\mathrm{rewriteinmatrixform},\mathrm{simplifier}=\mathrm{value}\right)$
 $\left[\right]$ (32)

or use the performmatrixoperations option of TensorArray, whose purpose is not just to rewrite in matrix form but also to perform the resulting matrix operations

 > $\mathrm{TensorArray}\left(\left[1\right],\mathrm{performmatrixoperations},\mathrm{simplifier}=\mathrm{value}\right)$
 $\left[\right]$ (33)

Alternatively, you can compute in steps, for example, first expand the commutators

 > $\mathrm{expand}\left(\right)$
 $\left[\right]$ (34)

To visualize the matrix operations, you can use TensorArray over the result above with its rewriteinmatrixform option, or to additionally perform them use its option performmatrixoperations. Alternatively, you can always call, directly, the corresponding Library commands. For example

 > $\mathrm{Library}:-\mathrm{PerformMatrixOperations}\left(\right)$
 $\left[\right]$ (35)

References

 Landau, L.D., and Lifshitz, E.M. The Classical Theory of Fields, Course of Theoretical Physics Volume 2, fourth revised English edition. Elsevier, 1975.

Compatibility

 • The Physics[TensorArray] command was introduced in Maple 16.