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−