Physics:-Library - A programming language for Physics
Calling Sequence
Physics:-Library:-Command(arguments, options)
Parameters
Command
-
a Command of the Physics Library; could be any of those shown via with(Physics:-Library)
arguments
the arguments of Command
options
Most Library Commands accept optional arguments of the form name = value
Description
This Physics Library got introduced in Maple 17 with 96 programming commands and 58 specialized Physics types, all key elements of the programming language used at Maplesoft to construct Physics. This library has been growing; in Maple 2019 there are 159 programming commands and 98 Physics types. These commands and types can be useful to program your own extensions of Physics. Many of these commands are useful interactively too, like for instance AntiCommute, Commute, Degree for noncommutative variables, IsTensorialAntisymmetric, IsTensorialSymmetric, MinimizeTensorComponents for tensors, Backup and Restore to explore with different settings for algebra rules, spacetime dimensions, and so on.
To load this Library of programming commands, enter:
with(Physics): with(Library):
You can also use any of these commands without loading the Library by using the long form, as in Library:-Command.
To see a complete list of the Physics types available, because PhysicsType is one of the commands of the Library, and a module itself, you can enter exports(PhysicsType), or instead list them alphabetically using another Library command, ListPhysicsTypes:
ListPhysicsTypes();
AnnihilationCreationOperator,AnnihilationOperator,AppliableProcedure,AppliedQuantumOperator,AtProcedure,BosonAnnihilationCreationOperator,BosonAnnihilationOperator,BosonCreationOperator,Bra,Bracket,CommutativeMapping,CompositeDifferentiationOperator,Contravariant,ContravariantGreek,Covariant,CreationOperator,D_,DifferentialOperator,DifferentialOperatorIndexed,DifferentialOperatorSymbol,DiracSpinor,DiracSpinorWithoutIndices,DoublyIndexedPhysicsMatrix,EntirelyNotNestedIntegral,EuclideanIndex,EuclideanTensor,ExpandableProduct,ExtendedBra,ExtendedDifferentialOperator,ExtendedDifferentialOperatorIndexed,ExtendedDifferentialOperatorSymbol,ExtendedKet,ExtendedMatrix,ExtendedMatrixRequiringEval,ExtendedPhysicsMatrix,ExtendedProjector,ExtendedProjectorKind,ExtendedQuantumOperator,ExtendedTensor,ExtendedVectorDifferentialOperator,FermionAnnihilationCreationOperator,FermionAnnihilationOperator,FermionCreationOperator,FullyCommutative,HalfInteger,HermitianOperator,IdentityMatrix,InertSymbol,Ket,LeviCivitaNonGalilean,LeviCivitaTensor,LinearOperatorFunction,LiteralSubscript,NegativePower,NonCommutativeProduct,NonTensorFunction,NotNestedIntegral,NumericalIndex,P_indexed,P_suffixed,PhysicsD3_2,PhysicsD_2,PhysicsFunction,PhysicsKnownFunction,PhysicsMatrix,PhysicsMatrixWithMatrixIndices,PhysicsTensor,PhysicsVectors,Physicsd_2,Polynomial,Procedure,Projector,ProjectorCore,ProjectorInt,ProjectorKind,ProjectorKindDot,ProjectorKindStar,ProjectorSum,QuantumNumber,QuantumObject,QuantumOperator,QuantumOperatorFunction,SpaceNumericalIndex,SpaceTimeVectorApplied,SpacetimeNumericalIndex,Spinor,SpinorWithoutIndices,SumOfNegatives,SymbolicTensorIndex,Tensor,TensorAllowWithoutIndices,TensorInCurrentCoordinates,TensorIndex,TensorInternalRepresentation,TensorQuantumOperator,TensorStructure,TensorVector,TensorWithAbstractIndices,TensorWithIndices,TensorWithNumericalIndices,TensorWithoutIndices,TensorialExpression,TripleProduct,UnitaryOperator,VectorDifferentialOperator,VectorOperator,VectorOperatorApplied,Vectorial,X_mu,dg_dg,genericindex,p_P_indexed,p_P_suffixed,p_indexed,p_suffixed,spaceindex,spacetimeindex,spinorindex,su2index,su2matrixindex,su3index,su3matrixindex,tetradindex,x_mu
You can see the definition of these types in two different ways. First, using the option showdefinition of ListPhysicsTypes. For example:
ListPhysicsTypes(AnnihilationCreationOperator, showdefinition);
AnnihilationCreationOperator=AnnihilationOperator∨CreationOperator
Secondly, the definition for each PhysicsType can be retrieved using TypeTools:-GetType, for example:
TypeTools:-GetType(PhysicsType:-AnnihilationCreationOperator);
AnnihilationOperator∨CreationOperator
If you load the package of types via with(PhysicsType), you can also see this definition entering just TypeTools:-GetType(AnnihilationCreationOperator). Recall however that by entering with(PhysicsType) you will populate the space of working names with the names of all the Physics types.
These types are used as in type(A, PhysicsType:-TypeKeyword) or using the long forms Library:-PhysicsType:-TypeKeyword or Physics:-Library:-PhysicsType:-TypeKeyword, depending on whether you have already loaded Physics or Physics:-Library using with. In all cases A can be anything, and TypeKeyword is any of the types returned above by ListPhysicsTypes() or exports(PhysicsType). Note that you do not need to list these types before using them.
Mathematical notation: When Physics or Physics:-Vectors are loaded in the Standard Graphical User Interface, by entering
with(Physics): Setup(mathematicalnotation = true);
mathematicalnotation=true
you have anticommutative and noncommutative variables displayed in different colors, non-projected vectors and unit vectors are respectively displayed with an arrow and a hat on top, the vectorial differential operators (such as Nabla, Laplacian) with an upside down triangle, and most of the other Physics commands are displayed as in textbooks.
Examples: illustrating the use of the package's commands in Analytical Geometry, Mechanics, Electrodynamics, Special and General Relativity, and Quantum Mechanics are found in Physics examples (this page opens only in the Standard Graphical User Interface).
Instead of providing a help page for each of these Library programming tools, below there is an alphabetical listing of them, linking to sections within this single page, where their calling sequence, parameters, description, and examples are shown.
List of the Physics Library Commands
Add
AntiCommute
ApplyCommandUsingImplicitAssumptions
ApplyProductsOfDifferentialOperators
Backup
BelongToDifferentDisjointedSpaces
BelongToDisjointedSpaces
BelongToTheSameDisjointedSpace
CartesianProduct
CombinePowersOfSameBase
Commute
Contravariant
CoordinatesINFO
Covariant
DefaultAlgebraRules
Degree
DelayEvaluationOfTensors
Dgamma5ToOtherDgamma
DiscardTermsOfHigherDegree
ExpandProductsInExpression
FlattenPowersInProduct
FlipCharacter
FlipCharacterOfFreeIndices
Forget
ForgetInAllRememberTables
FromCoordinatesToLabel
FromGeneralRelativityTensorFunctionalForm
FromLabelToCoordinates
FromMetricToLineElement
FromMinkowskiKindToSignature
FromSignatureToMinkowskiKind
FromSpaceTimeVector
FromTensorFunctionalForm
FromTensorInternalRepresentation
FromTetradToTetradMetric
GetAlgebraRuleName
GetAlgebraRules
GetAntiCommutativeSymbol
GetBasisContinuityInfo
GetBasisDimension
GetCommutativeSymbol
GetCoordinateSystem
GetCoordinatesAlias
GetDefineINFO
GetDifferentialOperators
GetDifferentiationVariables
GetDimensionNumbers
GetDimensionNumbersSequence
GetDimensionOfIndex
GetDimensionOfTypeOfIndex
GetDimensionRange
GetExistingAnnihilationCreationOperator
GetFAndDifferentiationVariables
GetFingerprint
GetGeneralRelativityTensorFunctionalForm
GetIndicesAndCharacter
GetIndicesInUse
GetIndicesOfType
GetNameIndicesVariables
GetNameWithIndices
GetNameWithoutIndices
GetNonCommutativeSymbol
GetNotCommutativeNamesAndFunctions
GetProjectorCore
GetRepeatedIndices
GetReplacementIndices
GetSetupINFO
GetSpaceTimeVectors
GetSumIntCore
GetSymbolsWithSameType
GetTensorDependency
GetTensorFunctionalForm
GetTensorIndices
GetTensorNamesInExpression
GetTensorProductArrayOfCoefficients
GetTensorSymmetryProperties
GetTypeOfIndex
GetTypeOfTensorIndices
GetVectorRootName
HasAfterAtomizingNames
IndicesOfKindOfLetter
InertProductToInertPower
IsACSuffixed
IsAntiCommutatorVariable
IsAnticommutativeMappingOfAnticommutativeVariables
IsCommutativeMappingOfAnticommutativeVariables
IsCommutatorVariable
IsContravariant
IsCovariant
IsEuclideanMetric
IsEuclideanSignature
IsGalileanMetric
IsGalileanSignature
IsHermitianOperator
IsLiteralSubscript
IsMinkowskiMetric
IsMinkowskiSignature
IsNCSuffixed
IsNoncommutativeMappingOfAnticommutativeVariables
IsNullTetradMetric
IsOrthonormalTetradMetric
IsRealObject
IsSymmetricMatrix
IsTensorInCurrentCoordinates
IsTensorialAntisymmetric
IsTensorialSymmetric
IsUnitaryOperator
IsValidSignature
IsVectorSymbol
ListPhysicsTypes
MinimizeTensorComponents
NestLeftAssociative
NormalizeProductsOfDifferentialOperators
NormalizeTensor
NormalizeTensorExpression
NumberOfIndependentTensorComponents
OperationOnInertCommand
PerformMatrixOperations
PhysicsType
PositionOfTimelikeComponent
PowerToProduct
PrintWithTypesetting
PutCharacterAttributesBack
PutCharacterAttributesInExpression
PutCharacterAttributesInTensor
PutZeroDimensionEntries
Quiet
RealObjects
RecycleArguments
RedefineTensorComponent
ReformatRepeatedIndices
RelabelTensorComponents
RemoveIntegerIndices
ReplaceCommonRepeatedIndices
ReplaceRepeatedIndices
Restore
RewriteInMatrixForm
RewriteTypeOfIndices
RootOfIndex
SearchDGMetricTable
ShieldDummyIndicesInFunctionArguments
ShowTypeDefinition
SignOfTimelikeComponent
SortAnticommutativeList
SortQuantumObjectsThatCommute
SplitIndicesByType
StripTilde
StripTildeFromRepeatedIndices
SubsTensorIndices
SubstituteMatrix
SwapLinesAndColumns
TensorComponents
ToContravariant
ToCovariant
ToGeneralRelativityTensorFunctionalForm
ToSpaceTimeVector
ToTensorFunctionalForm
ToTensorInternalRepresentation
TypesetPrint
UpdateCharacterAttributesInExpression
UpdateCharacterAttributesInTensor
UpdateQnInUse
Physics:-Library:-Add(f, k = m..n)
f : algebraic expression
k : name; summation index
m, n : integers or arbitrary expressions, indicate the summation range
Add unifies the standard add and sum commands into one that uses a more modern handling of arguments, is free of premature evaluation problems, and implements multi-index summation. The functionality and handling of arguments of Add can be plugged directly into the sum command using the option redefinesum of Physics:-Setup.
Examples
restart: with(Physics): with(Library):
Consider this multi-index summation.
Add(f[i, j], 1 <= i+j and i+j <= n);
∑1≤i+j≤n⁡fi,j
For instance, for n=2,
eval((5), n = 2);
f0,1+f1,0+f0,2+f1,1+f2,0
The formula for the integer power of a sum is:
(a+b+c)^n = Add(factorial(n)*a^p*b^q*c^r/(factorial(p)*factorial(q)*factorial(r)), p+q+r = n);
a+b+cn=∑p+q+r=n⁡n!⁢ap⁢bq⁢cr⁢1p!⁢q!⁢r!
eval((7), n = 3);
a+b+c3=a3+3⁢a2⁢b+3⁢a2⁢c+3⁢a⁢b2+6⁢a⁢b⁢c+3⁢a⁢c2+b3+3⁢b2⁢c+3⁢b⁢c2+c3
A more modern handling of its arguments, consider a typical problem where a name, say j, is assigned a value, and j is used as dummy summation variable
a, b, j := 1, 2, 3;
a,b,j≔1,2,3
The value just assigned, j=3, is not expected to interfere with the summation
Add(f[j], j = a..b);
f1+f2
while for this example, sum interrupts with an error message due to a premature evaluation of the summation index j. Another frequent case: a procedure that returns a value according to the value of the summation index.
g := k -> if k::odd then G[k] else 0 end if;
g≔k↦ifk::oddthenGkelse0endif
Without giving a value to the summation limit f, the following summation cannot be performed.
Add(g(k), k = 1 .. f);
∑k=1f⁡g⁡k
For this example, add interrupts with an error message while sum returns 0, again due to a premature evaluation of g⁡k before k has a numerical value. Using a more modern handling of arguments Add returns unevaluated instead, as seen above, which permits evaluating the summation at a later moment, for instance attributing a value to f.
eval((12), f = 3);
G1+G3
See Also
add, sum, Physics[Setup]
Physics:-Library:-AntiCommute(a, b)
a : any Maple algebraic expression
b : any Maple algebraic expression
AntiCommute returns true or false according to whether a and b anticommute, that is, a*b = -b*a.
Setup(anticommutativepre = A):
* Partial match of 'anticommutativepre' against keyword 'anticommutativeprefix'
_______________________________________________________
AntiCommute(A1, A2);
true
Physics:-Library:-ApplyCommandUsingImplicitAssumptions(command, ee)
command : a maple command to be applied to ee
ee : a Maple object, typically an algebraic expression or equation or set of them, containing definite integrals, sums, or products
ApplyCommandUsingImplicitAssumptions applies any command to expressions containing sums, integrals or products such that the command is applied to the summand (integrand or 1st argument of the product) taking into account the assumptions implicit in the summation (integration or product) range.
Any additional argument passed to ApplyCommandUsingImplicitAssumptions is passed as an optional argument for command when performing the operation.
Sum((a*b)^k, k = a .. b);
∑k=ab⁡a⁢bk
expand will not expand the power in the summand: it does not know about k being an integer (implicit assumption in the Sum structure)
expand((16));
∑k=ab⁡ak⁢bk
The following makes expand be aware of the implicit assumptions on k and so expand the power
ApplyCommandUsingImplicitAssumptions(expand, (16));
assuming, simplify
Physics:-Library:-ApplyProductsOfDifferentialOperators(ee)
e : any valid Maple object, possibly an expression, that may contain products involving differential operators
Given an algebraic expression ee, or any Maple object (e.g. set, list or Matrix) containing such expressions, ApplyProductsOfDifferentialOperators applies the differential operators found in the products to the operands appearing to their right.
restart: with(Physics): with(Library): with(Vectors):
Consider the commutator between a scalar A⁡x,y,z and the ∇ operator; use CompactDisplay for convenience
CompactDisplay(A(x, y, z), B_(x, y, z));
A⁡x,y,z⁢will now be displayed as⁢A
B→⁡x,y,z⁢will now be displayed as⁢B→
Commutator(Nabla, A(x, y, z));
∇,A−
The expanded form of this commutator has the correct operatorial meaning:
expand((20));
∇⁢A−A⁢∇
So all the algebra is performed taking ∇ as a noncommutative operator, as we do when computing with paper and pencil. You can apply the differential operators at any time using the ApplyProductsOfDifferentialOperators
ApplyProductsOfDifferentialOperators((21));
Ax⁢i∧+Ay⁢j∧+Az⁢k∧−A⁢∇
The differentiation variables associated to ∇ are the coordinates of the Cartesian cylindrical and spherical systems of coordinates: x,y,z,ρ,φ,r,θ. The same concept is implemented for the differential operators of special and special and general relativity, d_ and D_. Define system of coordinates, X, then A and B as a tensors and for convenience use a CompactDisplay
Coordinates(X);
⁢Systems of spacetime coordinates are:⁢X=x1,x2,x3,x4
X
Define(A[mu], B[mu]);
Defined objects with tensor properties
Aμ,Bμ,γμ,σμ,∂μ,gμ,ν,εα,β,μ,ν,Xμ
CompactDisplay((A, B)(X));
A⁡x1,x2,x3,x4⁢will now be displayed as⁢A
B⁡x1,x2,x3,x4⁢will now be displayed as⁢B
The commutator of ∂μ and Aν multiplied by Bα, representing the application of ∂μ can now be represented as
Commutator(d_[mu], A[nu](X))*B[alpha](X);
∂μ,Aν−⁢Bα
expand((26));
∂μ⁢Aν⁢Bα−Aν⁢∂μ⁢Bα
Note that to the right of ∂μ in the first term there is the product Aν⁢Bα, so that when applying the operator to the product, two terms result, one of which cancels the second term in the above:
Library:-ApplyProductsOfDifferentialOperators((27));
∂μ⁡Aν⁢Bα
ApplyProductsOfDifferentialOperators also applies differential operators that you define as such using Setup. This is particularly useful in quantum mechanics.
Setup(differentialoperators = {[p_, [x, y, z]]}, hermitianoperators = {p, x, y, z}, algebrarules = {%Commutator(x, y) = 0, %Commutator(x, z) = 0, %Commutator(y, z) = 0}, quiet);
algebrarules=x,y−=0,x,z−=0,y,z−=0,differentialoperators=p→,x,y,z,hermitianoperators=p,x,y,z
alias(:-X = (x, y, z)):
CompactDisplay(F(X)):
F⁡x,y,z⁢will now be displayed as⁢F
%Commutator(F(X), p_)*Ket(psi, X);
F,p→−⁢ψx,y,z
Note that p→, F⁡X and the ket ψx,y,z are operands in the products above and that they do not commute: we indicated that the coordinates X are the differentiation variables of p→. This emulates what we do when computing with these operators with paper and pencil, where we represent the application of a differential operator as a product operation.
This representation can be transformed into the (traditional in computer algebra) application of the differential operator when desired, as follows:
(31) = expand((31));
F,p→−⁢ψx,y,z=F⁢p→⁢ψx,y,z−p→⁢F⁢ψx,y,z
(31) = ApplyProductsOfDifferentialOperators(rhs((32)));
F,p→−⁢ψx,y,z=F⁢p→⁡ψx,y,z−p→⁡F⁢ψx,y,z
See Also -(lead=indent) CompactDisplay, Coordinates, Define, d_, D_, Setup, Physics:-Vectors, Physics:-Vectors:-Nabla
Physics:-Library:-Backup()
: no parameters
Backup saves in memory a copy of the current Physics Setup, so that it can be restored at a later moment, during the same Maple session, using the Physics:-Library:-Restore; command. Backup returns NULL.
Setup(noncommutativeprefix);
noncommutativeprefix=none
Backup();
Setup(noncommutativeprefix = Z);
noncommutativeprefix=Z
Commute(Z1, Z2);
false
Restore();
Physics:-Library:-BelongToDifferentDisjointedSpaces(A, B)
A, B : quantum operators set as such using Setup, or Bras or Kets
Given A and B as quantum operators or Bras or Kets, BelongToDifferentDisjointedSpaces returns true or false according to whether A and B below to different (disjointed) Hilbert spaces. products, correctly handling the case of noncommutative products and powers and using Glauber's formula for combining exponentials when the exponents commute with their commutator. Note that this functionality, including taking into account the possibly noncommutative character of the operands and powers in a product, is already present in the standard combine command that makes calls to CombinePowersOfSameBase, so you can directly use combine.
Setup(op = {A, B});
* Partial match of 'op' against keyword 'quantumoperators'
quantumoperators=A,B
A^n * A^m + exp(A) * exp(B);
Am⁢An+ⅇA⁢ⅇB
In this expression, the exponentials in the product ⅇA⁢ⅇB cannot be combined because neither A nor B are commutative:
CombinePowersOfSameBase((40));
Am+n+ⅇA⁢ⅇB
If, however, A and B commute with their commutator,
Setup(%Commutator(A, B) = C, %Commutator(A, C) = 0, %Commutator(B, C) = 0);
algebrarules=A,B−=C,A,C−=0,B,C−=0
Am+n+ⅇA+B+C2
This functionality is already present in the standard combine command that makes calls to CombinePowersOfSameBase.
combine((40));
BelongToTheSameDisjointedSpace, Physics[Setup]
Physics:-Library:-CombinePowersOfSameBase(ee)
ee : a Maple object, typically an algebraic expression or equation or a set of them
CombinePowersOfSameBase combines powers of same base in products, correctly handling the case of noncommutative products and powers and using Glauber's formula for combining exponentials when the exponents commute with their commutator. Note that this functionality, including taking into account the possibly noncommutative character of the operands and powers in a product, is already present in the standard combine command that makes calls to CombinePowersOfSameBase, so you can directly use combine.
combine, Physics[Commutator], Physics[Setup]
Physics:-Library:-Commute(a, b)
Commute returns true or false according to whether a and b commute, that is, a⁢b=b⁢a.
Setup(noncommutativepre = A, %Commutator(A1, A2) = 0):
* Partial match of 'noncommutativepre' against keyword 'noncommutativeprefix'
Commute(A1, A2);
Commute(A1, A3);
Physics:-Library:-Contravariant(mu)
mu : any Maple algebraic expression
Contravariant receives an algebraic expression representing a tensor index, and returns its corresponding contravariant index according to: if mu is a symbol (not already prefixed with ~), or a non-negative integer smaller or equal to the spacetime dimension, then prefix it with (that is, concatenate) ~; else if mu is a sum of such indices, then prefix all of them with ~; otherwise return mu unchanged.
Contravariant(mu);
~μ
Contravariant(mu + nu);
~μ+~ν
Setup(dimension);
dimension=4
Contravariant(3);
~3
Contravariant(5);
5
Covariant, FlipCharacter, StripTilde, StripTildeFromRepeatedIndices, ToContravariant
Physics:-Library:-CoordinatesINFO()
CoordinatesINFO returns information about systems of spacetime coordinates set using Coordinates or Setup, as a list with four equations, where in the left-hand sides are the local variables of Physics where the information about the coordinates is saved and in the right-hand sides are the actual value of these variables. This information is of use in various parts of the library that need to handle spacetime coordinates.
CoordinatesINFO();
Coordinates/X=∅,Coordinates/xyz=∅,Coordinates/X_equal_xyz=∅,Coordinates/with_macros=∅
Coordinates(X=spherical);
⁢Systems of spacetime coordinates are:⁢X=r,θ,φ,t
Remove the alias X to turn visible the information in the next input line
alias(X = X):
Coordinates/X=X,Coordinates/xyz=r,θ,φ,t,Coordinates/X_equal_xyz=X=r,θ,φ,t,Coordinates/with_macros=X=x1,x2,x3,x4
Physics[Coordinates], alias, macro
Physics:-Library:-Covariant(mu)
mu : a symbol or an algebraic expression
Covariant receives an algebraic expression representing a tensor index, and returns its corresponding covariant index according to: if mu is a symbol prefixed with ~, then remove the ~, otherwise return mu unchanged.
Covariant(~mu);
μ
Covariant(mu);
Contravariant, FlipCharacter, StripTilde, StripTildeFromRepeatedIndices, ToCovariant
Physics:-Library:-Degree()
EE : any Maple algebraic object, or equation or a set or list of them
X : a name or a set of them
minmax : optional, can be min, max (default), or both, to request the minimal (equivalent to the lower degree), maximal degree with respect to X, or both (returns a sequence of two numbers)
Degree computes the maximum degree of a set of equations EE with respect to variable(s) X, possibly not commutative.
NOTE: if all the equations are equal to 0, the value returned is 0, not -infinity. When the degree cannot be computed, Degree returns FAIL.
Degree({a, b^2, c^3}, {a, b, c});
3
Physics[Coefficients]
Physics:-Library:-FlattenPowersInProduct(A0)
A0 : any algebraic object or a table
FlattenPowersInProduct receives an expression, and if it is a power, where the base can be not commutative and the exponent an integer, returns the corresponding product of operands. If A0 is a table, it maps over its elements.
Setup(op = A);
quantumoperators=A
FlattenPowersInProduct(A^3);
A⁢A⁢A
InertProductToInertPower, PowerToProduct
Physics:-Library:-FlipCharacter(mu,{ignorefailure: truefalse := false})
mu : a tensor index, covariant or contravariant
ignorefailure : optional, when given, if mu is not a covariant/contravariant index, return mu itself instead of FAIL
FlipCharacter flips the covariant or contravariant character of a given index, or returns FAIL when mu is not an index or the covariant/contravariant character cannot be determined.
Setup(spacetimeindices = greek);
spacetimeindices=greek
FlipCharacter(mu);
FlipCharacter(~mu);
Contravariant, Covariant, StripTilde, StripTildeFromRepeatedIndices
Physics:-Library:-Forget()
Forget clears all the remember tables of the internal subroutines of the Physics package, as well as those of simplify, expand, diff, normal, and int. This command is automatically used by all the Physics commands when appropriate, for example, when defining new algebras or tensors, so that computations performed before that with the same mathematical objects, and stored in remember tables, are cleared to permit the next computations take into account the new properties of the objects.
restart;
expand(A*(B+C));
A⁢B+A⁢C
Expand swaps operands in products.
expand((B+C)*A);
Expand keeps results in a remember table.
op(4, eval(expand));
table⁡A⁢B+C=A⁢B+A⁢C,B+C=B+C
Setup(op = {A, B, C});
quantumoperators=A,B,C
The remember table got cleared to permit products with noncommutative operands.
No swapping of operands and no interference of the previous remember table.
B⁢A+C⁢A
forget, simplify, expand, diff, normal, int
Physics:-Library:-FromCoordinatesToLabel(`[X]`, {disregardordering: truefalse := false})
`[X]` : a list of spacetime coordinates set using Coordinates or Setup
disregardordering : optional, true or false (default), to disregard the ordering of the spacetime variables within the list `[X]`
FromCoordinatesToLabel receives a list of spacetime coordinates and returns the corresponding label assigned previously by the Coordinates command, when the system of coordinates got defined either using Setup or using Coordinates.
Coordinates(X):
FromCoordinatesToLabel([x1, x2, x3, x4]);
Physics:-Library:-FromGeneralRelativityTensorFunctionalForm(A, {evaluatetensor: truefalse := true}, $)
A : an algebraic expression involving tensors in a nongalilean spacetime, where the metric depends on the spacetime coordinates and the Christoffel symbols are different from zero
evaluatetensor : optional, true (default) or false, to evaluate the tensor after removing the spacetime functionality
FromGeneralRelativityTensorFunctionalForm receives an expression A containing general relativity tensors with functionality and returns the same expression after removing the functionality of these tensors, followed by a set with the substitution equations used. This is useful when intermediate computations should take into account (or not) this functionality.
Set the metric to be nongalilean, for example:
g_[sc];
⁢_______________________________________________________
⁢Default differentiation variables for d_, D_ and dAlembertian are:⁢X=r,θ,φ,t
Setting lowercaselatin_is letters to represent space indices
⁢The Schwarzschild metric in coordinates ⁢r,θ,φ,t
Parameters: m
Signature: - - - +
gμ,ν=
e1 := Riemann[alpha, beta, mu,nu](X) + g_[mu,nu](X);
e1≔Rα,β,μ,ν⁡X+gμ,ν⁡X
FromGeneralRelativityTensorFunctionalForm(e1);
Rα,β,μ,ν+gμ,ν,Rα,β,μ,ν⁡X=Rα,β,μ,ν,gμ,ν⁡X=gμ,ν
FromTensorFunctionalForm, GetGeneralRelativityTensorFunctionalForm, GetTensorFunctionalForm, GetTensorDependency, ToGeneralRelativityTensorFunctionalForm, ToTensorFunctionalForm, Physics[g_]
Physics:-Library:-FromLabelToCoordinates(X)
X : a capital Letter that is the label of a system of spacetime coordinates set using Coordinates or Setup
FromLabelToCoordinates receives a capital letter that is the label of a system of spacetime coordinates previously set with Coordinates or Setup and returns the corresponding list of coordinates.
ee := FromLabelToCoordinates(:-X);
ee≔X
map(``, [ee]);
x1,x2,x3,x4
Physics:-Library:-FromMetricToLineElement(g_info := Physics:-GetSetupINFO(metric), X := Physics:-GetSetupINFO(differentiationvariables), dim := Physics:-GetSetupINFO(dimension), {used_: truefalse := false})
g_info : optional, the default value is the current spacetime metric as returned by Setup(differentiationvariables), it can also be any equivalent set of array elements
X : optional, the default value is the list of the current differentiation variables as returned by Setup(differentiationvariables)
dim : optional, the default value is the current dimension of the spacetime as returned by Setup(dimension)
used_ : optional, can be true or false (default), to represent the differential of the spacetime coordinates using d_, or just concatenating the symbol d with the coordinate
FromMetricToLineElement computes the line element representation for the spacetime metric, an expression quadratic in the differentials of the spacetime coordinates, expressed by default concatenating the letter d with the coordinate, a visual representation, or applying d_ to the coordinate, a real mathematical representation that Physics understands with the correct meaning.
FromMetricToLineElement();
−dx12−dx22−dx32+dx42
FromMetricToLineElement(used_);
−ⅆ⁡x12−ⅆ⁡x22−ⅆ⁡x32+ⅆ⁡x42
Physics:-g_
Physics:-Library:-FromSpaceTimeVector(ee)
ee : a mathematical expression possibly involving the SpaceTimeVector command of Physics
FromSpaceTimeVector converts all occurrences of SpaceTimeVector[mu](X) into X[mu], where X is a sequence of spacetime coordinates.
X_mu := FromSpaceTimeVector(SpaceTimeVector[mu](X));
X_mu≔Xμ
map(``, [op(0, X_mu)]);
GetSpaceTimeVectors, ToSpaceTimeVector
Physics:-Library:-FromTensorFunctionalForm(A,{evaluatetensor: truefalse := true}, $)
A : an algebraic expression involving tensors that have functional dependency, either because they were defined as such, or because it is one of the general relativity tensors and the spacetime is nongalilean, with the metric depending on the spacetime coordinates
FromTensorFunctionalForm receives an expression A containing tensors with functionality - say T[i,j](x,y), and returns the same expression after removing the functionality of these tensors - say as in T[i,j] - followed by a set with the substitution equations used. This is useful when intermediate computations should take into account (or not) this functionality. In this sense, FromTensorFunctionalForm is a generalization of the Maple 17 FromGeneralRelativityTensorFunctionalForm command that also handles user defined tensor functions, and performs the reverse operation of ToTensorFunctionalForm.
Define a system of coordinates and tensor depending on some variables.
Coordinates(X = Cartesian);
⁢Systems of spacetime coordinates are:⁢X=x,y,z,t
Define(p[mu] = [m*v__1(t), m*v__2(t), m*v__3(t), p__0(t)]);
γμ,σμ,∂μ,gμ,ν,pμ,εα,β,μ,ν,Xμ
The system now knows about this dependency on t and m, so that the derivatives of pμ are not zero.
[p[mu], diff(p[mu], t), d_[nu](p[mu])];
pμ,∂∂tpμ,∂ν⁡pμ
Put and remove the functionality.
ToTensorFunctionalForm((91));
pμ⁡t,m,p.μ⁡t,m,∂ν⁡pμ⁡t,m,pμ=pμ⁡t,m
FromTensorFunctionalForm((92)[1]);
pμ,∂∂tpμ,∂ν⁡pμ,pμ⁡t,m=pμ
FromTensorFunctionalForm(e1);
FromGeneralRelativityTensorFunctionalForm, GetGeneralRelativityTensorFunctionalForm, GetTensorFunctionalForm, GetTensorDependency, ToGeneralRelativityTensorFunctionalForm, ToTensorFunctionalForm, Physics[g_]
Physics:-Library:-FromTensorInternalRepresentation(expr,{evaluatetensor: truefalse := true})
expr : a mathematical expression containing tensors in the Physics internal representation
evaluatetensor : optional, it can be true (default) or false, to evaluate the tensors after having restored their natural (not internal) representation
FromTensorInternalRepresentation replaces, in the given expression, all tensors expressed using the Physics internal representation by the same tensors expressed in the natural representation used at user level. The tensors being restored are evaluated before returning, so that they get normalized taking into account their symmetry properties. To override that evaluation use the option evaluatetensor = false.
Define(A):
ir := ToTensorInternalRepresentation(d_[mu](A[nu](X)));
ir≔_tenop⁡∂_dotidx1,A_dotidx2⁡X,Xμ,ν,_tenop⁡∂_dotidx1,A_dotidx2⁡X,Xμ,ν
FromTensorInternalRepresentation(ir[2]);
∂μ⁡Aν⁡X
Physics:-Library:-GetAlgebraRuleName(A)
A : a mathematical object supposed to be part of the definition of an algebra rule of Commutators or AntiCommutators
GetAlgebraRuleName applies a := GetNameWithIndices(A), and when a enters the internal representation of an algebra rule of Commutators or AntiCommutators, returns a Otherwise, if a is indexed it returns op(0, a). This command is used inside Commutator and AntiCommutator when computing, in order to determine whether an algebra rule already exists for the objects being manipulated.
Define(A, B):
Setup('Commutator(A[mu], B[nu])' = KroneckerDelta[mu,nu]);
Warning, since Maple 2019 KroneckerDelta is not implemented as a tensor unless the indices are of type <spinor, su2, su3 or gauge>indices, not space or spacetime. Thus, the right-hand side of the algebra rule Aμ,Bν−=δμ,ν has for free tensor indices ∅, while the left-hand side has μ,ν, of which μ,ν appear in δμ,ν. To resolve this problem you can: 1. If the dimension of the tensor indices on the left-hand side is 3, then use su2indices that you can define via Setup⁡su2indices=greek. 2. Use the spacetime metric g_, or the space metric gamma_, instead of KroneckerDelta. If so, check the value of: Setup⁡signature. 3. Enter: macro⁡KroneckerDelta=g_; or use gamma_ instead of g_. 4. Define a Kronecker δ tensor. In the following, type 'delta' on the left and 'KroneckerDelta' on the right, or copy and paste: Define⁡δα,β=Matrix⁡4,4,j,k↦δj,k. After any of the above it is recommended that you set this algebra rule again, with the corrected right-hand side, to avoid problems due to having different free indices on each side of the rule.
algebrarules=Aμ,Bν−=δμ,ν
GetAlgebraRuleName(A[mu]);
A
GetAlgebraRules, Physics[Setup]
Physics:-Library:-GetAlgebraRules(A, B, {cackind:list(identical(Physics:-Commutator, Physics:-AntiCommutator)) := [Physics:-Commutator, Physics:-AntiCommutator]})
A, B : two mathematical objects supposed to be related to the operands of a previous definition of an algebra rule of a Commutator or an AntiCommutator
cackind : optional, a list with either or both of Commutator and AntiCommutator, to search in the corresponding tables of previously defined algebra rules
GetAlgebraRules checks the internal tables for algebra rules of Commutators or AntiCommutators set using Setup, that are related to the objects A and B given. The output consists of a sequence of two lists, each containing lists of two elements, respectively defining Commutator and AntiCommutator algebra rules.
GetAlgebraRules(A[mu], B[nu]);
A,B,
Physics:-Library:-GetAntiCommutativeSymbol(x,n := 1)
x : any Maple object such that the anticommutative symbols returned are not already contained in x
n : optional, default value is 1, indicates how many anticommutative symbols are to be returned
GetAntiCommutativeSymbol returns anticommutative symbols (variables of type symbol) taking into account the anticommutative prefix of the moment, set using Setup(anticommutativeprefix). By default it returns 1 symbol; optionally returning as many as the number n passed as second argument. These symbol variables are not found in x, are not assigned, have no attributes previously set, are not local variables and are not visually identical to any local variables found in x; they are also not visually equivalent to the variables used during calls to assuming. This commands is thus a convenient way of getting variables of this type for internal computations within subroutines, that at the same time do not collide with the global variables already present in the computation. If no anticommutative prefix is defined then _Q_ is used as prefix.
GetAntiCommutativeSymbol(x);
_Q_1
type(_lambda1, anticommutative);
GetAntiCommutativeSymbol([_lambda5], 2);
_Q_1,_Q_2
GetCommutativeSymbol, GetNonCommutativeSymbol
Physics:-Library:-GetBasisContinuityInfo(A)
A : a Bra, Ket, or a name
GetBasisContinuityInfo receives a Bra, a Ket, or a name, and returns the name itself (or, the first argument of the Bra or the Ket) when this name was previously set as a label for quantum continuous basis using Setup(quantumcontinuousbasis = {...}), indicating that indeed the input A is related to a quantum continuous basis. If A is not related to any quantum continuous basis already set, the GetBasisContinuityInfo returns the string "unknown".
Setup(quantumcontinuousbasis = A);
quantumcontinuousbasis=A
GetBasisContinuityInfo(A);
GetBasisContinuityInfo(B);
unknown
GetBasisContinuityInfo(Bra(A));
GetBasisDimension, Physics[Setup]
Physics:-Library:-GetBasisDimension(A)
GetBasisDimension receives a Bra, a Ket, or a name, and returns an equation with the name itself (or, the first argument of the Bra or the Ket) in the left-hand side and the dimension of the basis of quantum states in the right-hand side, when this name in the left-hand side was previously set as a label for quantum basis of some dimension n using Setup(quantumbasisdimension = {A = n, ...}). If A is not related to any quantum continuous basis with dimension already set, the command returns the string "unknown".
Setup(quantumbasisdimension = {A = 2});
quantumbasisdimension=A=2
GetBasisDimension(A);
A=2
GetBasisDimension(B);
GetBasisDimension(Bra(A));
GetBasisContinuityInfo, Physics[Setup]
Physics:-Library:-GetCommutativeSymbol(x, n := 1)
x : any Maple object such that the commutative symbols returned are not already contained in x
n : optional, default value is 1, indicates how many commutative symbols are to be returned
GetAntiCommutativeSymbol returns commutative symbols (variables of type symbol) that start with a capital letter, and taking into account the anticommutative and noncommutative prefixes of the moment, set using Setup(anticommutativeprefix) and Setup(noncommutativeprefix). By default, it returns 1; optionally returning as many as the number n passed as second argument. These symbol variables are not found in x, are not assigned, have no attributes that are previously set, are not local variables, and are not visually identical to any local variables found in x; they are also not visually equivalent to the variables used during calls to assuming. This command is thus a convenient way of getting variables of this type for internal computations within subroutines, which at the same time do not collide with the global variables already present in the computation.
Setup(noncommutativeprefix = Z, anticommutativeprefix = theta);
anticommutativeprefix=θ,noncommutativeprefix=Z
GetCommutativeSymbol(x);
F1
GetCommutativeSymbol([F5]);
F6
Setup(additionally, noncommutativeprefix = F);
noncommutativeprefix=F,Z
A1
GetAntiCommutativeSymbol, GetNonCommutativeSymbol
Physics:-Library:-GetCoordinateSystem(`[X]`)
`[X]` : a list of spacetime coordinates of a system of coordinates previously defined with Setup(coordinatesystems = X) or with Coordinates
GetCoordinateSystem searches among the previously defined systems of coordinates to find one that has the same coordinates found in `[X]`, not necessarily with the same ordering. If it finds only one of such a system, it returns it, otherwise it returns FAIL.
Coordinates(Y = spherical);
⁢Systems of spacetime coordinates are:⁢Y=r,θ,φ,t
Y
GetCoordinateSystem([theta,phi,r,t]);
CoordinatesINFO, GetCoordinatesAlias
Physics:-Library:-GetCoordinatesAlias(x)
x : any variable of a system of spacetime coordinates previously set using Setup.
GetCoordinatesAlias receives a coordinate and searches the previously defined systems of spacetime coordinates for a system containing that coordinate. If it finds none, it returns the empty set, {}, Otherwise, the set contains equations, where the left-hand side contains the sequence of coordinates (one of which is the given x), and the right-hand side is the label for this system used in an alias definition to refer to it.
GetCoordinatesAlias(phi);
Y=Y
CoordinatesINFO, GetCoordinateSystem
Physics:-Library:-GetDefineINFO(keyword)
keyword : a string, one of the indices of the table of information Define:-INFO; that is, one of the strings returned by indices(Define:-INFO)
... : other keywords
GetDefineINFO(keyword, ...) gets the value of Define:-INFO[keyword, ...] without fully evaluating it, so as in eval(Define:-INFO[keyword, ...], 1). To see all the possible values of keyword, enter indices(Define:-INFO).
indices(Define:-INFO);
tetradtensors,properties,ElectromagneticFieldStrength,%PhysicsTensors,tetradnullvectors,properties,δ,properties,R,properties,G,properties,antisymmetric,properties,𝕎+,properties,f__su3,properties,g,threeplusonetensors,default_indices_used,su3indices,properties,R,properties,G,default_indices_used,properties,ZFieldStrength,properties,WPlusFieldStrength,default_indices_used,su3matrixindices,properties,η,properties,Τ,feynmandiagramstensors,properties,Γ,standardmodeltensors,GeneralRelativityTensors,defined_%PhysicsTensors,history,properties,δ,properties,λ,properties,𝔽,tensors_in_internal_representation,properties,R,properties,Christoffel,properties,WFieldStrength,defined,cannotbeerased,properties,lambda_,properties,𝔾,properties,FSU3,properties,e_,properties,𝕎−,properties,γ,properties,BFieldStrength,names,properties,symmetric,minimizetensorcomponents,properties,Γ,PhysicsTensors,properties,WMinusFieldStrength,default_indices_used,su2matrixindices,indices,properties,C,linear_operators,properties,γ,properties,R,properties,γ,properties,C,properties,Τ,flipcharacterofindices,default_indices_used,spaceindices,PhysicsTensorNames,properties,noncommutative,properties,R,properties,g,typeoftensorindices,properties,GluonFieldStrength,properties,𝔹,properties,ℤ,properties,Κ,functionality,default_indices_used,su2indices,properties,𝕎,properties,𝔢,linear_tensor_operators,properties,R,properties,eta_,properties,γ,structure
GetDefineINFO("GeneralRelativityTensors");
Lapse,R,Ricci3,Shift,C,e_,γ,l_,m_,mb_,n_,α,R,R,R,β,C,𝔢,γ,γ,l,λ,m,m&conjugate0;,n,Γ,Christoffel3,G,R,Riemann3,TimeVector,gamma3_,lambda_,Γ,Γ,G,R,t,ExtrinsicCurvature,UnitNormalVector,Κ,n
Physics:-Library:-GetDimensionOfIndex(idx)
idx : an index, of space, spacetime, spinor, or gauge kind
GetDimensionOfIndex gets the current dimension for the index idx as set using Setup. If idx is not an index of those kinds, GetDimensionOfIndex returns FAIL.
GetDimensionOfIndex(mu);
4
GetDimensionOfIndex(j);
FAIL
Setup(spaceindices = lowercaselatin);
spaceindices=lowercaselatin
Setup(dimension = 3);
Warning, unable to define the Pauli sigma matrices (Psigma) as a tensor in a spacetime with dimension = 3 where the metric is not Euclidean. You can still refer to the Pauli matrices using Psigmax, Psigmay and Psigmaz
The dimension and signature of the tensor space are set to 3,⁢⁡- - +
dimension=3
2
GetDimensionOfTypeOfIndex, GetDimensionRange
Physics:-Library:-GetDimensionOfTypeOfIndex(t_idx, j := not given)
t_idx : a type of index, one of spacetimeindex, spaceindex, tetradindex, spinorindex, genericindex, su2index, su3index, su2matrixindex, su3matrixindex.
GetDimensionOfTypeOfIndex returns the dimension of the type of index t_idx. If this dimension is not defined, or if the type of index is not previously set using Setup, the command returns FAIL.
GetDimensionOfTypeOfIndex(spacetimeindex);
GetDimensionOfTypeOfIndex(spaceindex);
GetDimensionOfIndex, GetDimensionRange
Physics:-Library:-GetDimensionRange(dim, continuous_basis, U)
dim : an integer or an algebraic expression, or a range of them
continuous_basis : true or false
U : a label of a basis of quantum states, possibly anticommutative (fermionic states)
GetDimensionRange returns a range to be used as a dimension range for the label U of quantum states. When dim is not a range, if continuous_basis = true, this dimension is the range dim..dim, otherwise, if U is anticommutative, the range from 0 to 1, else from 0 to dim-1. When dim is a range, if continuous_basis = false and the first operand of the range dim is half-integer, the range is from 0 to the second operand of dim minus that half integer, otherwise, the range is dim itself.
GetDimensionRange(2, true, U);
−2..2
GetDimensionRange(2, false, U);
0..1
Setup(anticommutativepre = Q, quiet):
GetDimensionRange(2, true, Q);
GetDimensionRange(2, false, Q);
GetDimensionRange(1/2, true, Q);
−12..12
GetDimensionRange(3/2, true, Q);
−32..32
GetDimensionRange(1/2, false, Q);
0..12
GetDimensionRange(3/2, false, Q);
GetDimensionOfIndex, GetDimensionOfTypeOfIndex
Physics:-Library:-GetExistingAnnihilationCreationOperator(notation, fingerprint)
notation : one of implicit, explicit, or anything
fingerprint : a list with an annihilation or creation internal Physics fingerprint; that is, a list with four elements, for example, as in ["annihilation", "label" = psi, "quantum_numbers" = [1, 2, 3], "boson"]
GetExistingAnnihilationCreationOperator searches, among the annihilation and creation operators already set with Annihilation and Creation, for one that has the given fingerprint and got defined with the given notation.
am := Annihilation(A);
am≔a−
fingerprint := [attributes(am)];
fingerprint≔annihilation,label=A,quantum_numbers=1,boson
GetExistingAnnihilationCreationOperator(anything, fingerprint);
a−
evalb(% = am);
Physics:-Library:-GetFingerprint(a)
a : an annihilation or creation operator set with Annihilation or Creation
If a is an annihilation or creation operator set with Annihilation or Creation, then GetFingerprint returns its fingerprint. The fingerprint is an attribute of these operators so it can also be retrieved with the attributes command.
ap := Creation(A);
ap≔a+
GetFingerprint(am);
annihilation,label=A,quantum_numbers=1,boson
GetFingerprint(ap);
creation,label=A,quantum_numbers=1,boson
attributes(ap);
Physics:-Library:-GetGeneralRelativityTensorFunctionalForm(T)
T : a general relativity tensor, a member of GetDefineINFO("GeneralRelativityTensorsWithDependency")
when T is a tensor whose name (its 0th operand) is a member of GetDefineINFO("GeneralRelativityTensors"), GetGeneralRelativityTensorFunctionalForm returns an equation of the form T = T(Q) where Q is the spacetime metric's dependency as indicated by GetSetupINFO("spacetimemetricdependency"). Otherwise, T = T is returned.
GetSetupINFO("GeneralRelativityTensorsWithDependency");
Lapse,R,Ricci3,Shift,C,e_,g,γ,l_,m_,mb_,n_,α,R,R,R,β,C,𝔢,g,γ,γ,γ,l,λ,m,m&conjugate0;,n,Γ,Christoffel3,G,R,Riemann3,TimeVector,gamma3_,lambda_,Γ,Γ,G,R,t,ExtrinsicCurvature,UnitNormalVector,Κ,n
GetSetupINFO("spacetimemetricdependency");
r,θ,m
GetGeneralRelativityTensorFunctionalForm(Einstein[mu, nu]);
Gμ,ν=Gμ,ν⁡r,θ,m
GetGeneralRelativityTensorFunctionalForm(%g_[mu, nu]);
gμ,ν=gμ,ν⁡r,θ,m
FromGeneralRelativityTensorFunctionalForm, ToGeneralRelativityTensorFunctionalForm, Physics[g_]
Physics:-Library:-GetFAndDifferentiationVariables(df)
df : a derivative expressed using :-diff, :-Diff, :-%diff or Physics:-diff
GetFAndDifferentiationVariables receives a derivative and returns a sequence with derivand and all the differentiation variables.
GetFAndDifferentiationVariables(diff(f(x,y,z), x,x, y,y,y, z));
f⁡x,y,z,x,x,y,y,y,z
diff, Physics[diff]
Physics:-Library:-GetIndicesAndCharacter(idxs, T)
idxs : a list of spacetime, space, tetrad, spinor, generic, su2, su3, su2matrix or su3matrix indices
T :
GetIndicesAndCharacter receives a list of indices idxs and the name T of the tensor, and returns a sequence of two lists- the first one with the indices themselves but all covariant (so stripping ~ prefixes), and the second one with the same name of operands, consisting of the keywords covariant or contravariant according to the character of the indices in idxs.
GetIndicesAndCharacter([alpha, beta], Ricci);
α,β,covariant,covariant
GetIndicesAndCharacter([alpha, ~beta], g_);
α,β,covariant,contravariant
GetIndicesAndCharacter([~1, ~2], g_);
1,2,contravariant,contravariant
GetIndicesInUse, GetIndicesOfType, GetNameIndicesVariables, GetTensorIndices
Physics:-Library:-GetIndicesInUse()
GetIndicesInUse receives arguments (any) and returns a set with all the indices in indexed objects or in indexed functions found in these arguments, union with the indices found in the environment variable _Env_Physics_indices_in_use. This routine is useful when dummy contracted indices are to be introduced, and when they cannot be indices that are already present in the expression or are already reserved by assigning them to _Env_Physics_indices_in_use.
expression := g_[alpha, ~beta] * %d_[mu](F[nu](x));
expression≔δαβαβ⁢∂μ⁡Fν⁡x
GetIndicesInUse(expression);
α,β,μ,ν
_Env_Physics_indices_in_use := kappa, rho:
α,β,κ,μ,ν,ρ
GetIndicesAndCharacter, GetIndicesOfType, GetNameIndicesVariables, GetReplacementIndices, GetTensorIndices
Physics:-Library:-GetIndicesOfType(kind::identical(spacetimeindex, spaceindex, tetradindex, spinorindex, genericindex, su2index, su3index, su2matrixindex, su3matrixindex), not_in_ee, N::nonnegint := 1, {character::(identical(Covariant, Contravariant)) := Covariant}, $)
kind : the kind of indices being requested, any of spacetimeindex, spaceindex, tetradindex, spinorindex, genericindex, su2index, su3index, su2matrixindex, su3matrixindex
not_in_ee : any Maple object, typically an expression, equation or a list or set of them - the requested indices must not be present in this second argument
n : optional, default value is 1, indicates the number of indices desired
character = ... : optional, the right-hand side can be Covariant (default) or Contravariant, indicating the character of the indices to be returned
GetIndicesOfType returns indices of the indicated type (kind), according to the kind of letter set in Setup for the kind of indices requested, that are not found in not_in_ee or in _Env_Physics_indices_in_use, and that are not assigned, not attributed, not aliased, or not macroed. The returned indices are covariant by default. To request them to be contravariant, pass the optional argument character = Contravariant. These returned indices can be used when constructing output, for instance, introducing contracted products of tensors without colliding with indices of the expression. If the type of index has not been associated with a kind of letter using Setup, an error message alerting that is displayed. To
Setup(spaceindices=lowercaselatin_is);
spaceindices=lowercaselatin_is
GetIndicesOfType(spacetimeindex, []);
GetIndicesOfType(spacetimeindex, [], character = Contravariant);
GetIndicesOfType(spaceindex, [], 3);
i,j,k
i := 5:
GetIndicesOfType(spaceindex, [a * j + c], 3);
k,l,m
_Env_Physics_indices_in_use := m;
_Env_Physics_indices_in_use≔m
GetIndicesOfType(spaceindex, [a * j + c], 3, character = Contravariant);
~k,~l,~n
GetIndicesAndCharacter, GetIndicesInUse, GetNameIndicesVariables, GetReplacementIndices, GetTensorIndices, GetTypeOfIndex
Physics:-Library:-GetNameIndicesVariables(A)
A : a symbol variable as in A or an indexed one, a function or an indexed function as in A[mu](x, y ,z); it can also be a power, conjugate, or Dagger of such an object, or a tensor in the Physics internal representation (see ToTensorInternalRepresentation)
GetNameIndicesVariables returns a sequence of four operands - say for F[mu, nu](x, y, z) that sequence would be F, F[mu, nu], [mu, nu], [x, y, z]. When the object is just indexed, no functionality, the last list is empty, as in []. When the name of the object has no indices, the third list is empty, and the first and second elements are equal. When A is a power, the commands applies to the first operand of A. If A is a conjugate or Dagger function, it works like when it is a power, but the first element returned is conjugate or Dagger applied to the name of the object. If A is a tensor in the Physics internal representation, first the natural (user) representation is restored, then GetNameIndicesVariables is applied to that result.
GetNameIndicesVariables(A);
A,A,,
GetNameIndicesVariables(A[mu]);
A,Aμ,μ,
GetNameIndicesVariables(A(x,y));
A,A,,x,y
GetNameIndicesVariables(A[mu](x,y));
A,Aμ,μ,x,y
GetNameIndicesVariables(A[mu](x,y)^n);
GetNameIndicesVariables('Dagger'(A[mu](x,y)));
A†,Aμ,μ,x,y
GetIndicesAndCharacter, GetIndicesInUse, GetIndicesOfType, GetTensorIndices
Physics:-Library:-GetNameWithIndices(T)
T : a function, possibly indexed, or a Dagger or conjugate of it.
GetNameWithIndices returns the name of the function call along with its indices, if any. When this function is itself a Dagger or conjugate of another function, the functionality is stripped from that function, and the Dagger or conjugate applied to the result is returned. This routine is useful to expose the indices of a nested expression while getting its name.
GetNameWithIndices(A);
GetNameWithIndices(A[mu](x,y,z));
Aμ
GetNameWithIndices('Dagger(A[mu](x,y,z))');
A†μ
Physics:-Library:-GetNameWithoutIndices(T)
GetNameWithoutIndices returns the same as GetNameWithIndices but without the indices. See GetNameWithIndices.
GetNameWithoutIndices(A);
GetNameWithoutIndices(A[mu](x,y,z));
GetNameWithoutIndices('Dagger(A[mu](x,y,z))');
A†
Physics:-Library:-GetNonCommutativeSymbol(x, n := 1)
x : any Maple object such that the noncommutative symbols returned are not already contained in x
n : optional, default value is 1, indicates how many noncommutative symbols are to be returned
GetNonCommutativeSymbol returns noncommutative symbols (variables of type symbol), taking into account the noncommutative prefix of the moment set using Setup(anticommutativeprefix). By default, it returns 1; optionally returning as many as the number n which is passed as the second argument. These symbol variables are not found in x, are not assigned, have no attributes that were previously set, are not local variables, and are not visually identical to any local variables found in x; they are also not visually equivalent to the variables used during calls to assuming. This commands is thus a convenient way of getting variables of this type for internal computations within subroutines, which at the same time do not collide with the global variables already present in the computation. If no noncommutative prefix is defined then Physics:-_Z_ is used as prefix and the variables are returned indexed, such as _Z_[1], and so on.
GetNonCommutativeSymbol(x);
_Z_1
type(_Z[1], noncommutative);
Z1
GetNonCommutativeSymbol([Z4]);
Z5
GetAntiCommutativeSymbol, GetCommutativeSymbol
Physics:-Library:-GetNotCommutativeNamesAndFunctions(ee, {ignorewithinfunctions::truefalse := false, onlyanticommutative::truefalse := false})
ee : any Maple object, typically an algebraic expression
ignorewithinfunctions : optional, to disregard not commutative names and functions found only within functions
onlyanticommutative : optional, to disregard noncommutative objects and only return anticommutative ones
GetNotCommutativeNamesAndFunctions returns the not commutative (that is, of types noncommutative or anticommutative) names and functions found in ee, optionally disregarding names and functions found only within functions, and optionally returning only the objects of type anticommutative, disregarding those of type noncommutative.
Setup(quantumoperators = {A,B}, anticommutativeprefix = Q);
anticommutativeprefix=Q,quantumoperators=A,B
ee := A(x) + F(B(x)) + Q1 + H(Q2);
ee≔A⁡x+F⁡B⁡x+Q1+H⁡Q2
GetNotCommutativeNamesAndFunctions(ee);
A,B,Q1,Q2,A⁡x,B⁡x,F⁡B⁡x
GetNotCommutativeNamesAndFunctions(ee, ignorewithinfunctions);
A,Q1,A⁡x
Physics:-Library:-GetProjectorCore(P::Physics:-Projector)
P : a projector, of type Library:-PhysicsType:-Projector
GetProjectorCore receives a projector P and returns a sequence of four elements. The first element is the projector's core. For example, if P is a sum (perhaps a multiple sum), then its core is the inner-most summand, or if P is an integral, then its core is the inner-most integrand. The second element is a list with the number 1 repeated as many times as the nesting level, so if it is not a multiple sum this list is [1]. The third element is a list with the dummies of the sum or integral, that is, with as many dummies as the nesting level. The fourth element is also a list with the summation or integration ranges representing the dimension (possibly multi-dimension) of the projector.
P := Sum(Ket(A, n)*Bra(A, n), n = 0 .. 2);
P≔∑n=02⁡An⁢An
GetProjectorCore(P);
An⁢An,1,n,0..2
P := Int(Int(Int(Ket(R, x, y, z)*Bra(R, x, y, z), x = -infinity .. infinity), y = -infinity .. infinity), z = -infinity .. infinity);
P≔∫−∞∞∫−∞∞∫−∞∞Rx,y,z⁢Rx,y,zⅆxⅆyⅆz
Rx,y,z⁢Rx,y,z,1,1,1,z,y,x,−∞..∞,−∞..∞,−∞..∞
Physics:-Library:-GetReplacementIndices(idx_to_be_replaced::Or(list, set))
idx_to_be_replaced : a list of indices to be replaced; these could be sspacetime, space, tetrad, spinor, generic, su2, su3, su2matrix or su3matrix indices
GetReplacementIndices returns a sequence of two objects L, S, where L is a list of four lists, each one containing equations with replacements of the indices of spacetime, space, spinor, and gauge types found in idx_to_be_replaced, and S is a set containing all the indices in use as found in the environment variable _Env_Physics_indices_in_use if any, including the new indices introduced as replacements. All the replacement indices returned are also not found in any additional arguments passed to GetReplacementIndices or in the environment variable _Env_Physics_indices_in_use, and the lists returned include equations for both covariant and contravariant indices.
Setup(spaceindices=lowercaselatin_is, spinorindices = lowercaselatin_ah, genericindices = uppercaselatin);
genericindices=uppercaselatin,spaceindices=lowercaselatin_is,spinorindices=lowercaselatin_ah
GetReplacementIndices([mu, a, i, B]);
μ=ν,~μ=~ν,i=j,~i=~j,a=b,~a=~b,B=A,~B=~A,A,b,j,ν
Get replacement indices that are not j, b or A
GetReplacementIndices([mu, a, i, B], [j, b, A]);
μ=ν,~μ=~ν,i=k,~i=~k,a=c,~a=~c,B=C,~B=~C,C,c,k,ν
Assigning a set of indices to _Env_Physics_indices_in_use makes GetReplacementIndices to not return those indices
_Env_Physics_indices_in_use := {j, b, A, k, C};
_Env_Physics_indices_in_use≔A,C,b,j,k
μ=ν,~μ=~ν,i=l,~i=~l,a=c,~a=~c,B=E,~B=~E,A,C,E,b,c,j,k,l,ν
GetIndicesAndCharacter, GetIndicesInUse, GetNameIndicesVariables, GetTensorIndices, GetTypeOfIndex
Physics:-Library:-GetSetupINFO()
keyword : a string, one of the indices of the table of information of the Physics Setup; that is, one of the strings returned after entering kernelopts(opaquemodules = false); indices(Physics:-SetupINFO)
GetSetupINFO(keyword, ...) gets the value of Physics:-SetupINFO[keyword, ...] without fully evaluating it, so as in eval(Physics:-SetupINFO[keyword, ...], 1). To see all the possible values of keyword, enter kernelopts(opaquemodules = false); indices(Physics:-SetupINFO).
kernelopts(opaquemodules = false):
GetSetupINFO("coordinatesystems");
none
GetSetupINFO("spacetimeindices");
greek
Physics:-Library:-GetSpaceTimeVectors(ee,{evaluateatintegers::truefalse := true})
ee : a mathematical expression possibly involving the spacetime vectors written as a sequence of spacetime coordinates X indexed, as in X[mu]
GetSpaceTimeVectors returns a set of equations where in the left-hand side there are spacetime vectors written as indexed sequences of spacetime coordinates, and in the right-hand side there are the equivalent spacetime vectors written in the SpaceTimeVector[mu](X) notation. Note that the product operator * of Physics automatically performs this normalization of products.
ee := X[mu];
ee≔Xμ
map(``, [op(0, ee)]);
Due to the use of alias, lhs and rhs look alike; use lprint to see the difference
GetSpaceTimeVectors(ee);
Xμ=Xμ
lprint(%);
{(X)[mu] = Physics:-SpaceTimeVector[mu](X)}
FromSpaceTimeVector, ToSpaceTimeVector
Physics:-Library:-GetSumIntCore(P::specfunc(anything,[sum, Sum, %sum, int, Int, %int]))
P : a projector not set using the Projector command of Physics, and not necessarily involving Kets or Bras. P is just expressed in terms of sum, Sum, int or Int, possibly nested
GetSumIntCore receives P, that could be interpreted as a projector but was not constructed by the Projector command of Physics, and it returns the same sequence of four elements returned by GetProjectorCore. See GetProjectorCore in this same help page.
ee := Sum(Int(c[n]*K[n](x)*B[n](x), x=-infinity..infinity), n=-3..3);
ee≔∑n=−33⁡∫−∞∞cn⁢Kn⁡x⁢Bn⁡xⅆx
GetSumIntCore(ee);
Sum,Int,cn⁢Kn⁡x⁢Bn⁡x,1,1,n,x,−3..3,−∞..∞
Physics:-Library:-GetSymbolsWithSameType(x, other, N))
x : a Maple algebraic object of type commutative, anticommutative, or noncommutative
other : any other Maple object, typically a list or set of algebraic objects or variables; the returned symbols should not be contained within other
N : optional, default value is 1, the number of symbols with the same type of x to be returned
GetSymbolsWithSameType receives an expression x, of type commutative, anticommutative, or noncommutative, along with any other argument, and returns symbols of the same type as x, and not present in the rest of arguments.
Setup(anticommutativeprefix = w, noncommutativeprefix = z);
anticommutativeprefix=w,noncommutativeprefix=z
GetSymbolsWithSameType(x, [x1], 2);
F1,F2
GetSymbolsWithSameType(w1 * w2, [F2], 2);
F3,F4
GetSymbolsWithSameType(w1 - w2, [x1], 2);
w3,w4
GetSymbolsWithSameType(z1 + z2, [z4], 3);
z5,z6,z7
GetAntiCommutativeSymbol,GetCommutativeSymbol, GetNonCommutativeSymbol, GetReplacementIndices
Physics:-Library:-GetTensorDependency(T)
T : a tensor, defined as such using the Define command, or one of the general relativity tensors automatically defined when you load Physics.
GetTensorDependency gets the dependency of an indexed object defined as a tensor using Define, or when the indexed object is one of the general relativity tensors automatically defined when Physics is loaded.
You can now compute with pμ itself without indicating the dependency; the system already knows this from its definition (as mentioned earlier), so for instance these two derivatives do not return 0.
[diff(p[mu], t), d_[nu](p[mu])];
∂∂tpμ,∂ν⁡pμ
You can make the dependency on m and t explicit, remove it, or just compute it with the purpose of further manipulations.
GetTensorDependency(p[mu]);
t,m
ToTensorFunctionalForm((224));
p.μ⁡t,m,∂ν⁡pμ⁡t,m,pμ=pμ⁡t,m
FromTensorFunctionalForm((226)[1]);
∂∂tpμ,∂ν⁡pμ,pμ⁡t,m=pμ
Set a non-flat spacetime metric, for instance:
All the general relativity tensors now have dependency.
Einstein[mu, nu];
Gμ,ν
GetTensorDependency((229));
GetTensorFunctionalForm, FromTensorFunctionalForm, ToTensorFunctionalForm
Physics:-Library:-GetTensorFunctionalForm(T)
T : a tensor defined using Define, or general relativity tensor
GetTensorFunctionalForm is a generalization of the former GetGeneralRelativityTensorFunctionalForm command that also handles tensor functions you define using Define. So when T is a tensor of any of those kinds, GetTensorFunctionalForm returns an equation of the form T = T(Q) where Q is the dependency of T. Otherwise, the T = T is returned.
The system now knows about this dependency on t and m, so that in most cases can compute with pμ itself, without making explicit the dependency on m and t; for example, these derivatives of pμ are not zero.
You can put, remove, or get the functionality of pμ.
ToTensorFunctionalForm((233));
FromTensorFunctionalForm((234)[1]);
GetTensorFunctionalForm(p[mu]);
pμ=pμ⁡t,m
GetTensorFunctionalForm(g_[mu,nu]);
FromGeneralRelativityTensorFunctionalForm, FromTensorFunctionalForm, GetGeneralRelativityTensorFunctionalForm ToGeneralRelativityTensorFunctionalForm, ToTensorFunctionalForm, Physics[Define], Physics[g_]
Physics:-Library:-GetTensorIndices(T)
T : a tensor, defined as such using the Define command, so that type(T, PhysicsType:-Tensor) = true. T can also be a tensor function or even a composed tensor function, such as in dAlembertian(T[mu,nu](X))
GetTensorIndices returns a list with the indices found in the tensor T. If T is not a tensor, the empty list [] is returned.
Define(T, quiet):
ee := d_[mu](T[alpha, beta](X));
ee≔∂μ⁡Tα,β⁡X
GetTensorIndices(ee);
μ,α,β
GetIndicesAndCharacter, GetIndicesInUse, GetIndicesOfType, GetNameIndicesVariables, GetReplacementIndices, GetTensorNamesInExpression, GetTensorSymmetryProperties
Physics:-Library:-GetTensorNamesInExpression(expr)
expr : any expression, or generally a Maple object with its contents visible (not a table)
GetTensorNamesInExpression returns the names of the tensors present in expr.
Define(A, quiet):
expr := g_[mu,nu] * A[alpha] * A[beta] + LeviCivita[alpha, beta, mu, nu] + KroneckerDelta[alpha, beta] * KroneckerDelta[mu, nu];
expr≔gμ,ν⁢Aα⁢Aβ+δα,β⁢δμ,ν+εα,β,μ,ν
GetTensorNamesInExpression(expr);
A,g,ε
GetTensorIndices, GetTensorSymmetryProperties
Physics:-Library:-GetTensorSymmetryProperties(T)
T : a tensor, of type PhysicsType:-Tensor
GetTensorSymmetryProperties returns a sequence of two sets; the first one with an indication of the indices with respect to which T is symmetric, the second one with respect to which T is antisymmetric. These sets contain lists with the numerical positions of indices representing the symmetries of T as explained in the help page for Physics[Define].
g_[sc]:
Define(A, H, symmetric, quiet):
Define(G, antisymmetric, quiet):
EM := F[mu,nu] = D_[mu](A[nu](X)) - D_[nu](A[mu](X));
EM≔Fμ,ν=▿μ⁡Aν⁡X−▿ν⁡Aμ⁡X
Define(EM, quiet):
GetTensorSymmetryProperties(A);
∅,∅
GetTensorSymmetryProperties(H[mu, nu]);
1,2,∅
GetTensorSymmetryProperties(G[alpha, mu, nu]);
∅,1,2,3
GetTensorSymmetryProperties(F[mu, nu](X));
∅,1,2
GetTensorSymmetryProperties(Riemann[alpha, beta, mu, nu]);
1,2,3,4,1,2,3,4
GetTensorIndices, GetTensorNamesInExpression, NormalizeTensorExpression
Physics:-Library:-GetTypeOfIndex(idx)
idx : an index of any of the types spacetimeindex, spaceindex, tetradindex, spinorindex, genericindex, su2index, su3index, su2matrixindex or su3matrixindex
GetTypeOfIndex returns the type of the index idx when it is one of spacetimeindex, spaceindex, tetradindex, spinorindex, genericindex, su2index, su3index, su2matrixindex or su3matrixindex; otherwise it returns FAIL.
GetTypeOfIndex(mu);
spacetimeindex
GetTypeOfIndex(j);
GetIndicesAndCharacter, GetIndicesInUse, GetNameIndicesVariables, GetTensorIndices, GetTypeOfIndex, IndicesOfKindOfLetter, RootOfIndex
Physics:-Library:-HasAfterAtomizingNames(a, b)
a :
b :
HasAfterAtomizingNames first transforms indexed objects into atomized symbols, then calls has, as in has(a_with_all_indexed_atomized, b_with_all_indexed_atomized). This is particularly relevant when working in jet notation, where x and u[x] (derivative of u) represent independent objects, or when indexing vectors just to represent their components, as in V[x] (the projection of V over the x axis).
has(a[x], x);
HasAfterAtomizingNames(a[x], x);
has(f[a[x]], a[x]);
HasAfterAtomizingNames(f[a[x]], a[x]);
HasAfterAtomizingNames(f(a[x]) + a[x], a[x]);
has
Physics:-Library:-IndicesOfKindOfLetter(n)
n : any integer between 1 and 5
IndicesOfKindOfLetter returns a sequence of three elements: a list followed by two numbers. The list contains the letters available for the indices corresponding to the given number n, where this correspondence is 1 = greek, 2 = lowercaselatin, 3 = lowercaselatin_ah, 4 = lowercaselatin_is, and 5 = uppercaselatin. The two numbers that follow the list are the minimum and maximum lengths of such an index, respectively.
IndicesOfKindOfLetter(1);
α,β,γ,δ,ζ,η,θ,ι,κ,λ,μ,ν,ξ,ο,π,ρ,σ,τ,υ,φ,χ,ψ,ω,ε,ϵ,ϰ,ϕ,ϖ,ϱ,ς,ϑ,2,10
IndicesOfKindOfLetter(2);
a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,1,1
IndicesOfKindOfLetter(3);
a,b,c,d,e,f,g,h,1,1
IndicesOfKindOfLetter(4);
i,j,k,l,m,n,o,p,q,r,s,1,1
IndicesOfKindOfLetter(5);
A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,1,1
GetTypeOfIndex, RootOfIndex
Physics:-Library:-InertProductToInertPower(A)
A : an algebraic expression entering, the first operand of an inert product
rest : any other argument, also operands of the inert product
InertProductToInertPower receives a sequence of arguments supposed to be operands of an inert product and, taking their commutative, anticommutative, or noncommutative character, returns the inert product of them with rewriting as inert powers any two or more contiguous operands that are identical. Note that this command receives the operands of an inert product, not the inert product itself, and returns an inert product. Inert products are represented by the function %*, for example as in %*(A, B, C).
ee := InertProductToInertPower(Z2, Z1, Z1, Z3);
ee≔Z2∗Z12∗Z3
lprint(ee);
Physics:-`%*`(Z2,Z1 %^ 2,Z3)
Physics[*], Physics[^], PowerToProduct
Physics:-Library:-IsACSuffixed(x0)
x0 : any symbol variable
IsACSuffixed and IsNCSuffixed return true or false according to whether or not x0 is a symbol of type global and an anticommutative (for IsACSuffixed) or a noncommutative (for IsNCSuffixed) prefix itself, which is set using Setup, or suffixed by any of these anticommutative or noncommutative prefixes and followed by an integer. Note that the (new in Maple 17) so-called literal subscripted variables are allowed, so that if Q is an anticommutative prefix, then both Q5 and Q_5 are considered anticommutative. Similarly, if Z is a noncommutative prefix, then both Z5 and Z_5 are considered noncommutative.
Setup(anticommutativeprefix = {Q, theta});
anticommutativeprefix=Q,θ
IsACSuffixed(Q);
IsACSuffixed(Q5);
IsACSuffixed(Qn);
IsACSuffixed(Q__5);
IsAntiCommutatorVariable, IsCommutatorVariable, IsNCSuffixed, type/anticommutative, type/noncommutative
Physics:-Library:-IsAntiCommutatorVariable(x)
x : any name variable or a tensor, of type PhysicsType:-Tensor
IsAntiCommutatorVariable return true or false according to whether x entered an AntiCommutator algebra rule with right-hand side equal to zero, set using Setup.
Setup(%AntiCommutator(A, B) = 0);
algebrarules=A,B+=0
IsAntiCommutatorVariable(A);
IsAntiCommutatorVariable(B);
IsAntiCommutatorVariable(C);
IsACSuffixed, IsCommutatorVariable, IsNCSuffixed, type/anticommutative, type/noncommutative
Physics:-Library:-IsCommutatorVariable(x)
IsCommutatorVariable return true or false according to whether x entered a Commutator algebra rule with right-hand side not equal to zero, set using Setup.
Setup(%Commutator(A, B) = C);
algebrarules=A,B−=C
IsCommutatorVariable(A);
IsCommutatorVariable(B);
IsCommutatorVariable(C);
IsACSuffixed, IsAntiCommutatorVariable, IsNCSuffixed, type/anticommutative, type/noncommutative
Physics:-Library:-IsContravariant(mu)
IsContravariant receives an index mu, and returns true or false depending on whether mu is contravariant or not. The distinction between covariant and contravariant is that the second one is prefixed with ~.
IsContravariant(~mu);
IsCovariant(mu);
Physics:-Library:-IsCovariant(mu)
IsCovariant receives an index mu, and returns true or false depending on whether mu is covariant or not. The distinction between covariant and contravariant is that the second one is prefixed with ~.
IsCovariant(~mu);
Physics:-Library:-IsHermitianOperator(A)
A : a symbol or an algebraic expression
IsHermitianOperator returns true or false depending on whether A is a Hermitian operator operator or not.
Setup(hermitian = {A, B}, unitary = {C}, quantumoperators = {F,G});
* Partial match of 'hermitian' against keyword 'hermitianoperators'
* Partial match of 'unitary' against keyword 'unitaryoperators'
hermitianoperators=A,B,quantumoperators=A,B,C,F,G,unitaryoperators=C
[hermitianoperators = {A, B}, quantumoperators = {A, B, C, F, G}, unitaryoperators = {C}]
IsHermitianOperator(A);
IsHermitianOperator(C);
IsUnitaryOperator(C);
IsUnitaryOperator(F);
IsHermitianOperator(F);
select(type, [A, B, C, F, G], PhysicsType:-QuantumOperator);
A,B,C,F,G
select(type, [A, B, C, F, G], PhysicsType:-HermitianOperator);
A,B
select(type, [A, B, C, F, G], PhysicsType:-UnitaryOperator);
C
Physics:-Library:-IsLiteralSubscript(u)
u : any symbol variable
IsLiteralSubscript returns true or false depending on whether a symbol u is of the form x__y, that is, it has the substring __ after the first or next characters and before the last one.
[x, x_y, __y, x__y, x__, x___y];
x,x_y,__y,x__y,x__,x___y
map(IsLiteralSubscript, (291));
false,false,false,true,false,true
IsACSuffixed, IsNCSuffixed
Physics:-Library:-IsNCSuffixed(x0)
IsACSuffixed and IsNCSuffixed return true or false according to whether x0 is or not a symbol of type global and, respectively, an anticommutative (IsACSuffixed) or noncommutative (IsNCSuffixed) prefix itself, set using Setup, or suffixed by any of these anticommutative or noncommutative prefixes and followed by an integer. Note that the (new in Maple 17) so-called literal subscripted variables are allowed, so that if Q is an anticommutative prefix, then both Q5 and Q_5 are considered anticommutative. Likely, if Z is an noncommutative prefix, then both Z5 and Z_5 are considered noncommutative.
IsACSuffixed, IsAntiCommutatorVariable, IsCommutatorVariable, type/anticommutative, type/noncommutative
Physics:-Library:-IsRealObject(A)
A : an algebraic expression, could be a function or just a symbol
IsRealObject returns true or false according to whether a function or variable passed is known to be real, either because it was assumed to be real, or because it was set to be real using Setup and its realobjects keyword.
restart: with(Physics): with(Vectors): with(Library):
The real objects after loading Vectors are
Setup(realobjects);
realobjects=φ,r,ρ,θ,x,y,z
F_ &x G_;
F→×G→
IsRealObject((299));
Setup(real = {F_, G_});
* Partial match of 'real' against keyword 'realobjects'
realobjects=F→,G→,φ,r,ρ,θ,x,y,z
Note also that the is command queries IsRealObject and therefore knows that the product of these two vectors is real, and through it, the rest of the Maple library has access to this information.
is((299), real);
F_ . G_;
F→·G→
IsRealObject((304));
is((304), real);
assume, assuming, is, coulditbe, RealObjects, Physics[Setup]
Physics:-Library:-IsTensorInCurrentCoordinates(T,{ignore::set := {}})
ignore : a set with galilean tensor exceptions
IsTensorInCurrentCoordinates returns true or false depending on whether T is a tensor or not (of type PhysicsType:-Tensor) in the current coordinates (spacetime metric). For example, in a nongalilean spacetime, neither the spacetime vector nor its differentials are tensors.
IsTensorInCurrentCoordinates(A[mu]);
IsTensorInCurrentCoordinates(X[mu]);
IsTensorInCurrentCoordinates(d_[mu](A[nu](X)));
IsTensorInCurrentCoordinates(D_[mu](A[nu](X)));
Physics[g_]
Physics:-Library:-IsTensorialAntisymmetric(EE::algebraic, idx::list := NULL,{covariantandcontravariant::truefalse := true, totensorinternalrepresentation::truefalse := true})
EE : an algebraic, tensorial expression with free indices; of type PhysicsType:-ExtendedTensor
idx : optional, a list of indices. If this is not given, all free indices of EE are included. The antisymmetry is with respect to all the permutations of pairs of these indices
totensorinternalrepresentation : optional, true (default) or false, to rewrite tensors in EE in the tensor internal Physics representation before proceeding.
IsTensorialAntisymmetric and IsTensorialSymmetric return true or false depending on whether E is, totally antisymmetric or totally symmetric with respect to all of its free indices, or only with respect to permutations of an optional idx list of indices that is passed. By default, before proceeding, IsTensorialAntisymmetric and IsTensorialSymmetric rewrite the tensors in the expression EE in the internal Physics representation; this can be avoided using the optional argument totensorinternalrepresentation = false
Define(H, symmetric, quiet):
EM := F[mu,nu] = d_[mu](A[nu](X)) - d_[nu](A[mu](X));
EM≔Fμ,ν=∂μ⁡Aν⁡X−∂ν⁡Aμ⁡X
IsTensorialAntisymmetric(H[mu, nu]);
IsTensorialAntisymmetric(G[mu, nu]);
IsTensorialAntisymmetric(F[mu, nu]);
IsTensorialAntisymmetric(Riemann[alpha, beta, mu, nu]);
IsTensorialAntisymmetric(Riemann[alpha, beta, mu, nu], [mu, nu]);
IsTensorialSymmetric(Christoffel[mu, alpha, beta]);
IsTensorialSymmetric(Christoffel[mu, alpha, beta], [alpha, beta]);
FromTensorInternalRepresentation, IsTensorialSymmetric, ToTensorInternalRepresentation, Physics[g_]
Physics:-Library:-IsTensorialSymmetric(EE::algebraic, idx::list := NULL,{covariantandcontravariant::truefalse := true, totensorinternalrepresentation::truefalse := true})
EE : an algebraic, tensorial expression with free indices, of type PhysicsType:-ExtendedTensor
IsTensorialAntisymmetric and IsTensorialSymmetric return true or false depending on whether E is, respectively totally antisymmetric or totally symmetric with respect to all of its free indices, or only with respect to permutations of an optional idx list of indices that is passed. By default, before proceeding, IsTensorialAntisymmetric and IsTensorialSymmetric rewrite the tensors in the expression EE in the internal Physics representation; this can be avoided using the optional argument totensorinternalrepresentation = false
FromTensorInternalRepresentation, IsTensorialAntisymmetric, ToTensorInternalRepresentation, Physics[g_]
Physics:-Library:-IsUnitaryOperator(A)
IsUnitaryOperator returns true or false based on whether A is a Unitary operator or not.
Physics:-Library:-IsVectorSymbol(v)
v : an object of type symbol
IsVectorSymbol returns true or false if v is a vector symbol, that is, one suffixed by the value of Setup(vectorpostfix), by any of the orthonormal unit vectors of the cartesian, cylindrical, or spherical basis, or by any of the vectorial differential operators Nabla, Gradient, Divergence, or Curl. You can also use a literal subscript variable as a vector symbol: suppose the vectorpostfix is the underscore, _, then A__x_ is a vector symbol, displayed as A indexed x with an arrow on top of A.
Setup(vectorpostfix);
vectorpostfix=none
with(Vectors):
vectorpostfix=_
IsVectorSymbol(Nabla);
IsVectorSymbol(_i);
IsVectorSymbol(A_);
IsVectorSymbol(A__x_);
Physics[Vectors]
Physics:-Library:-ListPhysicsTypes({showdefinition::truefalse := false})
showdefinition : optional, when given, the output consists of a list of equations with the type in the left-hand side and its definition in the right-hand side
ListPhysicsTypes returns a list of all the Physics types, the exports of the module Library:-PhysicsType, but without loading any of them into the global space of names. ListPhysicsTypes can also show the definition of the type when passing the optional argument showdefinition. This is handy and more readable than the equivalent call to TypeTools:-GetType(PhysicsType:-any_Physics_type_here).
PhysicsType, type, TypeTools[GetType]
Physics:-Library:-NestLeftAssociative(p, a, b)
p : anything representing a procedure that takes two arguments
a, b, ... : to be the arguments of p
NestLeftAssociative applies p to the received arguments, recursively, assuming p takes only two arguments at a time, and that it is left associative. The expression is constructed without actually applying p at any moment. This is the same operation that transforms diff(f(x, y, z), x, y, z) into diff(diff(diff(f(x, y, z), x), y), z).
NestLeftAssociative(p, a,b,c,d);
p⁡p⁡p⁡a,b,c,d
eval
Physics:-Library:-NormalizeTensor(T,{usedefinition::truefalse := true})
NormalizeTensor normalizes the tensor T with respect to the symmetry properties of its indices. This normalization aims to return the different manners of expression T that are mathematically equivalent in a canonical form. Symmetry properties of tensors are indicated when the tensor is defined using Define. Note that tensors defined using a tensorial equation are automatically normalized, so NormalizeTensor is mostly relevant for definitions not using a tensorial equation or when performing manipulations of indices inside a program.
Define(F, antisymmetric, quiet):
F[alpha, beta];
Fα,β
The normalization is not automatic; use NormalizeTensor
ee := F[beta, alpha];
ee≔Fβ,α
NormalizeTensor(ee);
−Fα,β
Define(A, quiet);
A,F,γμ,σμ,∂μ,gμ,ν,εα,β,μ,ν,Xμ
F[mu,nu];
Fμ,ν
The normalization is automatic when the definition used a tensorial equation
F[nu, mu];
−Fμ,ν
GetTensorSymmetryProperties, NormalizeTensorExpression, Physics[Define]
Physics:-Library:-NormalizeTensorExpression(EE, {tensors::set(Physics:-Tensor) := {}, totensorinternalrepresentation::truefalse := true})
EE : an algebraic tensorial expression tensor or a relation between them, or an Array of them
tensors : optional, a set of tensors, to normalize only occurrences of these tensors in EE
totensorinternalrepresentation : optional, it can be true (default) or false, to rewrite the tensors in the tensor internal Physics representation before proceeding
NormalizeTensorExpression normalizes all the tensors found in EE as explained in NormalizeTensor. To restrict this operation to a subset of the tensors found in EE, use the optional argument tensors = {...}. To avoid rewriting all the tensors in EE in the tensor internal Physics representation, use totensorinternalrepresentation = false. Note that NormalizeTensorExpression does not perform any simplification of contracted indices - it only rewrites the tensors of EE in a canonical form permitting identifying that two tensors with the same indices are actually the same tensor (this not obvious when the tensor has symmetry properties).
ee := F[alpha, beta] + F[beta, alpha];
ee≔Fα,β+Fβ,α
The normalization is not automatic; use NormalizeTensorExpression.
NormalizeTensorExpression(ee);
0
GetTensorSymmetryProperties, NormalizeTensor
Physics:-Library:-OperationOnInertCommand(operation, inert_command, {inertize::set(symbol) := {}})
operation : an operation to be performed on an inert_command function call, in a case where it is known how to perform the same operation on the related command function call (the non-inert version)
inert_command : the inert_command name, a symbol starting with % and followed by the name of a Maple command
inertize : optional, a set of non-inert command names that should be inertized before proceeding with the operation to be performed
OperationOnInertCommand is a handy tool to perform operations on an inert command - say F - when operation/F is a procedure, so the system knows how to apply that operation on F, just no particular instruction exists about %F. The operation to be performed is the first argument, the name of the inert command is the second argument, inert_command, and the _rest of arguments passed to OperationOnInertCommand are the arguments of inert_command. Optionally, a set inertize = {.. other command names ..} makes these other command names be inertized (replacing each foo by %foo) before proceeding. CAVEAT: as of Maple 17, the only operations handled by this command are operations that take only one argument, so for instance, it can be used for normal, but not for int or diff.
OperationOnInertCommand(expand, %exp, f(x) + g(x));
ⅇf⁡x⁢ⅇg⁡x
OperationOnInertCommand(expand, %exp, f(x) + g(x), inertize = {f});
OperationOnInertCommand(expand, %exp, sin(a + b));
ⅇsin⁡a⁢cos⁡b⁢ⅇcos⁡a⁢sin⁡b
OperationOnInertCommand(expand, %exp, sin(a + b), inertize = {sin, cos});
value
The Physics types available are:
with(PhysicsType);
nops((369));
124
To see the definition of the type, either use ListPhysicsTypes or TypeTools:-GetType.
ListPhysicsTypes(ExtendedTensor, showdefinition);
ExtendedTensor=algebraic∧satisfies⁡u↦CheckIndices⁡u,free,noerror::¬identical⁡FAIL,∅
TypeTools:-GetType(ExtendedTensor);
algebraic∧satisfies⁡u↦CheckIndices⁡u,free,noerror::¬identical⁡FAIL,∅
ListPhysicsTypes, type, TypeTools[GetType]
Physics:-Library:-PowerToProduct(A, B)
A, B : the base and the exponent of a power
If A is not commutative and B is an integer, PowerToProduct returns a non-evaluated product of A and B using the Physics:-* operator. This appears either in the numerator or in the denominator depending on whether B is positive or negative; and if B is not an integer, PowerToProduct returns an unevaluated AB where ^ is the Physics:-^ power operator. On the other hand, if A is commutative, it returns the A^B using the global commutative :-^ operator.
PowerToProduct(A,3);
A3
PowerToProduct(Z,3);
Z⁢Z⁢Z
lprint(PowerToProduct(A,n));
A^n
lprint(PowerToProduct(Z,n));
Physics:-`^`(Z,n)
InertProductToInertPower, Physics[*], Physics[^]
Physics:-Library:-PrintWithTypesetting(msgString, msgParam1, msgParam2, ...)
msgString : the text container, as a message string, as the first argument of the error command
msgParam1, msgParam2 : parameters to substitute into msgString
The difference between the standard print command and PrintWithTypesetting is that with the latter you can construct sentences mixing text and mathematical formulas systematically, such that the formulas appear in the middle of the text and with full typesetting. The syntax being the same as that of the WARNING and error messages.
The msgString is thus a string value that is independent of any parameters that are to be part of the message. The string typically contains numbered parameters of the form %n, where n is an integer, to be replaced by the text or formulas or any valid computational Maple object (lists, sets, etc.).
PrintWithTypesetting("This is %1 and that is %2, so formulas within the text, involving special characters like %3 and %4, and with typesetting", cos(theta), exp(Int(sin(varphi),varphi=1..2)), theta, varphi);
This is cos⁡θ and that is ⅇ∫12sin⁡ϕⅆϕ, so formulas within the text, involving special characters like θ and ϕ, and with typesetting
print
Physics:-Library:-PutCharacterAttributesBack(T::indexed)
T : an indexed object, typically a tensor or also a tensor in the Physics internal representation (see ToTensorInternalRepresentation)
PutCharacterAttributesBack receives an indexed object T, typically a tensor, that has attributes regarding its indices as explained in the section for PutCharacterAttributesInTensor, and replaces each index of T by the equivalent index using the character specified in the attributes. So this is the reverse of the operation done by PutCharacterAttributesInTensor.
A_i_contravariant := setattribute(A[i], i = "contravariant");
A_i_contravariant≔Ai
PutCharacterAttributesBack(A_i_contravariant);
A⁢i⁢i
PutCharacterAttributesInExpression, PutCharacterAttributesInTensor, PutCharacterAttributesBack, UpdateCharacterAttributesInTensor, UpdateCharacterAttributesInExpression
Physics:-Library:-PutCharacterAttributesInExpression(ee, Repeated, {indexedfunction::set := indets(ee, And(Or(indexed,function)))})
ee : typically an expression involving tensors, it can be any Maple object which is not of type last_name_eval
Repeated : a set or list of indices, typically these are indices that appear repeated in ee
indexedfunction = ... : optional, an equation where the right-hand side is a set of tensors; if this is not given, all indexed or function objects that have the indices found in Repeated are considered as indexedfunction
When working with curvilinear coordinates (a curved spacetime - so that the Christoffel symbols are not zero), PutCharacterAttributesInExpression puts attributes in all the tensors that were indicated in indexedfunction and the ones that have the indices indicated in Repeated. This operation is performed using PutCharacterAttributesInTensor and is explained in PutCharacterAttributesInTensor. If the Christoffel symbols are zero, ee is returned untouched; in such a case you can still put attributes in tensors using PutCharacterAttributesInTensor.
Set the spacetime to be curvilinear, for example, via:
T := A[mu, ~nu];
T≔Aμνμν
You can put attributes in a tensor itself with PutCharacterAttributesInTensor.
eq := PutCharacterAttributesInTensor(T);
eq≔Aμνμν=Aμνμν
attributes(rhs(eq));
μ=covariant,~ν=contravariant
For expressions, use PutCharacterAttributesInExpression
e1 := T + 1;
e1≔Aμνμν+1
All tensors in e1 having the index mu will have received attributes regarding their indices.
e2 := PutCharacterAttributesInExpression(e1, [mu]);
e2≔Aμνμν+1
Ts := indets(e2, PhysicsType:-Tensor);
Ts≔Aμνμν
attributes(Ts[1]);
PutCharacterAttributesBack, PutCharacterAttributesInTensor, Physics[g_], UpdateCharacterAttributesinExpression, UpdateCharacterAttributesInTensor
Physics:-Library:-PutCharacterAttributesInTensor(T)
T : a spacetime Tensor, of type PhysicsType:-Tensor
PutCharacterAttributesInTensor receives a tensor T and returns an equation where the left-hand side is a tensor index of T, and the right-hand side is either the string covariant or contravariant according to the character of that index. This equation is useful in that it permits keeping a representation of the tensor with all its indices as subscripts (so an index is just an index, regardless of being covariant or contravariant) while keeping the information of the true character in the attributes. Note that the subs command will substitute indices both in T and also in its attributes, so that substitutions can happen without loosing information on the character of the indices.
T_indices_all_subscripts := subs(~nu = nu, rhs(eq));
T_indices_all_subscripts≔Aμ,ν
attributes(T_indices_all_subscripts);
μ=covariant,ν=contravariant
PutCharacterAttributesBack, PutCharacterAttributesInExpression, UpdateCharacterAttributesInTensor, UpdateCharacterAttributesInExpression
Physics:-Library:-PutZeroDimensionEntries(A::Or(Array, Matrix))
A : a Maple object of type Array where all of its indices range from 1 to the spacetime dimension returned by Setup(spacetimedimension)
PutZeroDimensionEntries receives an Array where all of its indices range from 1 to the spacetime dimension returned by Setup(spacetimedimension) - say n - and returns an equivalent Array adding to it indices equal to 0 and corresponding entries so that A[.., 0, ..] = A[.., n, ..]. This is relevant in the context of the Physics package, where in a spacetime of dimension n, any spacetime tensor T can have its components referred as T[.., 0, ..] = T[.., n, ..]. For example, in the default 4-D spacetime, g_[0, 0] gives you the same metric component as g_[4, 4].
Setup(dimension = 2);
Warning, unable to define the Pauli sigma matrices (Psigma) as a tensor in a space with dimension = 2 < 3. You can still refer to the Pauli matrices using Psigmax, Psigmay and Psigmaz
The dimension and signature of the tensor space are set to 2,⁢⁡- +
dimension=2
A := Array(1..2, 1..2, 1..2, [[a,b], [c,d], [e,f]]):
ArrayElems(A);
1,1,1=a,1,2,1=b,2,1,1=c,2,2,1=d
A0 := PutZeroDimensionEntries(A):
ArrayElems(A0);
0,0,1=d,0,1,1=c,1,0,1=b,1,1,1=a,1,2,1=b,2,1,1=c,2,2,1=d
A0[0,0,1] = A[2,2,1];
d=d
Array, ArrayElems
Physics:-Library:-Quiet(quiet::truefalse, Args::list)
quiet : it can be true or false
Args : a list of arguments that may or not include the word quiet or the equation quiet = true (or false).
Quiet is called from another routine to return true or false regarding whether to display (print) messages on the screen. In the typical case, the caller routine has the option {quiet::truefalse := <either true or false>}. Quiet returns true or false according to: if quiet or quiet = <either true or false> are present in Args, then return the value of the first argument passed to Quiet, otherwise, decide between the first argument, quiet and the value of _Env_Physics_print, with priority for _Env_Physics_print. This routine is uniformly used across the Physics package to handle when should messages be displayed on the screen.
Create a procedure P that returns arguments with (default) or without displaying messages on the screen, and when quiet is given, then according to its value:
P := proc({quiet::truefalse := false}) _Env_Physics_print := not Quiet(quiet, [args]); if _Env_Physics_print then print(`arguments received` = [_rest]); fi; [_rest] end;
P≔procquiet::truefalse ≔ false_Env_Physics_print ≔ notLibrary:-Quiet⁡quiet,args;if_Env_Physics_printthenprint⁡arguments received=_restend if;_restend proc
P(x,y,z);
arguments received=x,y,z
x,y,z
P(x,y,z, quiet);
When _Env_Physics_print is of type truefalse and quiet is not passed to P, the value of _Env_Physics_print, gets passed, otherwise the value of quiet has the priority.
_Env_Physics_print := false;
_Env_Physics_print≔false
P(x,y,z, quiet = false);
Physics:-Library:-RealObjects(A)
A : a function or a variable of type name
RealObjects sets and unsets mathematical variables and functions as real, and answers queries about them.
The real objects entering a mathematical computation can be set in different ways: using assume, Physics[Setup] and its parameter realobjects, and directly with the Library:-RealObjects. The advantage of using the last two methods compared to using assume is that you can reuse expressions entered before you set the objects real, and that contain those objects.
When setting or unsetting objects as real, like Physics[Setup], RealObjects returns all the objects that are real.
RealObjects(set, F, G);
F,G
F * G;
F⁢G
is((403), real);
RealObjects(unset, G);
F
assume, assuming, is, IsRealObject, Physics[Setup]
Physics:-Library:-RecycleArguments(Rest, valid_keywords,{Args::list := NULL})
Rest : a list of arguments, typically received by the routine that calls RecycleArguments, such that each element of the list is either a keyword (of type symbol) or an equation with such a keyword in the left-hand side
valid_keywords : a list of keywords that RecycleArguments accepts as valid
Args : optional, a list typically containing the actual arguments received by the routine that calls RecycleArguments
RecycleArguments receives a list Rest where each element is a keywords or a keyword = ..., typically the _rest arguments received by the routine that calls RecycleArguments, and performs a text matching of each keyword against the valid_keywords, then returns either the match when there is only one, as a list with that argument, or a set with a sequence of possible matches when there is more than one. This is particularly useful for programming routines that expect optional arguments as keyword = ... and receive just a portion of keyword - say ey. RecycleArgments is used by all the Physics commands to process optional arguments that can then be passed misspelled or incomplete, facilitating in that way the use of the Physics commands.
debug(Physics:-RecycleArguments);
`tools/GetKeywords`(Simplify);
indices,int,quiet,sum,tryhard,algebrarules,bracketrules,ordering,completeprojector,dodgammaproducts,equalizerepeatedindices,noncommutativeproducts,replaceimaginaryunit,simplifyelementaryfunctions,tryexpandvectorfunctions
Simplify(A, ind):
{--> enter RecycleArguments, args = [ind], [algebrarules, bracketrules, completeprojector, dodgammaproducts, equalizerepeatedindices, indices, int, noncommutativeproducts, ordering, quiet, replaceimaginaryunit, simplifyelementaryfunctions, sum, tryexpandvectorfunctions, tryhard]
* Partial match of 'ind' against keyword 'indices'
<-- exit RecycleArguments (now in Simplify:-ModuleApply) = [indices]}
Setup(op = A):
{--> enter RecycleArguments, args = [op = A], [abbreviations, algebrarules, anticommutativecolor, anticommutativeprefix, assumingusesAssume, automaticsimplification, bracketbasis, bracketrules, combinepowersofsamebase, coordinatesystems, cosmologicalconstant, Dgammarepresentation, differentialoperators, differentiationvariables, dimension, disjointedspaces, genericindices, geometricdifferentiation, hermitianoperators, hideketlabel, lapseandshift, levicivita, masslessfields, mathematicalnotation, metric, noncommutativeprefix, noncommutativecolor, normusesconjugate, primedvariables, quantumbasisdimension, quantumcontinuousbasis, quantumdiscretebasis, quantumoperators, realobjects, redefinesum, signature, spacetimeindices, spaceindices, spinorindices, su2indices, su2matrixindices, su3indices, su3matrixindices, tensorproductnotation, tensorsimplifier, tetrad, tetradindices, tetradmetric, traceonlymatrices, unitaryoperators, unitvectordisplay, usecoordinatesastensorindices, usephysicsevaluator, minimizetensorcomponents, usewirtingerderivatives, vectordisplay, vectorpostfix, deletesetup, hilbertspaces, operators, readsetup, realobjects, savecurrent, advanced, additionally, clear, conventions, default, deletesavedsetup, keywords, query, quiet, readusersetup, redo, savesetup], Args = [op = A]
<-- exit RecycleArguments (now in Setup:-ModuleApply) = [quantumoperators = A]}
parameter keywords
Physics:-Library:-ReformatRepeatedIndices(ee, repeatedindices::Or(list(symbol), not given) := not given , {normalizecontractedindices::truefalse := normalizecontractedproducts , normalizecontractedproducts::truefalse := false , reformatoperands::truefalse := true} , repeatedindicescovariant::truefalse := evalb(Library:-GetSetupINFO(kindofspacetime) = Euclidean) , $)
ee : any Maple expression, relation, or Array of them
repeatedindices : optional, it can be a list of tensor indices expected to appear repeatedly in ee; if given, only these repeated indices will be reformatted in ee, as one covariant and the other contravariant. Otherwise, all tensor repeated indices in ee will be reformatted
normalizecontractedproducts : optional, it can be true or false (default), so that in addition to reformatting the contracted indices, a normalization of the tensors whose indices were reformatted is carried equivalent to applying NormalizeTensor to them. See also NormalizeTensor.
normalizecontractedindices : optional, it can be true or false (default value is the value of normalizecontractedproducts), so that in addition to a normalization of the tensors whose indices were reformatted, a normalization of their indices is also performed.
reformatoperands : optional, it can be true (default) or false. This parameter is also used to reformat the indices in contracted products that appear within functions - so that ee is not linear in these products.
repeatedindicescovariant : optional, it can be true (default value when the metric is Euclidean) or false (default value otherwise). It only applies to tensors (see IsTensorInCurrentCoordinates) or their products, and is used to rewrite each pair of repeated indices as all-covariant instead of one covariant and one contravariant.
ReformatRepeatedIndices reformats the indices of contracted products of tensors within ee such that for each pair of repeated indices, in the output one index is covariant and the other is contravariant. If the pair is already one covariant and the other contravariant, it is kept as it is. Aiming at reformatting the expression entirely with the less computational cost, by default contracted products within functions are also reformatted and the tensors with repeated indices reformatted are not normalized after the process; you can override any of these defaults with the options reformatoperands = false and normalizecontractedproducts = true.
When the option normalizecontractedproducts is given, by default the option normalizecontractedindices is activated so that contracted indices are also normalized. For example, if A is a tensor then occurrences of A[j, ~j] and A[~j, j] are both normalized to A[j, ~j]. To avoid this normalization of indices, pass normalizecontractedindices = false.
By default, when the metric is Euclidean, all repeated indices are automatically reformatted as covariant. In order to have repeated indices expressed all-covariant when the metric is not Euclidean, pass the option repeatedindicescovariant. NOTE: while this option will produce the desired result within the programs, to have the repeated indices all-covariant on the screen, you need to set the Physics evaluator to false (see Setup), otherwise the repeated indices will be automatically reformatted to one covariant the other contravariant before returning a result on the screen.
Define(A, B);
A,B,γμ,σμ,∂μ,gμ,ν,εα,β,μ,ν
Setup(evaluator = false);
* Partial match of 'evaluator' against keyword 'usephysicsevaluator'
usephysicsevaluator=false
ee := A[mu] * B[mu];
ee≔Aμ⁢Bμ
ReformatRepeatedIndices(ee);
Aμ⁢B⁢μ⁢μ
ReformatRepeatedIndices((413), repeatedindicescovariant);
Aμ⁢Bμ
Define(F, antisymmetric);
A,B,F,γμ,σμ,∂μ,gμ,ν,εα,β,μ,ν
ReformatRepeatedIndices(F[mu,mu]);
Fμμμμ
ReformatRepeatedIndices(F[mu,mu], normalizecontractedproducts);
F[mu, nu] + F[nu, mu];
Fμ,ν+Fν,μ
NormalizeTensorExpression((418));
(418) * A[mu] * B[nu];
Fμ,ν+Fν,μ⁢Aμ⁢Bν
ReformatRepeatedIndices((420));
Fμ,ν+Fν,μ⁢A⁢μ⁢μ⁢B⁢ν⁢ν
ReformatRepeatedIndices((420), normalizecontractedproducts);
Physics[Setup]
Physics:-Library:-RemoveIntegerIndices({dimension::nonnegint := Physics:-GetSetupINFO(dimension)})
rest : any sequence of arguments
dimension : optional, the dimension of spacetime as returned by Setup(dimension); if not given, it is obtained using GetSetupINFO("dimension")
RemoveIntegerIndices receives a sequence of objects, or a set or list of them, and returns them after removing all those that could be an integer spacetime index. For example, the number 1, and the symbols 1 and ~1 all represent integer spacetime indices.
GetSetupINFO("dimension");
L := mu, 1, `1`, ~1, nu, 5;
L≔μ,1,1,~1,ν,5
RemoveIntegerIndices(L);
μ,ν,5
RemoveIntegerIndices([L]);
ReplaceCommonRepeatedIndices, ReplaceRepeatedIndices
Physics:-Library:-ReplaceCommonRepeatedIndices(A)
A, rest : a sequence of tensorial expressions, each one typically having contracted indices
ReplaceCommonRepeatedIndices receives a sequence of tensorial expressions, each one typically having contracted indices, and returns an equivalent sequence such that the contracted indices of each element does not appear in the contracted indices of the other elements. In other words, only the common repeated indices are replaced. See also the similar command ReplaceRepeatedIndices.
Define(A);
A,γμ,σμ,∂μ,gμ,ν,εα,β,μ,ν
ee := A[mu]^2;
ee≔Aμ⁢A⁢μ⁢μ
ReplaceCommonRepeatedIndices(ee);
Aμ⁢A⁢μ⁢μ
ee := A[mu]^2*A[nu]^2 + A[rho]^2;
ee≔Aμ⁢A⁢μ⁢μ⁢Aν⁢A⁢ν⁢ν+Aρ⁢A⁢ρ⁢ρ
ReplaceCommonRepeatedIndices(ee, A[mu]^2);
Aμ⁢A⁢μ⁢μ⁢Aν⁢A⁢ν⁢ν+Aρ⁢A⁢ρ⁢ρ,Aα⁢A⁢α⁢α
ReplaceCommonRepeatedIndices(ee, A[mu]^2*A[nu]^2);
Aμ⁢A⁢μ⁢μ⁢Aν⁢A⁢ν⁢ν+Aρ⁢A⁢ρ⁢ρ,Aα⁢A⁢α⁢α⁢Aβ⁢A⁢β⁢β
ReplaceCommonRepeatedIndices(ee, ee);
Aμ⁢A⁢μ⁢μ⁢Aν⁢A⁢ν⁢ν+Aρ⁢A⁢ρ⁢ρ,Aα⁢A⁢α⁢α⁢Aβ⁢A⁢β⁢β+Aκ⁢A⁢κ⁢κ
RemoveIntegerIndices, ReplaceRepeatedIndices
Physics:-Library:-ReplaceRepeatedIndices(A, to_be_replaced)
A : a tensorial expression
to_be_replaced : a set with indices, expressed as covariant indices, to be replaced in A whenever they appear contracted
ReplaceRepeatedIndices receives a tensorial expression A and replaces in it all repeated (contracted) indices indicated in the set to_be_replaced.
ReplaceRepeatedIndices(ee, {mu});
Aν⁢A⁢ν⁢ν
ReplaceRepeatedIndices(ee, {mu, nu});
Aα⁢Aβ⁢A⁢α⁢α⁢A⁢β⁢β+Aρ⁢A⁢ρ⁢ρ
ReplaceRepeatedIndices(ee, {rho});
Aμ⁢A⁢μ⁢μ⁢Aν⁢A⁢ν⁢ν+Aα⁢A⁢α⁢α
RemoveIntegerIndices, ReplaceCommonRepeatedIndices
Physics:-Library:-Restore({quiet::truefalse := false})
Restore uses the Physics:-Library:-Backup() command to restore from memory a Physics Setup that was backed-up in the same Maple session. Restore returns NULL.
Physics:-Library:-RootOfIndex(mu, mi := 1, ma := 7)
mu : a tensor index, it could be a greek or latin letter, lowercase or uppercase, or such a letter followed by a number, say a1, or followed by the literal subscript suffix __ and then followed by a number, such as in a__1
RootOfIndex receives a tensor index mu and returns its root; that is, the letter prefix, greek or latin, lowercase or uppercase. Contravariant indices as well as literal subscript indices are also handled.
RootOfIndex(mu);
RootOfIndex(~mu);
RootOfIndex(~mu1);
A contravariant literal subscript index:
RootOfIndex(~mu__1);
RootOfIndex(~a__1);
a
GetTypeOfIndex, IndicesOfKindOfLetter
Physics:-Library:-SearchDGMetricTable(keyword)
keyword : any text or portion of it, as a Maple symbol (enclosed by ) or as a string (enclosed by )
SearchDGMetricTable, searches the DifferentialGeometry database of solutions to Einstein's equations for occurrences of the portion of text keyword in the description of the solution.
The keys for all the metrics found in the database that contain the portion of word sc:
SearchDGMetricTable(sc);
5,21,1,12,13,1,12,27,1,12,31,1,12,32,1,13,31,1,13,32,1,14,26,2,15,17,1,15,19,1,15,19,2,16,18,1,17,16,1,33,15,1,33,44,1,36,11,1
For example:
g_[[12, 13, 1]];
⁢Systems of spacetime coordinates are:⁢X=v,x,y,u
⁢Default differentiation variables for d_, D_ and dAlembertian are:⁢X=v,x,y,u
The Ozsvath, Schucking (1962) metric in coordinates v,x,y,u
Comments: gⅇoⅆⅇsⅈcally complⅇtⅇ, no curvaturⅇ sⅈngularⅈtⅈⅇs
Resetting the signature of spacetime from - - - + to + + + - in order to match the signature in the database of metrics
g_[[16, 18, 1]];
The Schwarzschild (1916) metric in coordinates r,θ,φ,t
Parameters: κ0,R,a,b
Comments: To makⅇ thⅇ prⅇssurⅇ posⅈtⅈvⅇ nⅇar r =0, wⅇ rⅇquⅈrⅇ (a - 3*b)/(a-b) > 0. Notⅇ also that that thⅇ mⅇtrⅈc ⅈs unchangⅇⅆ by a sⅈmultanⅇous changⅇ sⅈgn of a, b
Domain: 0<r,r<R
Assumptions: 0<κ0,b<a,a<3⁢b
Signature: + + + -
Search the database about the metrics published in the year 1974:
SearchDGMetricTable("1974");
g_[[15, 31, 1]];
⁢Default differentiation variables for d_, D_ and dAlembertian are:⁢X=x,y,z,t
The Novotny, Horsky (1974) metric in coordinates x,y,z,t
Parameters: a
Domain: 0<z,z<π2⁢a
Assumptions: 0<a
Physics[g_], DifferentialGeometry[Library][MetricSearch]
Physics:-Library:-ShieldDummyIndicesInFunctionArguments(ee, use_indices_not_in_here := NULL)
ee : any Maple object that is not of type last_name_eval
use_indices_not_in_here : optional, any Maple object that is not of type last_name_eval
ShieldDummyIndicesInFunctionArguments replaces in ee all spacetime dummy (contracted) indices that appear inside functions (in their arguments) and that also appear outside the functions. If there are no functions or the dummies within them are not found outside them, nothing gets changed. To indicate that some indices are not to be used as replacements, pass a second argument, use_indices_not_in_here, that can be an expression or any other Maple object that contains the indices not to be used.
ee := G(A[mu], B[mu])*B[mu]*B[mu];
ee≔G⁡Aμ,Bμ⁢Bμ⁢B⁢μ⁢μ
In this expression, the index mu appearing in the arguments of G is not a dummy, so nothing is changed
ShieldDummyIndicesInFunctionArguments(ee);
G⁡Aμ,Bμ⁢Bμ⁢B⁢μ⁢μ
In this other expression, mu within G is a contracted index so it is changed
ee2 := A[nu]^2*G(A[mu]*B[mu]) + A[mu]*B[mu];
ee2≔Aν⁢A⁢ν⁢ν⁢G⁡Aμ⁢B⁢μ⁢μ+Aμ⁢B⁢μ⁢μ
ShieldDummyIndicesInFunctionArguments(ee2);
Aν⁢A⁢ν⁢ν⁢G⁡Aα⁢B⁢α⁢α+Aμ⁢B⁢μ⁢μ
Indicate that alpha should not be used as new dummy contracted index
ShieldDummyIndicesInFunctionArguments(ee2, alpha);
Aν⁢A⁢ν⁢ν⁢G⁡Aβ⁢B⁢β⁢β+Aμ⁢B⁢μ⁢μ
Physics:-Library:-SortAnticommutativeList(L1::list, L2::list := sort(L1), {verifyanticommutativity::truefalse := false})
L1 : a list of anticommutative objects
L2 : optional, another list of anticommutative objects indicating the preferred ordering to be achieved
verifyanticommutativity : optional, can be true or false (default), to verify that the elements of L1 and L2 are indeed anticommutative before proceeding with reordering them
SortAnticommutativeList receives two lists of anticommutative objects and sorts the first one according to the ordering of the second one, then returns a sequence of two objects: the number 1 or -1 according to the number of permutations performed during the sorting, followed by the sorted L1. If L2 is not given, the pattern used to reorder L1 is the one returned by sort(L1). Note that L2 does not need to have the same number of elements as L1.
Setup(anticommutativeprefix = a);
anticommutativeprefix=a
L1 := [a[1], a[2], a[3]];
L1≔a1,a2,a3
L2 := [a[3], a[1]];
L2≔a3,a1
SortAnticommutativeList(L1, L2);
1,a3,a1,a2
L2 := [a[3], a[2]];
L2≔a3,a2
−1,a3,a2,a1
sort, antisymmetric
Physics:-Library:-SortQuantumObjectsThatCommute(A, B)
A : a quantum object (so of type noncommutative) that is assumed to commute with B, another quantum object
B : same as A, a quantum object assumed to commute with A
Suppose two noncommutative objects, A and B, are given, and in addition, suppose they commute. In these situations, in order to recognize that A⁢B is equal to B⁢A it is necessary to express both with the same ordering. SortQuantumObjectsThatCommute accomplishes that task choosing an ordering for the sequence A, B, and returning true or false according to whether the ordering given matches the one preferred by this command. The preferred ordering is an extension of the concept of normal ordering in field theories (creation operators to the left of annihilation operators, or if A and B refer to the same basis of quantum states, then sort ascending by quantum numbers, or fermionic operators to the left of bosonic ones, and so on).
Setup(op = {A, B}, %Commutator(A, B) = 0);
algebrarules=A,B−=0,quantumoperators=A,B
SortQuantumObjectsThatCommute(am, ap);
SortQuantumObjectsThatCommute(A[1], A[2]);
SortQuantumObjectsThatCommute(B, A);
AntiCommute, Commute
Physics:-Library:-StripTilde(mu, {actonpowers::truefalse := false})
mu : a tensor index, of type symbol
actonpowers : optional, to act on powers stripping the tilde ~ in the base of the power, expected to be a tensor index of type symbol
StripTilde receives mu, a tensor index, of type symbol, and if mu is a contravariant index, so that its first character is the tilde ~, it strips out the tilde, otherwise it returns mu unchanged. If the option actonpowers is passed, then if mu is actually a power where the base is a symbol, then StripTilde returns the power after stripping the tilde from its base.
~mu;
StripTilde(~mu);
StripTilde(mu);
StripTilde(~mu^2);
~μ2
StripTilde(~mu^2, actonpowers);
μ2
Contravariant, Covariant, FlipCharacter, StripTildeFromRepeatedIndices
Physics:-Library:-StripTildeFromRepeatedIndices(L)
L : a list of indices, possibly containing powers or products of them, or a power or product of indices, or an an object of indexed with indices of type symbol, that it is a tensor defined using Define
StripTildeFromRepeatedIndices detects the repeated indices in L, and if there are contravariant indices in this subset, so prefixed with the tilde ~, it strips the tilde from them.
L := [mu, ~mu, nu, ~nu];
L≔μ,~μ,ν,~ν
StripTildeFromRepeatedIndices(L);
μ,μ,ν,ν
L := `*`(op(L));
L≔μ⁢~μ⁢ν⁢~ν
μ2⁢ν2
L := map(u -> u^2, [op(L)]);
L≔μ2,~μ2,ν2,~ν2
μ2,μ2,ν2,ν2
ee := A[mu,~mu];
ee≔Aμμμμ
StripTildeFromRepeatedIndices(ee);
Aμμμμ
Contravariant, Covariant, FlipCharacter, StripTilde
Physics:-Library:-SubsTensorIndices(eqs, ee, Tensors::set := indets(ee,Physics:-Tensor))
eqs : a list of substitution equations for indices
ee : the object where indices are to be substituted, typically an expression, it could be any Maple object not of type last_name_eval
Tensors : optional, a set with the tensors where substitutions are to be performed - if not given, the substitutions are performed in all the objects of type PhysicsType:-Tensor found in ee
SubsTensorIndices substitutes the list of equations eqs with indices substitutions into the object ee, typically an expression containing tensors (defined using Physics:-Define, so of type PhysicsType:-Tensor). You can restrict the substitutions to only some tensors by giving them within a set as a third argument. The tensors in ee are expected to be either indexed objects, as in T[mu, nu, ...], or indexed functions, say as in T[mu, nu, ...](X). Given a covariant index equation like mu = alpha, SubsTensorIndices automatically replaces both the covariant mu = alpha and contravariant ~mu = ~alpha indices. SubsTensorIndices is a simplified and fast version of the command Physics:-SubstituteTensorIndices, useful when the tensors in ee are of this specific simple form mentioned: indexed or indexed functions.
Define(A, B, quiet):
ee := A[mu]*B[mu] + A[mu]*A[mu] + B[mu]*B[mu] + C[mu,mu];
ee≔Aμ⁢A⁢μ⁢μ+Aμ⁢B⁢μ⁢μ+Bμ⁢B⁢μ⁢μ+Cμ,μ
In the above, C[mu,mu] is not a tensor, so substitutions are not performed in it
SubsTensorIndices([mu = nu], ee);
Aν⁢A⁢ν⁢ν+Aν⁢B⁢ν⁢ν+Bν⁢B⁢ν⁢ν+Cμ,μ
Physics[SubstituteTensor], Physics[SubstituteTensorIndices], ShieldDummyIndicesInFunctionArguments
Physics:-Library:-TensorComponents(T::Or(algebraic,rtable,relation(Or(algebraic,rtable))))
T : a tensorial expression, or a relation between tensorial expressions, or an rtable (typically Array) of them
TensorComponents returns an ordered list of the tensor components of the tensorial expression T. Covariant and contravariant (prefixed by ~) indices are respected. The ordering in the list returned corresponds to the ascending numerical positions of these components in the corresponding tensor Array of components. See TensorArray.
The contravariant spacetime vector X[mu]
TensorComponents(X[~mu]);
The covariant spacetime vector X[mu]
TensorComponents(X[mu]);
−x1,−x2,−x3,x4
A,γμ,σμ,∂μ,gμ,ν,εα,β,μ,ν,Xμ
TensorComponents(A[~mu]);
A⁢1⁢1,A⁢2⁢2,A⁢3⁢3,A⁢4⁢4
TensorComponents(A[mu]);
A1,A2,A3,A4
Physics[SumOverRepeatedIndices], Physics[TensorArray]
Physics:-Library:-ToContravariant(EE, {evaluatetensor::truefalse := true, evaluateexpression::truefalse := true, totensorinternalrepresentation::truefalse := true, fromtensorinternalrepresentation::truefalse := true})
EE : any maple object where subs and eval can perform substitutions, typically a tensorial expression with free and repeated (contracted) tensor indices
evaluatetensor : optional, default value is true, to evaluate the tensor after rewriting it with contravariant indices; this may be relevant when the tensor has symmetry properties under permutation of its indices
evaluateexpression : optional, default value is true, to evaluate the expression EE after rewriting it with all tensors in contravariant form
totensorinternalrepresentation : optional, default value is true, to rewrite the tensors in EE using the internal Physics representation before proceeding
fromtensorinternalrepresentation : optional, default value is true, to rewrite back,using the user-level representation, all the tensors entering the result
ToContravariant rewrites all covariant indices of tensors in EE as contravariant ones by replacing the tensors with contracted products using the metric, say as in replacing A[mu] by g_[mu, nu] * A[~nu]. Note that this rewriting does not change their covariant or contravariant character of the free indices of EE, so this rewriting is different from multiplying EE by the metric in order to raise its free indices.
Define(A, B, C, F);
A,B,C,F,γμ,σμ,∂μ,gμ,ν,εα,β,μ,ν
A tensorial expression with mu and nu as free indices and rho as contracted index
A[mu]*B[`~nu`]+C[mu, `~nu`]*F[rho, rho];
Aμ⁢B⁢ν⁢ν+Cμνμν⁢Fρρρρ
ToContravariant((496));
gα,μ⁢C⁢α,ν⁢α,ν⁢gβ,ρ⁢F⁢β,ρ⁢β,ρ+gα,μ⁢A⁢α⁢α⁢B⁢ν⁢ν
Note that the free indices have not changed:
Check((497), all);
The repeated indices per term are: ...,...,..., the free indices are: ...
α,β,ρ,α,μ,~ν
ToCovariant((496));
g⁢α,ν⁢α,ν⁢Cμ,α⁢g⁢β,ρ⁢β,ρ⁢Fρ,β+Aμ⁢g⁢α,ν⁢α,ν⁢Bα
ToContravariant((499));
g⁢α,ν⁢α,ν⁢gκ,μ⁢gα,λ⁢C⁢κ,λ⁢κ,λ⁢g⁢β,ρ⁢β,ρ⁢gρ,σ⁢gβ,τ⁢F⁢σ,τ⁢σ,τ+gβ,μ⁢A⁢β⁢β⁢g⁢α,ν⁢α,ν⁢gα,κ⁢B⁢κ⁢κ
Simplify((500));
Aμ⁢B⁢ν⁢ν+Cμνμν⁢Fττττ
Contravariant, eval, Physics[Check], subs, SubstituteTensor, ToCovariant
Physics:-Library:-ToCovariant(EE, {evaluatetensor::truefalse := true, evaluateexpression::truefalse := true, totensorinternalrepresentation::truefalse := true, fromtensorinternalrepresentation::truefalse := true})
evaluatetensor : optional, default value is true, to evaluate the tensor after rewriting it with covariant indices; this may be relevant when the tensor has symmetry properties under permutation of its indices
ToCovariant rewrites all contravariant indices of tensors in EE as covariant ones by replacing the tensors with contracted products using the metric, say as in replacing A[~mu] by g_[~mu, ~nu] * A[nu]. Note that this rewriting does not change their covariant or contravariant character of the free indices of EE, so this rewriting is different from multiplying EE by the metric in order to lower its free indices.
ToCovariant((503));
Check((504), all);
ToCovariant((506));
Simplify((507));
Contravariant, eval, Physics[Check], subs, SubstituteTensor, ToContravariant
Physics:-Library:-ToGeneralRelativityTensorFunctionalForm(A, $)
ToGeneralRelativityTensorFunctionalForm receives an expression A containing general relativity tensors without functionality and returns the same expression after introducing the functionality found in the spacetime metric g_, including parameters if any, followed by a set with the substitution equations used. This is useful when intermediate computations should take into account (or not) this functionality - see also FromGeneralRelativityTensorFunctionalForm.
e1 := Riemann[alpha, beta, mu,nu] + g_[mu,nu];
e1≔Rα,β,μ,ν+gμ,ν
ToGeneralRelativityTensorFunctionalForm(e1);
Rα,β,μ,ν⁡r,θ,m+gμ,ν⁡r,θ,m,Rα,β,μ,ν=Rα,β,μ,ν⁡r,θ,m,gμ,ν=gμ,ν⁡r,θ,m
FromGeneralRelativityTensorFunctionalForm, GetGeneralRelativityTensorFunctionalForm, Physics[g_]
Physics:-Library:-ToSpaceTimeVector(ee,{evaluateatintegers::truefalse := true})
ToSpaceTimeVector converts to the SpaceTimeVector[mu](X) notation all occurrences of spacetime vectors, written as X[mu], where X is a sequence of spacetime coordinates.
X_mu := X[mu];
ToSpaceTimeVector(X_mu);
Xμ
FromSpaceTimeVector, GetSpaceTimeVectors
Physics:-Library:-ToTensorFunctionalForm(A, $)
A : an algebraic expression involving tensors that appear as indexed objects, which however do have functional dependency,
ToTensorFunctionalForm receives an expression A containing tensors that appear as indexed objects - say as in T[i,j] - which however do have functional dependency, either because they were defined as such, or because they are the general relativity tensors and the spacetime is non nongalilean - the metric depends on the spacetime coordinates, and returns the same expression after inserting the functionality of these tensors - say as in T[i,j](X) - followed by a set with the substitution equations used. This is useful when intermediate computations should take into account (or not) this functionality. In this sense, ToTensorFunctionalForm is a generalization of the Maple 17 FromGeneralRelativityTensorFunctionalForm command that handles also user defined tensor functions, and performs the reverse operation of FromTensorFunctionalForm.
Define a system of coordinates and tensor depending on some variables
The system now knows about this dependency on t and m, so that the derivatives of pμ are not zero
Put and remove the functionality
ToTensorFunctionalForm((518));
FromTensorFunctionalForm((519)[1]);
ToTensorFunctionalForm(e1);
FromGeneralRelativityTensorFunctionalForm, FromTensorFunctionalForm, GetGeneralRelativityTensorFunctionalForm, GetTensorFunctionalForm, GetTensorDependency, ToGeneralRelativityTensorFunctionalForm, Physics[g_]
Physics:-Library:-ToTensorInternalRepresentation(expr)
expr : a mathematical expression containing tensors (see Physics:-Define)
ToTensorInternalRepresentation replaces in the given expression all tensor functions defined using the Physics Define command by an internal representation that contains the same information and is of type indexed, permitting a more uniform manipulation of the different kinds of tensors that can be constructed composing tensors and linear or tensorial operators. The output consists of a sequence of two elements: first there is a set with all the tensors found in expr written in the internal representation, then comes the expression itself after having replaced the tensors by their internal representation.
This internal representation involves three local variables of the Physics package; these are: Physics:-_tenop, used when a linear tensorial operator has for arguments a tensor; Physics:-_tenfunc, used when the arguments of the operator do not contain tensors and Physics:-_dotidx, used to represent the indices within the 0th operand of this internal indexed representation.
ToTensorInternalRepresentation(d_[mu](A(X)));
_tenfunc⁡ⅆ,A⁡X,Xμ,_tenfunc⁡ⅆ,A⁡X,Xμ
Physics:-Library:-TypesetPrint(text,{shieldcoordinatesalias::truefalse := true})
text, rest : any mathematical expression in Maple syntax, or symbol, or a sequence of any of them, typically portions of text enclosed between `` and meant to be displayed without the surrounding '
TypesetPrint receives a sequence of text and mathematical formulas, the former as Maple symbols, normal text enclosed between ``, the latter written in Maple syntax, and displays the sequence on the screen, without commas in between the text and the formulas (different from the standard print command), with the text italicized and the formulas with typesetting in 2D math, using traditional mathematical notation for Physics objects (equivalent to setting interface(typesetting = extended)). Additionally, if the environment variable _Env_Physics_print = false, nothing is displayed. This routine is used across the Physics package together with Quiet, in order to display (Yes or No) text or text and formulas on the screen with full mathematical notation.
TypesetPrint(`The greek letters of the list `, [alpha, beta, gamma], ` enter this integral `, Int('d_[alpha](A[~beta])'*A[~gamma], x));
The greek letters of the list α,β,γ enter this integral ∫∂α⁡A⁢β⁢β⁢A⁢γ⁢γⅆx
print, Quiet, Typesetting
Physics:-Library:-UpdateCharacterAttributesInExpression(ee,S,{idx_in := [attributes(S)], idx_out := idx_in})
ee : typically an expression containing tensors, it could be any Maple object not of type last_name_eval
S : a tensor or list of them
idx_in : optional, the indices of S whose attributes should be used to update the attributes of these indices in the tensors found in ee
idx_out : optional, the indices of tensors in ee whose attributes should be updated with the attributes of these indices in S
When the Christoffel symbols are not zero (curved spacetime) UpdateCharacterAttributesInExpression will update the attributes of the indices of all the tensors in ee with the attributes of the same indices found in the tensor S or in the list of tensors S. Optionally you can indicate which indices are to be considered in S with the optional argument indx_in = ... where the right-hand side is a list of indices; likewise you can optionally specify which indices must have their attributes updated with the optional argument idx_out = ... and the right-hand side is a list with these indices. Note: Only the indices of tensors in ee that already have attributes when calling UpdateCharacterAttributesInExpression will have their attributes updated. This type of manipulation is used together with PutCharacterAttributesInTensor, PutCharacterAttributesInExpression, UpdateCharacterAttributesInTensor and PutCharacterAttributesBack to manipulate tensorial expressions in curved spacetimes, that have covariant and contravariant indices, while having all them expressed as subscripts.
Define(A, B, C, quiet):
B_k_contravariant := setattribute(B[k], k = "contravariant");
B_k_contravariant≔Bk
C_ik_covariant := setattribute(C[i,k], i = "covariant", k = "covariant");
C_ik_covariant≔Ci,k
ee := A_i_contravariant * B_k_contravariant + g_[i,k];
ee≔Ai⁢Bk+gi,k
ee_covariant := UpdateCharacterAttributesInExpression(ee, C_ik_covariant);
ee_covariant≔Ai⁢Bk+gi,k
Ts := indets(ee_covariant, PhysicsType:-Tensor);
Ts≔gi,k,Ai,Bk
Only the indices that have attributes (so only in A and B) have their attributes updated
map(u -> (u = attributes(u)), Ts);
gi,k=,Ai=i=covariant,Bk=i=covariant
PutCharacterAttributesInExpression, PutCharacterAttributesBack, UpdateCharacterAttributesInTensor, UpdateCharacterAttributesInExpression
Physics:-Library:-UpdateCharacterAttributesInTensor(T,S,{idx_in := map(lhs,[if(S::(list),op(map(attributes,S)),attributes(S))]), idx_out := idx_in})
idx_in : optional, the indices of S whose attributes should be used to update the attributes of these indices in T
idx_out : optional, the indices of T whose attributes should be updated with the attributes of these indices in S
UpdateCharacterAttributesInTensor will update the attributes of the indices of the tensor T with the attributes of the same indices found in the tensor S or in the list of tensors S. Optionally you can indicate which indices are to be considered in S with the optional argument idx_in = ... where the right-hand side is a list of indices; likewise you can optionally specify which indices must have their attributes updated with the optional argument idx_out = ... and the right-hand side is a list with these indices. Note: Only the indices of T that already have attributes when calling UpdateCharacterAttributesInTensor will have their attributes updated. This type of manipulation is used together with PutCharacterAttributesInTensor, PutCharacterAttributesInExpression, UpdateCharacterAttributesInExpression and PutCharacterAttributesBack to manipulate tensorial expressions in curved spacetimes, that have covariant and contravariant indices, while having all them expressed as subscripts.
Set attributes to A[i] indicating the character of its index, regardless of it being a subscript
A_i := setattribute(A[i], i = "contravariant");
A_i≔Ai
attributes(A_i);
i=contravariant
The same for B[i, k]
B_ik_covariant := setattribute(B[i,k], i = "covariant", k = "covariant");
B_ik_covariant≔Bi,k
A_i := UpdateCharacterAttributesInTensor(A_i, B_ik_covariant);
i=covariant
PutCharacterAttributesInExpression, PutCharacterAttributesBack, UpdateCharacterAttributesInTensor, UpdateCharacterAttributesInExpression, Physics[Define], Physics[g_]
Physics:-Library:-UpdateQnInUse()
rest : any sequence of parameters
UpdateQnInUse returns the indets of type symbol found in the arguments received and in the environment variable _Env_Qn_in_use. This is used to update the value of _Env_Qn_in_use within programs: variables present in _Env_Qn_in_use are discarded by GetAntiCommutativeSymbol, GetCommutativeSymbol, GetNonCommutativeSymbol, GetIndicesOfType and in general by all the Physics:-Library commands that return symbol variables for different purposes (e.g. for representing contracted indices in an expression that already has indices that are not these contracted ones).
UpdateQnInUse();
∅
_Env_Qn_in_use := mu;
_Env_Qn_in_use≔μ
ν
_Env_Qn_in_use := UpdateQnInUse([mu, nu]);
_Env_Qn_in_use≔μ,ν
α
Environment Variables
Physics, Physics conventions, Physics examples, Physics Updates, Tensors - a complete guide, Mini-Course Computer Algebra for Physicists
Compatibility
The Physics:-Library command was introduced in Maple 17.
For more information on Maple 17 changes, see Updates in Maple 17.
The Physics:-Library command was updated in Maple 2017.
Download Help Document