Substitute - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Physics : Substitute

Physics[Substitute] - substitute tensor indices, tensorial expressions, non-commutative products possibly involving tensors, combining into one command all of subs, algsubs, SubstituteTensor, SubstituteTensorIndices,  Library:-SubstituteMatrix and Library:-SubstituteOperator

Calling Sequence

Substitute(EQ, ..., ee, evaluateexpression, <other options>)

Parameters

EQ

-

a substitution equation, a list or set of them, or a sequence of any of these, typically involving tensor indices or tensors, or noncommutative objects, or sums or products of them, on the left-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/or noncommutative objects products or powers

evaluateexpression

-

optional, when given, the substitutions in ee are performed and the result fully evaluated

<other options>

-

optional, can be any of the options of the commands SubstituteTensor, SubstituteTensorIndices, Library:-SubstituteOperator or the indexing options of the subs command as in Substitute[subs_options](...)

Description

• 

Substitute substitutes the equation(s) EQ into ee, unifying in one command all of subs, algsubs, SubstituteTensor, SubstituteTensorIndices, Library:-SubstituteMatrix and Library:-SubstituteOperator. In this sense, Substitute performs mathematical substitutions instead of just syntactical ones as subs and eval do. A list of typical examples:

– 

If Greek letters are tensor indices, EQμ=ν and the target ee is a tensorial expression, the substitution is automatically forwarded to SubstituteTensorIndices and will substitute both covariant (μ) and contravariant (~&mu;) indices, and perform the substitution only in tensor indices, not otherwise.

– 

If EQ is a tensorial equation, with or without free indices on the left and right hand sides, the task is automatically forwarded to SubstituteTensor.

– 

If EQ involves Matrix or Vector constructions, the task is automatically forwarded to Library:-SubstituteMatrix.

– 

If EQ involves products, sums or powers, with or without non-commutative objects, the substitution task is automatically forwarded to Library:-SubstituteOperator which combines three different strategies involving algsubs that handles simple cases, simplify/siderels that uses a more thorough approach involving Groebner basis, and an algorithm dedicated to perform substitutions of sub-products of noncommutative products (say AB in ABC), as well as sub-sums (say A+B in A+B+C).

• 

All the optional arguments accepted by SubstituteTensor, SubstituteTensorIndices or Library:-SubstituteOperator can be passed, as such, to Substitute, and the indexing options of the subs command are also understood by Substitute provided you pass them indexing the command, as in Substitute[subs_options](...). Conflicting options - accepted by one command but not by another one - are not a problem: if an option passed is not accepted by the command actually performing the substitution, that option is ignored.

• 

The special keyword evaluateexpression is understood by all the commands used by Substitute; if that option is passed and the command used to perform the action is subs, then subs is used as in subs[eval].

Examples

withPhysics&colon;

Setupmathematicalnotation=true

mathematicalnotation=true

(1)

Substitutions of matrices, sub-products and sub-sums, possibly involving noncommutative objects

eqF+ABx=Ej

eqF+ABx=Ej

(2)

eeABxC

eeABxC

(3)

Substituteeq&comma;ee

CFEj

(4)
  

Substitution of matrices and vectors taking mathematical equality into account

eqMatrix2&comma;symbol=a=β+Matrix2&comma;symbol=b

eq=β+

(5)

eeMatrix2&comma;symbol=a

ee

(6)
  

Although the target expression ee consists of a Matrix and the left hand side of eq is a matrix mathematically equal to ee, each Matrix is an independent object so syntactically they are not equal:

lhseq=ee

=

(7)

evalb

false

(8)
  

These cases are handled by Substitute as one would expect, by recognizing the left-hand side of eq as mathematically equal to ee

Substituteeq&comma;ee

β+

(9)
  

Substitute performs the substitution in the presence of Matrix or Vector constructions not just in the natural case above but in general, in all the cases it can handle

eqα+Matrix2&comma;2&comma;a1,1&comma;a1,2&comma;a2,1&comma;a2,2=β+Matrix2&comma;2&comma;b1,1&comma;b1,2&comma;b2,1&comma;b2,2

eqα+=β+

(10)

Substituteeq&comma;ee

α+β+

(11)
  

Setup some non-commutative operands

Setupquantumoperators=A&comma;B&comma;C&comma;E&comma;F&colon;

  

Some typical examples not handled by subs, eval or algsubs

eqF+ABx=Ej

eqF+ABx=Ej

(12)

eeABxC

eeABxC

(13)

Substituteeq&comma;ee

EjFC

(14)

eeexpλABCBexpλABC

ee&ExponentialE;λABCB&ExponentialE;λABC

(15)

SubstituteBC=F&comma;ee

&ExponentialE;λAFB&ExponentialE;λAF

(16)

eeIntAtexpλAtBtC1Ketψ&comma;t&comma;t=..

eeAt&ExponentialE;λAtBtCψt&DifferentialD;t

(17)

SubstituteAtBt=Ft1λ&comma;ee

At&ExponentialE;FtCψt&DifferentialD;t

(18)

eeSumλfnAgnBhnCn1n!&comma;n=0..

een=0λfnAgnBhnCnn!

(19)

SubstitutegnBhnC=Fn1λ&comma;ee

n=0fnAFnnn!

(20)

eeBAB2KetA&comma;α

eeBAB2Aα

(21)

SubstituteBKetA&comma;α=KetC&comma;α&comma;ee

BABCα

(22)
• 

Clear quantum operators to proceed with examples in the next sections

Setupclear&comma;quantumoperators

quantumoperators=none

(23)

Substituting tensorial sub-expressions

DefineA&comma;B&comma;C&comma;F&comma;G&colon;

Defined objects with tensor properties

(24)

EQAμ=Gν,αAαFμ,ν

EQAμ=Gν,αAααFμνμν

(25)
  

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

CheckEQ&comma;all

The repeated indices per term are: ...&comma;...&comma;..., the free indices are: ...

&comma;μ=α&comma;ν&comma;μ

(26)
  

The easy case

SubstituteEQ&comma;Aμ

Gν,αAααFμνμν

(27)
  

Now the free index in the target expression is now not mu but nu

SubstituteEQ&comma;Aν

Gβ,αAααFνβνβ

(28)
  

Distinction between covariant and contravariant indices

SubstituteEQ&comma;A~nu

Gβ,αAααFν,βν,β

(29)
  

The index nu found repeated in the rhs of the substitution equation eq also appears repeated in the following target expression

eeAνAν

eeAνAνν

(30)

resSubstituteEQ&comma;ee

resGλ,κAκκFνλνλGβ,αAααFν,βν,β

(31)
  

The repeated and free indices of this result

Checkres&comma;all

The repeated indices per term are: ...&comma;...&comma;..., the free indices are: ...

α&comma;β&comma;κ&comma;λ&comma;ν,

(32)
  

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

SubstituteAμX=BμX&comma;AνY

BνY

(33)
  

Substituting in sub-expressions like algsubs

EQ2AμXBνY=Gμ,νX

EQ2AμXBνY=Gμ,νX

(34)

ee2AαXBβYAρXBρY

ee2AαXBβYAρXBρρY

(35)
  

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

indetsee2

X&comma;Y&comma;AαX&comma;AρX&comma;BβY&comma;BρρY

(36)

SubstituteEQ2&comma;ee2

Gα,βXGρρρρX

(37)
  

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

Setupspinorindices=lowercaselatin_is

spinorindices=lowercaselatin_is

(38)

DefineTμ,i,j

Defined objects with tensor properties

B&comma;C&comma;Aμ&comma;γμ&comma;Fμνμν&comma;Gν,α&comma;σμ&comma;Tμ,i,j&comma;μ&comma;gμ,ν&comma;εα,β,μ,ν

(39)
  

Substitutions in doubly indexed Dirac matrices

SubstituteDgammaμi,j=Tμ,i,j&comma;Dgamma~alpha~k,m

Tα,kmα,km

(40)
  

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

SubstituteDgammaμi,j=1&comma;Dgamma~alpha~k,m

Free indices on both sides of the equation are different: found i&comma;j&comma;μ 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

SubstituteDgammaμi,j=1&comma;Dgamma~alpha~k,m&comma;disregardfreeindices

1

(41)

Substitutions of tensor indices

  

Define a couple of arbitrary spacetime tensors for exploration purposes

DefineA&comma;B

Defined as tensors

B&comma;C&comma;Aμ&comma;γμ&comma;Fμνμν&comma;Gν,α&comma;σμ&comma;Tμ,i,j&comma;μ&comma;gμ,ν&comma;εα,β,μ,ν

(42)
  

Enter, for example, this tensorial expression, with a contravariant free index ρ

g_α,μA~mug_~alpha,~nuBν,σ,~rho

gα,μAμμgα,να,νBν,σρν,σρ

(43)
  

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

Check&comma;all

The repeated indices per term are: ...&comma;...&comma;..., the free indices are: ...

α&comma;μ&comma;ν,σ&comma;~&rho;

(44)
  

So (3) has α and the contravariant ρ as free indices. Substitute now α=β: the standard subs command will only substitute the covariant α

subsα=β&comma;

gβ,μAμμgα,να,νBν,σρν,σρ

(45)
  

Consequently, the resulting expression is not equivalent to (3): it now has four free indices

Check&comma;all

The repeated indices per term are: ...&comma;...&comma;..., the free indices are: ...

μ&comma;ν,β&comma;σ&comma;~&alpha;&comma;~&rho;

(46)
  

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

Substituteα=β&comma;

gβ,μAμμgβ,νβ,νBν,σρν,σρ

(47)

Check&comma;all

The repeated indices per term are: ...&comma;...&comma;..., the free indices are: ...

β&comma;μ&comma;ν,σ&comma;~&rho;

(48)
  

Substitute now the contravariant ρ by τ; the standard subs command will fail because contravariant indices are prefixed by ~, so this returns (3) as given

subsρ=β&comma;

gα,μAμμgα,να,νBν,σρν,σρ

(49)
  

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

Substituteρ=β&comma;

gα,μAμμgα,να,νBν,σβν,σβ

(50)

Check&comma;all

The repeated indices per term are: ...&comma;...&comma;..., the free indices are: ...

α&comma;μ&comma;ν,σ&comma;~&beta;

(51)
  

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

Substituteρ=β&comma;α=γ&comma;

gγ,μAμμgγ,νγ,νBν,σβν,σβ

(52)
  

After substituting, tensors are re-evaluated; in this example, ν becomes 1 and the normalized form of g_ is presented with it in the first place, so switching places with μ

g_μ,ν

gμ,ν

(53)

Substituteν=1&comma;

gμ,1

(54)

Substituteν=1&comma;μ=1&comma;

g1,1

(55)
  

Note the result above is not fully evaluated; in that sense, Substitute, the same as SubstituteTensorIndices, follows the design of subs. To have results fully evaluated, pass the keyword evaluateexpression

Substituteν=1&comma;μ=1&comma;&comma;evaluateexpression

−1

(56)

See Also

algsubs, Check, eval, eval, g_, indets, Physics, Physics conventions, Physics examples, Physics Updates, Tensors - a complete guide, Mini-Course Computer Algebra for Physicists, Physics:-Library, subs, SubstituteTensor, SubstituteTensorIndices

Compatibility

• 

The Physics[Substitute] command was introduced in Maple 2023.

• 

For more information on Maple 2023 changes, see Updates in Maple 2023.