 SubstituteTensor - Maple Help

Physics[SubstituteTensor] - substitute tensor, sums or products of them, in tensorial expression, matching free indices and automatically taking care of possible collisions between repeated indices Calling Sequence SubstituteTensor(EQ, ..., ee, evaluateexpression, repeatedindicescovariant) Parameters

 EQ - a substitution equation, a list or set of them, or a sequence of any of these, typically involving tensors, or sums or products of them, on the left-hand sides, and corresponding tensorial expressions (same free indices) on the right-hand sides ee - the target where the substitutions EQ, ... are to be performed, it is the last argument after the substitution equations; ee can be any Maple object (expression, list, etc.) typically involving tensors or tensorial expressions with free and/or repeated tensor indices, and where subs and eval are able to perform substitutions disregardfreeindices - optional, when given, the substitutions are performed even if the free indices of the left-hand sides are not equal to the free indices of the right-hand sides evaluateexpression - optional, when given, the substitutions in ee are performed using eval instead of subs repeatedindicescovariant - optional, default value is true when the spacetime is Euclidean and false otherwise. When true, all repeated (contracted) indices in the result are returned covariant instead of one covariant and the other contravariant. Description

 • SubstituteTensor substitutes the equation(s) EQ into ee, taking care of free and repeated indices such that:
 – equations in EQ are interpreted as mappings having the free indices as parameters, so for example substituting A[j] = G[j] into A[k] results in G[k];
 – repeated indices in EQ do not clash with repeated indices in ee, so for example substituting A[j] = G[j]*F[k,k] into A[i]*G[k]*G[k] or into A[k]*A[k] respectively results in G[i]*F[m,m]*G[k]*G[k], and G[k]*F[j,j] * G[k]*F[m,m].
 • SubstituteTensor can also substitute sub-expressions of type product or sum, similar to what algsubs does, so for example substituting A[j] * B[k] = F[j, k] into A[i] * B[i] * F[j, k] and into A[i] * B[j] * A[k] * B[m] respectively results in F[i, i] * F[j, k] and F[i, j] * F[k, m].
 Note: when the left-hand-side of a substitution equation is a tensor function (of type Library:-PhysicsType:-Tensor and also of type function), say T[j,k](X), then not just the indices j,k but also the functionality X is considered a parameter, so for example substituting T[j, k](X) = F[j, k](X) into T[i, i](Y) results in F[i, i](Y). The functionality is not considered a parameter when the left-hand-side is an algebraic expression.
 • By default, it is expected that the free indices of the left and right hand sides of the substitution equation(s) are the same, and SubstituteTensor will interrupt with an error message when that doesn't check. When the free indices in both sides of a substitution equation are intentionally different, to avoid that interruption you can use the option disregardfreeindices. Examples

 > $\mathrm{with}\left(\mathrm{Physics}\right):$
 > $\mathrm{Setup}\left(\mathrm{mathematicalnotation}=\mathrm{true}\right)$
 $\left[{\mathrm{mathematicalnotation}}{=}{\mathrm{true}}\right]$ (1)
 > $\mathrm{Define}\left(A,B,C,F,G\right):$
 $\mathrm{Defined objects with tensor properties}$ (2)
 > $\mathrm{EQ}≔A\left[\mathrm{\mu }\right]=G\left[\mathrm{\nu },\mathrm{\alpha }\right]A\left[\mathrm{\alpha }\right]F\left[\mathrm{\mu },\mathrm{\nu }\right]$
 ${\mathrm{EQ}}{≔}{{A}}_{{\mathrm{\mu }}}{=}{{G}}_{{\mathrm{\nu }}{,}{\mathrm{\alpha }}}{}{{A}}_{\phantom{{}}\phantom{{\mathrm{\alpha }}}}^{\phantom{{}}{\mathrm{\alpha }}}{}{{F}}_{{\mathrm{\mu }}\phantom{{\mathrm{\nu }}}}^{\phantom{{\mathrm{\mu }}}{\mathrm{\nu }}}$ (3)

The repeated and free indices of the lhs and rhs of this substitution equation eq

 > $\mathrm{Check}\left(\mathrm{EQ},\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[{\varnothing }\right]{,}\left\{{\mathrm{\mu }}\right\}\right){=}\left(\left[\left\{{\mathrm{\alpha }}{,}{\mathrm{\nu }}\right\}\right]{,}\left\{{\mathrm{\mu }}\right\}\right)$ (4)

The easy case

 > $\mathrm{SubstituteTensor}\left(\mathrm{EQ},A\left[\mathrm{\mu }\right]\right)$
 ${{G}}_{{\mathrm{\nu }}{,}{\mathrm{\alpha }}}{}{{A}}_{\phantom{{}}\phantom{{\mathrm{\alpha }}}}^{\phantom{{}}{\mathrm{\alpha }}}{}{{F}}_{{\mathrm{\mu }}\phantom{{\mathrm{\nu }}}}^{\phantom{{\mathrm{\mu }}}{\mathrm{\nu }}}$ (5)

Now the free index in the target expression is now not $\mathrm{mu}$ but $\mathrm{nu}$

 > $\mathrm{SubstituteTensor}\left(\mathrm{EQ},A\left[\mathrm{\nu }\right]\right)$
 ${{G}}_{{\mathrm{\beta }}{,}{\mathrm{\alpha }}}{}{{A}}_{\phantom{{}}\phantom{{\mathrm{\alpha }}}}^{\phantom{{}}{\mathrm{\alpha }}}{}{{F}}_{{\mathrm{\nu }}\phantom{{\mathrm{\beta }}}}^{\phantom{{\mathrm{\nu }}}{\mathrm{\beta }}}$ (6)

Distinction between covariant and contravariant indices

 > $\mathrm{SubstituteTensor}\left(\mathrm{EQ},A\left[\mathrm{~nu}\right]\right)$
 ${{G}}_{{\mathrm{\beta }}{,}{\mathrm{\alpha }}}{}{{A}}_{\phantom{{}}\phantom{{\mathrm{\alpha }}}}^{\phantom{{}}{\mathrm{\alpha }}}{}{{F}}_{\phantom{{}}\phantom{{\mathrm{\nu }}}\phantom{{,}}\phantom{{\mathrm{\beta }}}}^{\phantom{{}}{\mathrm{\nu }}{,}{\mathrm{\beta }}}$ (7)

The index $\mathrm{nu}$ found repeated in the rhs of the substitution equation eq also appears repeated in the following target expression

 > $\mathrm{ee}≔A\left[\mathrm{\nu }\right]A\left[\mathrm{\nu }\right]$
 ${\mathrm{ee}}{≔}{{A}}_{{\mathrm{\nu }}}{}{{A}}_{\phantom{{}}\phantom{{\mathrm{\nu }}}}^{\phantom{{}}{\mathrm{\nu }}}$ (8)
 > $\mathrm{res}≔\mathrm{SubstituteTensor}\left(\mathrm{EQ},\mathrm{ee}\right)$
 ${\mathrm{res}}{≔}{{G}}_{{\mathrm{\lambda }}{,}{\mathrm{\kappa }}}{}{{A}}_{\phantom{{}}\phantom{{\mathrm{\kappa }}}}^{\phantom{{}}{\mathrm{\kappa }}}{}{{F}}_{{\mathrm{\nu }}\phantom{{\mathrm{\lambda }}}}^{\phantom{{\mathrm{\nu }}}{\mathrm{\lambda }}}{}{{G}}_{{\mathrm{\beta }}{,}{\mathrm{\alpha }}}{}{{A}}_{\phantom{{}}\phantom{{\mathrm{\alpha }}}}^{\phantom{{}}{\mathrm{\alpha }}}{}{{F}}_{\phantom{{}}\phantom{{\mathrm{\nu }}}\phantom{{,}}\phantom{{\mathrm{\beta }}}}^{\phantom{{}}{\mathrm{\nu }}{,}{\mathrm{\beta }}}$ (9)

The repeated and free indices of this result

 > $\mathrm{Check}\left(\mathrm{res},\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{\kappa }}{,}{\mathrm{\lambda }}{,}{\mathrm{\nu }}\right\}\right]{,}{\varnothing }$ (10)

Functionality is also taken as parameters (only when the lhs is a Tensor function)

 > $\mathrm{SubstituteTensor}\left(A\left[\mathrm{\mu }\right]\left(X\right)=B\left[\mathrm{\mu }\right]\left(X\right),A\left[\mathrm{\nu }\right]\left(Y\right)\right)$
 ${{B}}_{{\mathrm{\nu }}}{}\left({Y}\right)$ (11)

Substituting in sub-expressions like algsubs

 > $\mathrm{EQ2}≔A\left[\mathrm{\mu }\right]\left(X\right)B\left[\mathrm{\nu }\right]\left(Y\right)=G\left[\mathrm{\mu },\mathrm{\nu }\right]\left(X\right)$
 ${\mathrm{EQ2}}{≔}{{A}}_{{\mathrm{\mu }}}{}\left({X}\right){}{{B}}_{{\mathrm{\nu }}}{}\left({Y}\right){=}{{G}}_{{\mathrm{\mu }}{,}{\mathrm{\nu }}}{}\left({X}\right)$ (12)
 > $\mathrm{ee2}≔A\left[\mathrm{\alpha }\right]\left(X\right)B\left[\mathrm{\beta }\right]\left(Y\right)A\left[\mathrm{\rho }\right]\left(X\right)B\left[\mathrm{\rho }\right]\left(Y\right)$
 ${\mathrm{ee2}}{≔}{{A}}_{{\mathrm{\alpha }}}{}\left({X}\right){}{{B}}_{{\mathrm{\beta }}}{}\left({Y}\right){}{{A}}_{{\mathrm{\rho }}}{}\left({X}\right){}{{B}}_{\phantom{{}}\phantom{{\mathrm{\rho }}}}^{\phantom{{}}{\mathrm{\rho }}}{}\left({Y}\right)$ (13)

When substituting EQ2 into ee2, the sub-expression A . B appears twice, and not in the indets (indeterminates) of ee2:

 > $\mathrm{indets}\left(\mathrm{ee2}\right)$
 $\left\{{X}{,}{Y}{,}{{A}}_{{\mathrm{\alpha }}}{}\left({X}\right){,}{{A}}_{{\mathrm{\rho }}}{}\left({X}\right){,}{{B}}_{{\mathrm{\beta }}}{}\left({Y}\right){,}{{B}}_{\phantom{{}}\phantom{{\mathrm{\rho }}}}^{\phantom{{}}{\mathrm{\rho }}}{}\left({Y}\right)\right\}$ (14)
 > $\mathrm{SubstituteTensor}\left(\mathrm{EQ2},\mathrm{ee2}\right)$
 ${{G}}_{{\mathrm{\alpha }}{,}{\mathrm{\beta }}}{}\left({X}\right){}{{G}}_{{\mathrm{\rho }}\phantom{{\mathrm{\rho }}}}^{\phantom{{\mathrm{\rho }}}{\mathrm{\rho }}}{}\left({X}\right)$ (15)

Set a kind of letter to represent spinorindices and define a tensor with mixed spacetime and spinor indices

 > $\mathrm{Setup}\left(\mathrm{spinorindices}=\mathrm{lowercaselatin_is}\right)$
 $\left[{\mathrm{spinorindices}}{=}{\mathrm{lowercaselatin_is}}\right]$ (16)
 > $\mathrm{Define}\left(T\left[\mathrm{\mu },i,j\right]\right)$
 $\mathrm{Defined objects with tensor properties}$
 $\left\{{B}{,}{C}{,}{{A}}_{{\mathrm{\mu }}}{,}{{\mathrm{\gamma }}}_{{\mathrm{\mu }}}{,}{{F}}_{{\mathrm{\mu }}\phantom{{\mathrm{\nu }}}}^{\phantom{{\mathrm{\mu }}}{\mathrm{\nu }}}{,}{{G}}_{{\mathrm{\nu }}{,}{\mathrm{\alpha }}}{,}{{\mathrm{\sigma }}}_{{\mathrm{\mu }}}{,}{{T}}_{{\mathrm{\mu }}{,}{i}{,}{j}}{,}{{\partial }}_{{\mathrm{\mu }}}{,}{{g}}_{{\mathrm{\mu }}{,}{\mathrm{\nu }}}{,}{{\mathrm{\epsilon }}}_{{\mathrm{\alpha }}{,}{\mathrm{\beta }}{,}{\mathrm{\mu }}{,}{\mathrm{\nu }}}\right\}$ (17)

Substitutions in doubly indexed Dirac matrices

 > $\mathrm{SubstituteTensor}\left(\mathrm{Dgamma}\left[\mathrm{\mu }\right]\left[i,j\right]=T\left[\mathrm{\mu },i,j\right],\mathrm{Dgamma}\left[\mathrm{~alpha}\right]\left[\mathrm{~k},m\right]\right)$
 ${{T}}_{\phantom{{}}\phantom{{\mathrm{\alpha }}{,}{k}}{m}}^{\phantom{{}}{\mathrm{\alpha }}{,}{k}\phantom{{m}}}$ (18)

When the free indices of left and right hand sides of a substitution equation are different, the substitution is halted and a related error message is displayed

 > $\mathrm{SubstituteTensor}\left(\mathrm{Dgamma}\left[\mathrm{\mu }\right]\left[i,j\right]=1,\mathrm{Dgamma}\left[\mathrm{~alpha}\right]\left[\mathrm{~k},m\right]\right)$

Substitutions of that kind could however be intentional; in those situations you can use the option disregardfreeindices

 > $\mathrm{SubstituteTensor}\left(\mathrm{Dgamma}\left[\mathrm{\mu }\right]\left[i,j\right]=1,\mathrm{Dgamma}\left[\mathrm{~alpha}\right]\left[\mathrm{~k},m\right],\mathrm{disregardfreeindices}\right)$
 ${1}$ (19)
 > See Also Compatibility

 • The Physics[SubstituteTensor] command was introduced in Maple 2015.