SubstituteTensorIndices - Maple Help

Physics[SubstituteTensorIndices] - perform substitution of covariant/contravariant tensor indices in tensorial expressions

 Calling Sequence SubstituteTensorIndices(mu = .., ... expression)

Parameters

 expression - any algebraic tensorial expression typically having some free and some repeated indices mu = ... - the substitution equation, or a set {...} or list [...] of them evaluatetensor = ... - optional - can be true (default) or false, to indicate whether to evaluate the tensors after substituting on them evaluateexpression = ... - optional - can be true or false (default), to indicate whether to evaluate expression after substituting the indices in its tensors covariantandcontravariant = ... - optional - can be true (default) or false, to indicate whether to substitute both covariant and contravariant indices when only one of them is given on the left-hand sides of the substitution equations

Description

 • The SubstituteTensorIndices substitutes indices in tensors - the ones displayed when you enter Define(); see Define to define one. Nowhere else are the indices substituted, and the substitution can be performed on a covariant index, the corresponding contravariant one, or on both.
 • The first argument is a substitution equation with an index on the left-hand side, or a set or list of them. All the substitution equations are expected in this first argument. The second argument is the target, where the substitutions are to be performed.
 • The tensors where indices are substituted are re-evaluated after substitution; this re-evaluation can optionally be suppressed giving the argument evaluatetensor = false. The expression where these re-evaluated tensors are introduce is by default not re-evaluated; you can change that passing the optional argument evaluateexpression = true.
 • By default both covariant and contravariant indices are substituted, even if the substitution equation has only one of them on the left-hand side; this behavior is convenient both when substituting contracted or free indices. To substitute only the kind of index found on the left-hand side of the substitution equation use covariantandcontravariant = false.
 • To check and determine the free and repeated indices of an expression use Check.
 • When substituting indices by numerical values, contravariant values are prefixed with ~, say as in ~1; otherwise, say as in 1, the value is interpreted as covariant. Hence, the equation ~nu = 1 will also transform ~nu into covariant. Substituting the natural way, say as in nu = 1, will automatically substitute both nu = 1 and also ~nu = ~1 keeping the covariant/contravariant character unchanged.
 • When the right-hand side of a substitution equation is a contravariant index, so suffixed with ~, say as in ~nu = ~1, note the separation between = and ~; that separation is important because ~ is also the element-wise operator and so =~ has other specific meaning.

Examples

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

Define a couple of arbitrary spacetime tensors for exploration purposes

 > $\mathrm{Define}\left(A,B\right)$
 $\mathrm{Defined objects with tensor properties}$
 $\left\{{A}{,}{B}{,}{{\mathrm{\gamma }}}_{{\mathrm{\mu }}}{,}{{\mathrm{\sigma }}}_{{\mathrm{\mu }}}{,}{{\partial }}_{{\mathrm{\mu }}}{,}{{g}}_{{\mathrm{\mu }}{,}{\mathrm{\nu }}}{,}{{\mathrm{\epsilon }}}_{{\mathrm{\alpha }}{,}{\mathrm{\beta }}{,}{\mathrm{\mu }}{,}{\mathrm{\nu }}}\right\}$ (2)

Enter, for example, this tensorial expression, with a contravariant free index $\mathrm{\rho }$

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

To check the repeated and free indices in an expression use Check

 > $\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{\mu }}{,}{\mathrm{\nu }}\right\}\right]{,}\left\{{\mathrm{\sigma }}{,}{\mathrm{~rho}}\right\}$ (4)

So (3) has $\mathrm{\alpha }$ and the contravariant $\mathrm{\rho }$ as free indices. Substitute now $\mathrm{\alpha }=\mathrm{\beta }$: the standard subs command will only substitute the covariant $\mathrm{\alpha }$

 > $\mathrm{subs}\left(\mathrm{\alpha }=\mathrm{\beta },\right)$
 ${{g}}_{{\mathrm{\beta }}{,}{\mathrm{\mu }}}{}{{A}}_{\phantom{{}}\phantom{{\mathrm{\mu }}}}^{\phantom{{}}{\mathrm{\mu }}}{}{{g}}_{\phantom{{}}\phantom{{\mathrm{\alpha }}}\phantom{{,}}\phantom{{\mathrm{\nu }}}}^{\phantom{{}}{\mathrm{\alpha }}{,}{\mathrm{\nu }}}{}{{B}}_{{\mathrm{\nu }}{,}{\mathrm{\sigma }}\phantom{{\mathrm{\rho }}}}^{\phantom{{\mathrm{\nu }}}\phantom{{,}{\mathrm{\sigma }}}{\mathrm{\rho }}}$ (5)

Consequently, the resulting expression is not equivalent to (3): it now has four free 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{\mu }}{,}{\mathrm{\nu }}\right\}\right]{,}\left\{{\mathrm{\beta }}{,}{\mathrm{\sigma }}{,}{\mathrm{~alpha}}{,}{\mathrm{~rho}}\right\}$ (6)

To substitute both covariant and contravariant repeated indices obtaining an expression equivalent to original one use

 > $\mathrm{SubstituteTensorIndices}\left(\mathrm{\alpha }=\mathrm{\beta },\right)$
 ${{g}}_{{\mathrm{\beta }}{,}{\mathrm{\mu }}}{}{{A}}_{\phantom{{}}\phantom{{\mathrm{\mu }}}}^{\phantom{{}}{\mathrm{\mu }}}{}{{g}}_{\phantom{{}}\phantom{{\mathrm{\beta }}}\phantom{{,}}\phantom{{\mathrm{\nu }}}}^{\phantom{{}}{\mathrm{\beta }}{,}{\mathrm{\nu }}}{}{{B}}_{{\mathrm{\nu }}{,}{\mathrm{\sigma }}\phantom{{\mathrm{\rho }}}}^{\phantom{{\mathrm{\nu }}}\phantom{{,}{\mathrm{\sigma }}}{\mathrm{\rho }}}$ (7)
 > $\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{\beta }}{,}{\mathrm{\mu }}{,}{\mathrm{\nu }}\right\}\right]{,}\left\{{\mathrm{\sigma }}{,}{\mathrm{~rho}}\right\}$ (8)

Substitute now the contravariant $\mathrm{\rho }$ by $\mathrm{\tau }$; the standard subs command will fail because contravariant indices are prefixed by ~, so this returns (3) as given

 > $\mathrm{subs}\left(\mathrm{\rho }=\mathrm{\beta },\right)$
 ${{g}}_{{\mathrm{\alpha }}{,}{\mathrm{\mu }}}{}{{A}}_{\phantom{{}}\phantom{{\mathrm{\mu }}}}^{\phantom{{}}{\mathrm{\mu }}}{}{{g}}_{\phantom{{}}\phantom{{\mathrm{\alpha }}}\phantom{{,}}\phantom{{\mathrm{\nu }}}}^{\phantom{{}}{\mathrm{\alpha }}{,}{\mathrm{\nu }}}{}{{B}}_{{\mathrm{\nu }}{,}{\mathrm{\sigma }}\phantom{{\mathrm{\rho }}}}^{\phantom{{\mathrm{\nu }}}\phantom{{,}{\mathrm{\sigma }}}{\mathrm{\rho }}}$ (9)

To make it work with subs you would need to substitute ~rho = ~beta instead. Using SubstituteTensorIndices you get the desired result regardless of this subtlety

 > $\mathrm{SubstituteTensorIndices}\left(\mathrm{\rho }=\mathrm{\beta },\right)$
 ${{g}}_{{\mathrm{\alpha }}{,}{\mathrm{\mu }}}{}{{A}}_{\phantom{{}}\phantom{{\mathrm{\mu }}}}^{\phantom{{}}{\mathrm{\mu }}}{}{{g}}_{\phantom{{}}\phantom{{\mathrm{\alpha }}}\phantom{{,}}\phantom{{\mathrm{\nu }}}}^{\phantom{{}}{\mathrm{\alpha }}{,}{\mathrm{\nu }}}{}{{B}}_{{\mathrm{\nu }}{,}{\mathrm{\sigma }}\phantom{{\mathrm{\beta }}}}^{\phantom{{\mathrm{\nu }}}\phantom{{,}{\mathrm{\sigma }}}{\mathrm{\beta }}}$ (10)
 > $\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{\mu }}{,}{\mathrm{\nu }}\right\}\right]{,}\left\{{\mathrm{\sigma }}{,}{\mathrm{~beta}}\right\}$ (11)

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

 > $\mathrm{SubstituteTensorIndices}\left(\left[\mathrm{\rho }=\mathrm{\beta },\mathrm{\alpha }=\mathrm{\gamma }\right],\right)$
 ${{g}}_{{\mathrm{\gamma }}{,}{\mathrm{\mu }}}{}{{A}}_{\phantom{{}}\phantom{{\mathrm{\mu }}}}^{\phantom{{}}{\mathrm{\mu }}}{}{{g}}_{\phantom{{}}\phantom{{\mathrm{\gamma }}}\phantom{{,}}\phantom{{\mathrm{\nu }}}}^{\phantom{{}}{\mathrm{\gamma }}{,}{\mathrm{\nu }}}{}{{B}}_{{\mathrm{\nu }}{,}{\mathrm{\sigma }}\phantom{{\mathrm{\beta }}}}^{\phantom{{\mathrm{\nu }}}\phantom{{,}{\mathrm{\sigma }}}{\mathrm{\beta }}}$ (12)

After substituting, tensors are re-evaluated; in this example, $\mathrm{\nu }$ becomes 1 and the normalized form of g_ is presented with it in the first place, so switching places with $\mathrm{\mu }$

 > $\mathrm{g_}\left[\mathrm{\mu },\mathrm{\nu }\right]$
 ${{g}}_{{\mathrm{\mu }}{,}{\mathrm{\nu }}}$ (13)
 > $\mathrm{SubstituteTensorIndices}\left(\mathrm{\nu }=1,\right)$
 ${{g}}_{{1}{,}{\mathrm{\mu }}}$ (14)

To avoid this re-evaluation of tensors in the result use evaluatetensor = false

 > $\mathrm{SubstituteTensorIndices}\left(\mathrm{\nu }=1,,\mathrm{evaluatetensor}=\mathrm{false}\right)$
 ${{g}}_{{\mathrm{\mu }}{,}{1}}$ (15)
 > 

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[SubstituteTensorIndices] command was introduced in Maple 16.