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 on both sides of a substitution equation are intentionally different, to avoid that interruption you can use the option disregardfreeindices.
Examples
with⁡Physics:
Setup⁡mathematicalnotation=true
mathematicalnotation=true
Define⁡A,B,C,F,G:
Defined objects with tensor properties
EQ≔Aμ=Gν,α⁢Aα⁢Fμ,ν
EQ≔Aμ=Gν,α⁢A⁢α⁢α⁢Fμνμν
The repeated and free indices of the lhs and rhs of this substitution equation eq
Check⁡EQ,all
The repeated indices per term are: ...,...,..., the free indices are: ...
∅,μ=α,ν,μ
The easy case
SubstituteTensor⁡EQ,Aμ
Gν,α⁢A⁢α⁢α⁢Fμνμν
Now the free index in the target expression is now not mu but nu
SubstituteTensor⁡EQ,Aν
Gβ,α⁢A⁢α⁢α⁢Fνβνβ
Distinction between covariant and contravariant indices
SubstituteTensor⁡EQ,A~nu
Gβ,α⁢A⁢α⁢α⁢F⁢ν,β⁢ν,β
The index nu found repeated in the rhs of the substitution equation eq also appears repeated in the following target expression
ee≔Aν⁢Aν
ee≔Aν⁢A⁢ν⁢ν
res≔SubstituteTensor⁡EQ,ee
res≔Gλ,κ⁢A⁢κ⁢κ⁢Fνλνλ⁢Gβ,α⁢A⁢α⁢α⁢F⁢ν,β⁢ν,β
The repeated and free indices of this result
Check⁡res,all
α,β,κ,λ,ν,∅
Functionality is also taken as parameters (only when the lhs is a Tensor function)
SubstituteTensor⁡Aμ⁡X=Bμ⁡X,Aν⁡Y
Bν⁡Y
Substituting in sub-expressions like algsubs
EQ2≔Aμ⁡X⁢Bν⁡Y=Gμ,ν⁡X
ee2≔Aα⁡X⁢Bβ⁡Y⁢Aρ⁡X⁢Bρ⁡Y
ee2≔Aα⁡X⁢Bβ⁡Y⁢Aρ⁡X⁢B⁢ρ⁢ρ⁡Y
When substituting EQ2 into ee2, the sub-expression A . B appears twice, and not in the indets (indeterminates) of ee2:
indets⁡ee2
X,Y,Aα⁡X,Aρ⁡X,Bβ⁡Y,B⁢ρ⁢ρ⁡Y
SubstituteTensor⁡EQ2,ee2
Gα,β⁡X⁢Gρρρρ⁡X
Set a kind of letter to represent spinorindices and define a tensor with mixed spacetime and spinor indices
Setup⁡spinorindices=lowercaselatin_is
spinorindices=lowercaselatin_is
Define⁡Tμ,i,j
B,C,Aμ,γμ,Fμνμν,Gν,α,σμ,Tμ,i,j,∂μ,gμ,ν,εα,β,μ,ν
Substitutions in doubly indexed Dirac matrices
SubstituteTensor⁡Dgammaμi,j=Tμ,i,j,Dgamma~alpha~k,m
T⁢α,km⁢α,km
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
SubstituteTensor⁡Dgammaμi,j=1,Dgamma~alpha~k,m
Free indices on both sides of the equation are different: found i,j,μ on the left-hand side and ∅ on the right-hand side
Error, (in Physics:-SubstituteTensor) free indices on both sides of the equation are different
Substitutions of that kind could however be intentional; in those situations you can use the option disregardfreeindices
SubstituteTensor⁡Dgammaμi,j=1,Dgamma~alpha~k,m,disregardfreeindices
1
See Also
algsubs, Check, eval, indets, Physics, Physics conventions, Physics examples, Physics Updates, Tensors - a complete guide, Mini-Course Computer Algebra for Physicists, subs, SubstituteTensorIndices
Compatibility
The Physics[SubstituteTensor] command was introduced in Maple 2015.
For more information on Maple 2015 changes, see Updates in Maple 2015.
The Physics[SubstituteTensor] command was updated in Maple 2020.
Download Help Document